优化 刷新进度显示文本
This commit is contained in:
parent
56853c2243
commit
ac7ec56997
|
|
@ -33,7 +33,7 @@
|
||||||
<Descriptions Title="任务详情" Bordered>
|
<Descriptions Title="任务详情" Bordered>
|
||||||
|
|
||||||
<DescriptionsItem Title="@rowData.Data.LastEnum.ToString()">
|
<DescriptionsItem Title="@rowData.Data.LastEnum.ToString()">
|
||||||
@rowData.Data.Progress%
|
@rowData.Data.Progress
|
||||||
</DescriptionsItem>
|
</DescriptionsItem>
|
||||||
|
|
||||||
<DescriptionsItem Title="操作" Span="2">
|
<DescriptionsItem Title="操作" Span="2">
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ using SixLabors.ImageSharp;
|
||||||
using SixLabors.ImageSharp.PixelFormats;
|
using SixLabors.ImageSharp.PixelFormats;
|
||||||
using SixLabors.ImageSharp.Processing;
|
using SixLabors.ImageSharp.Processing;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using System;
|
||||||
|
using Microsoft.VisualBasic.FileIO;
|
||||||
|
|
||||||
namespace VideoAnalysisCore.AICore.FFMPGE
|
namespace VideoAnalysisCore.AICore.FFMPGE
|
||||||
{
|
{
|
||||||
|
|
@ -51,6 +53,12 @@ namespace VideoAnalysisCore.AICore.FFMPGE
|
||||||
throw new Exception("存在PPTCOde但未能找到对应资源文件");
|
throw new Exception("存在PPTCOde但未能找到对应资源文件");
|
||||||
var ffmpeg = new Engine(FFmpegPath);
|
var ffmpeg = new Engine(FFmpegPath);
|
||||||
var cToken = new CancellationToken();
|
var cToken = new CancellationToken();
|
||||||
|
RedisExpand.SetTaskProgress(task, "Frame=>10%");
|
||||||
|
|
||||||
|
foreach (string jpgFile in Directory.GetFiles(localPath, "*.jpg"))
|
||||||
|
FileSystem.DeleteFile(jpgFile, UIOption.OnlyErrorDialogs, RecycleOption.DeletePermanently);
|
||||||
|
RedisExpand.SetTaskProgress(task, "Frame=>20%");
|
||||||
|
|
||||||
await ffmpeg.ExecuteAsync($"-i {filePath} -vf \"fps=1/{intervalSec},scale=320:180\" {localPath}/frame_%03d.jpg", cToken);
|
await ffmpeg.ExecuteAsync($"-i {filePath} -vf \"fps=1/{intervalSec},scale=320:180\" {localPath}/frame_%03d.jpg", cToken);
|
||||||
|
|
||||||
//视频关键帧分析
|
//视频关键帧分析
|
||||||
|
|
@ -58,9 +66,8 @@ namespace VideoAnalysisCore.AICore.FFMPGE
|
||||||
.OrderBy(f => f)
|
.OrderBy(f => f)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
RedisExpand.SetTaskProgress(task, "Frame=>50%");
|
||||||
Image<Rgb24> prevFrame = null;
|
Image<Rgb24> prevFrame = null;
|
||||||
string outputDir = "output";
|
|
||||||
Directory.CreateDirectory(outputDir);
|
|
||||||
var keyFrames = new List<int>();
|
var keyFrames = new List<int>();
|
||||||
foreach (var frameFile in frameFiles)
|
foreach (var frameFile in frameFiles)
|
||||||
{
|
{
|
||||||
|
|
@ -83,8 +90,15 @@ namespace VideoAnalysisCore.AICore.FFMPGE
|
||||||
prevFrame = currFrame.Clone();
|
prevFrame = currFrame.Clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 遍历数组
|
||||||
|
for (int i = 1; i < keyFrames.Count(); i++)
|
||||||
|
{
|
||||||
|
keyFrames[i] += 10;//ppt与课堂视频时间修正
|
||||||
|
if (keyFrames[i] - keyFrames[i - 1] < 10)
|
||||||
|
keyFrames[i] = -1;
|
||||||
|
}
|
||||||
//写入数据库
|
//写入数据库
|
||||||
var keyFramStr = JsonSerializer.Serialize(keyFrames);
|
var keyFramStr = JsonSerializer.Serialize(keyFrames.Where(s=>s!=-1));
|
||||||
await DbScoped.Sugar
|
await DbScoped.Sugar
|
||||||
.Updateable<VideoTask>()
|
.Updateable<VideoTask>()
|
||||||
.SetColumns(it => it.PPTKeyFrame == keyFramStr)
|
.SetColumns(it => it.PPTKeyFrame == keyFramStr)
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ using System.Threading;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using VideoAnalysisCore.AICore.GPT.ChatGPT;
|
using VideoAnalysisCore.AICore.GPT.ChatGPT;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
||||||
{
|
{
|
||||||
|
|
@ -153,7 +154,7 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
||||||
var lastChat = new ChatResSSE();
|
var lastChat = new ChatResSSE();
|
||||||
var splitCount = "data:".Length;
|
var splitCount = "data:".Length;
|
||||||
var maxLoop = 60*1000;
|
var maxLoop = 60*1000;
|
||||||
int threshold = 50;
|
int threshold = 0;
|
||||||
while (maxLoop>0)
|
while (maxLoop>0)
|
||||||
{
|
{
|
||||||
line = reader.ReadLine();
|
line = reader.ReadLine();
|
||||||
|
|
@ -191,11 +192,8 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
||||||
if (!string.IsNullOrEmpty(strReasoning))
|
if (!string.IsNullOrEmpty(strReasoning))
|
||||||
messageBuilder1.Append(strReasoning);
|
messageBuilder1.Append(strReasoning);
|
||||||
var steamCount = messageBuilder.Length + messageBuilder1.Length;
|
var steamCount = messageBuilder.Length + messageBuilder1.Length;
|
||||||
if (steamCount> threshold)
|
if (++threshold%30==0)
|
||||||
{
|
RedisExpand.SetTaskProgress(chatReq.taskId, "steam=>"+ steamCount);
|
||||||
threshold += threshold;
|
|
||||||
Console.WriteLine(DateTime.Now + "=>接收到流 " + steamCount);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,10 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
||||||
/// <para>该模型还可用于生成音频。自 请求此模型同时生成文本和音频响应,您可以 用:gpt-4o-audio-preview["text", "audio"]</para>
|
/// <para>该模型还可用于生成音频。自 请求此模型同时生成文本和音频响应,您可以 用:gpt-4o-audio-preview["text", "audio"]</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string modalities { get; set; } = "[\"json\"]";
|
public string modalities { get; set; } = "[\"json\"]";
|
||||||
|
/// <summary>
|
||||||
|
/// 任务id
|
||||||
|
/// </summary>
|
||||||
|
public string taskId { get; set; }
|
||||||
public object stream_options { get; set; } = new { include_usage = true };
|
public object stream_options { get; set; } = new { include_usage = true };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -519,13 +519,13 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
||||||
.Select(s => s.Start + ":" + s.Text));
|
.Select(s => s.Start + ":" + s.Text));
|
||||||
var keyFrameArr = string.IsNullOrEmpty(taskInfo?.PPTVideoCode)
|
var keyFrameArr = string.IsNullOrEmpty(taskInfo?.PPTVideoCode)
|
||||||
?string.Empty
|
?string.Empty
|
||||||
: $"通过分析视频图像得到了视频授课内容发生了变化的时间节点{taskInfo.PPTKeyFrame},授课阶段应当在附近时间发生变化。" ;
|
: $"视频授课内容发生了变化的时间节点{taskInfo.PPTKeyFrame},授课阶段应当在附近时间发生变化。" ;
|
||||||
var resFormat = """[{"StartTime":开始秒(number),"EndTime":结束秒(number),"Stage":阶段(string),"Theme":主题(string),"Content":内容总结(string)}]""";
|
var resFormat = """[{"StartTime":开始秒(number),"EndTime":结束秒(number),"Stage":阶段(string),"Theme":主题(string),"Content":内容总结(string)}]""";
|
||||||
var postMessages =
|
var postMessages =
|
||||||
$"请通过视频字幕内容分析出视频中{subject}课堂的授课阶段。" +
|
$"请通过视频字幕内容分析出视频中{subject}课堂的授课阶段。" +
|
||||||
$"课堂内容与{fileNameInfoRes.授课章节}章节相关" +
|
$"课堂内容与{fileNameInfoRes.授课章节}章节相关。" +
|
||||||
$"{keyFrameArr}" +
|
$"{keyFrameArr}" +
|
||||||
$"完整的课堂标准流程包含以下5个阶段:课程引入/新知讲解/例题精讲/课堂练习/课程总结。" +
|
$"完整的课堂标准流程包含以下5个阶段:课程引入/新知讲解/例题精讲/课堂练习/知识总结。" +
|
||||||
$"通过授课阶段的主要讲解内容分析出对应的授课阶段内容总结。" +
|
$"通过授课阶段的主要讲解内容分析出对应的授课阶段内容总结。" +
|
||||||
$"通过生成的内容总结分析出对应的授课阶段主题。 " +
|
$"通过生成的内容总结分析出对应的授课阶段主题。 " +
|
||||||
$"请注意 本次分析的视频字幕只是其中一部分 不需要分析出所有类型的授课阶段。" +
|
$"请注意 本次分析的视频字幕只是其中一部分 不需要分析出所有类型的授课阶段。" +
|
||||||
|
|
@ -647,7 +647,7 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
||||||
|
|
||||||
public async Task<T> ChatAsync<T>(string task, string postMessages, string postMessages1, string model = "deepseek-reasoner")
|
public async Task<T> ChatAsync<T>(string task, string postMessages, string postMessages1, string model = "deepseek-reasoner")
|
||||||
{
|
{
|
||||||
var maxTokens = 4000;
|
var maxTokens = 6000;
|
||||||
Message[] messageArr = [
|
Message[] messageArr = [
|
||||||
new Message(postMessages,"user"),
|
new Message(postMessages,"user"),
|
||||||
string.IsNullOrEmpty(postMessages1)?null:new Message(postMessages1,"user"),
|
string.IsNullOrEmpty(postMessages1)?null:new Message(postMessages1,"user"),
|
||||||
|
|
@ -655,6 +655,7 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
|
||||||
messageArr = messageArr.Where(s => s != null).ToArray();
|
messageArr = messageArr.Where(s => s != null).ToArray();
|
||||||
var chatRep = new ChatRequest
|
var chatRep = new ChatRequest
|
||||||
{
|
{
|
||||||
|
taskId = task,
|
||||||
model = model,
|
model = model,
|
||||||
stream = model == "deepseek-reasoner",
|
stream = model == "deepseek-reasoner",
|
||||||
max_tokens = maxTokens,
|
max_tokens = maxTokens,
|
||||||
|
|
|
||||||
|
|
@ -220,7 +220,7 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx
|
||||||
End = (float)Math.Round(startTime + duration, 2, MidpointRounding.AwayFromZero),
|
End = (float)Math.Round(startTime + duration, 2, MidpointRounding.AwayFromZero),
|
||||||
});
|
});
|
||||||
if (!string.IsNullOrEmpty(task))
|
if (!string.IsNullOrEmpty(task))
|
||||||
RedisExpand.SetTaskProgress(task, (double)(startTime + duration) / (totalSecond) * 100);
|
RedisExpand.SetTaskProgress(task, Math.Round((double)(startTime + duration) / (totalSecond) * 100,2)+"%");
|
||||||
}
|
}
|
||||||
VAD.Pop();
|
VAD.Pop();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue