From d1bbce8baf0e6f8129a215bfe7ca6ad6c156d1fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=82=A5=E7=BE=8A?= <1048382248@qq.com> Date: Tue, 22 Apr 2025 10:41:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20=E8=BF=87=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E8=87=AA=E5=8A=A8=E4=BB=BB=E5=8A=A1=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20ppt=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Expand/CoravelExpand.cs | 3 --- VideoAnalysis/Expand/CoravelExpand.cs | 1 - .../AICore/FFMPGE/FFMPGEHandle.cs | 9 ++++--- .../AICore/GPT/DeepSeek/DeepSeekClient.cs | 1 + .../AICore/GPT/DeepSeek/DeepSeek_GPT.cs | 6 ++--- VideoAnalysisCore/Common/DownloadFile.cs | 24 ++++++++++++------- .../Controllers/LJZK_Controller.cs | 3 ++- 7 files changed, 26 insertions(+), 21 deletions(-) diff --git a/Learn.VideoAnalysis.API/Expand/CoravelExpand.cs b/Learn.VideoAnalysis.API/Expand/CoravelExpand.cs index 9586794..cd419f2 100644 --- a/Learn.VideoAnalysis.API/Expand/CoravelExpand.cs +++ b/Learn.VideoAnalysis.API/Expand/CoravelExpand.cs @@ -18,7 +18,6 @@ namespace Learn.VideoAnalysis.API.Expand Console.WriteLine($"{DateTime.Now}=>初始化 Coravel"); service.AddScheduler(); - service.AddTransient(); service.AddTransient(); service.AddTransient(); } @@ -26,8 +25,6 @@ namespace Learn.VideoAnalysis.API.Expand { provider.ApplicationServices.UseScheduler(scheduler => { - //每5分钟执行一次 未处理视频扫描 - scheduler.Schedule().EveryFiveMinutes(); //文件包分析 scheduler.Schedule().EveryThirtyMinutes(); //每30分钟执行一次 }); diff --git a/VideoAnalysis/Expand/CoravelExpand.cs b/VideoAnalysis/Expand/CoravelExpand.cs index 669edb6..4debc9d 100644 --- a/VideoAnalysis/Expand/CoravelExpand.cs +++ b/VideoAnalysis/Expand/CoravelExpand.cs @@ -18,7 +18,6 @@ namespace Learn.VideoAnalysis.Expand Console.WriteLine($"{DateTime.Now}=>初始化 Coravel"); service.AddScheduler(); - service.AddTransient(); service.AddTransient(); service.AddTransient(); } diff --git a/VideoAnalysisCore/AICore/FFMPGE/FFMPGEHandle.cs b/VideoAnalysisCore/AICore/FFMPGE/FFMPGEHandle.cs index 0e3f4dc..43a4456 100644 --- a/VideoAnalysisCore/AICore/FFMPGE/FFMPGEHandle.cs +++ b/VideoAnalysisCore/AICore/FFMPGE/FFMPGEHandle.cs @@ -40,7 +40,7 @@ namespace VideoAnalysisCore.AICore.FFMPGE var taskID = long.Parse(task); //间隔秒 var intervalSec = 5; - var threshold = 15.0; + var threshold = 8.15; var PPTVideoCode = await DbScoped.Sugar .Queryable() .Where(s => s.Id == long.Parse(task)) @@ -83,8 +83,11 @@ namespace VideoAnalysisCore.AICore.FFMPGE keyFrames.Add((int)timestamp); //string outputPath = Path.Combine(outputDir, $"change_{timestamp:0000}.jpg"); //currFrame.Save(outputPath); - //Console.WriteLine($"变化帧: {timestamp}秒,差异值: {diff:F2}"); + Console.WriteLine($"变化帧: {timestamp}秒,差异值: {diff:F2}"); } + else + Console.WriteLine($"帧: {timestamp}秒,差异值: {diff:F2}"); + } prevFrame?.Dispose(); prevFrame = currFrame.Clone(); @@ -93,7 +96,7 @@ namespace VideoAnalysisCore.AICore.FFMPGE // 遍历数组 for (int i = 1; i < keyFrames.Count(); i++) { - keyFrames[i] += 10;//ppt与课堂视频时间修正 + keyFrames[i] += 5;//ppt与课堂视频时间修正 if (keyFrames[i] - keyFrames[i - 1] < 10) keyFrames[i] = -1; } diff --git a/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeekClient.cs b/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeekClient.cs index 4b9e6e7..0608794 100644 --- a/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeekClient.cs +++ b/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeekClient.cs @@ -144,6 +144,7 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek if (!chatResp.IsSuccessStatusCode) { Console.WriteLine(DateTime.Now + "=>请求GPT服务器异常 " + chatResp?.StatusCode); + Console.WriteLine(await chatResp.Content.ReadAsStringAsync()); goto PostJsonStream; } using var stream = chatResp.Content.ReadAsStream(); diff --git a/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeek_GPT.cs b/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeek_GPT.cs index 29fbb83..cdf98f1 100644 --- a/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeek_GPT.cs +++ b/VideoAnalysisCore/AICore/GPT/DeepSeek/DeepSeek_GPT.cs @@ -482,7 +482,7 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek var fileNameInfoRes = await ChatAsync (task, fileNamePostMessages, null); #if DEBUG - fileNameInfoRes = new FileNameInfo() { 授课章节 = "一元二次不等式" }; + //fileNameInfoRes = new FileNameInfo() { 授课章节 = "一元二次不等式" }; #endif var captions = ExpandFunction.GetSpeakerCaptions(captionsArr, speakerArr); var maxVideoTime = captions?.TimeBase?.LastOrDefault()?.End ?? 0; @@ -547,8 +547,8 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek } } + if (questionRes.Count == 0) continue; questionRes = questionRes.OrderBy(s => s.StartTime).ToList(); - var thems = JsonSerializer.Serialize(questionRes.Adapt());// string.Join(',', questionRes.Select(s => s.StartTime + "->" + s.Theme)); var checkResFormat1 = """[{"StartTime":开始秒(number),"KnowPoint":知识点名称(string),"KnowPointId":知识点Id(string)}]"""; var knowMessages = @@ -647,7 +647,6 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek public async Task ChatAsync(string task, string postMessages, string postMessages1, string model = "deepseek-reasoner") { - var maxTokens = 6000; Message[] messageArr = [ new Message(postMessages,"user"), string.IsNullOrEmpty(postMessages1)?null:new Message(postMessages1,"user"), @@ -658,7 +657,6 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek taskId = task, model = model, stream = model == "deepseek-reasoner", - max_tokens = maxTokens, temperature = 0.2f, messages = messageArr }; diff --git a/VideoAnalysisCore/Common/DownloadFile.cs b/VideoAnalysisCore/Common/DownloadFile.cs index 97c4be5..8cdcb9f 100644 --- a/VideoAnalysisCore/Common/DownloadFile.cs +++ b/VideoAnalysisCore/Common/DownloadFile.cs @@ -180,16 +180,22 @@ namespace VideoAnalysisCore.Common { try { - var videoInfo = await vodClient.GetPlayInfoAsync(new AlibabaCloud.SDK.Vod20170321.Models.GetPlayInfoRequest() + var url = string.Empty; + if (taskInfo.PPTVideoCode.Contains("http")) + url = taskInfo.PPTVideoCode; + else { - VideoId = taskInfo.PPTVideoCode, - Formats = "mp4", - OutputType = "cdn", - AuthTimeout = 3600 * 24 * 12, - }); - if (videoInfo is null || videoInfo.StatusCode != 200 && !videoInfo.Body.PlayInfoList.PlayInfo.Any()) - throw new Exception($"{DateTime.Now} 视频订阅=>获取阿里云视频信息失败 VideoCode {taskInfo.TagId} StatusCode {videoInfo?.StatusCode}"); - var url = videoInfo.Body.PlayInfoList.PlayInfo.First().PlayURL; + var videoInfo = await vodClient.GetPlayInfoAsync(new AlibabaCloud.SDK.Vod20170321.Models.GetPlayInfoRequest() + { + VideoId = taskInfo.PPTVideoCode, + Formats = "mp4", + OutputType = "cdn", + AuthTimeout = 3600 * 24 * 12, + }); + if (videoInfo is null || videoInfo.StatusCode != 200 && !videoInfo.Body.PlayInfoList.PlayInfo.Any()) + throw new Exception($"{DateTime.Now} 视频订阅=>获取阿里云视频信息失败 VideoCode {taskInfo.TagId} StatusCode {videoInfo?.StatusCode}"); + url = videoInfo.Body.PlayInfoList.PlayInfo.First().PlayURL; + } await Download(url, localPath, "ppt.mp4", (s, e) => RedisExpand.SetTaskProgress(task, "PPT->" + Math.Round(e.ProgressPercentage, 1) )); diff --git a/VideoAnalysisCore/Controllers/LJZK_Controller.cs b/VideoAnalysisCore/Controllers/LJZK_Controller.cs index 563b8e5..6518f00 100644 --- a/VideoAnalysisCore/Controllers/LJZK_Controller.cs +++ b/VideoAnalysisCore/Controllers/LJZK_Controller.cs @@ -75,6 +75,7 @@ namespace VideoAnalysisCore.Controllers /// /// [HttpPost(Name = "NodePackage")] + [NonAction, Obsolete] public async Task NodePackage(NodePackageReq req) { Console.WriteLine($"{DateTime.Now} ļ req=" + JsonSerializer.Serialize(req)); @@ -112,7 +113,7 @@ namespace VideoAnalysisCore.Controllers TagId = s.VideoCode, MediaUrl = string.Empty, MediaName = s.VideoName, - PPTVideoCode = req.AnalyzeItems + PPTVideoCode = req.AnalyzeItems //ȡppt videoCode .FirstOrDefault(x => x.AttachmentsInfoType == AttachmentsInfoType.PPT && s.StructurePageContentId == x.StructurePageContentId) ?.VideoCode, });