From f87cc83a5e59343383d7b4ccd765df0b913edbe6 Mon Sep 17 00:00:00 2001 From: sinsanction <1602723930@qq.com> Date: Fri, 24 May 2024 20:03:16 +0800 Subject: [PATCH] EpisodeProfile: add `ReExtractSource` option to re-extract non-video tracks from source for ReEncode tasks --- OKEGui/OKEGui/Task/AddEpProfileService.cs | 10 ++++- OKEGui/OKEGui/Task/EpisodeProfile.cs | 1 + OKEGui/OKEGui/Worker/ExecuteTaskService.cs | 52 +++++++++++++--------- 3 files changed, 40 insertions(+), 23 deletions(-) diff --git a/OKEGui/OKEGui/Task/AddEpProfileService.cs b/OKEGui/OKEGui/Task/AddEpProfileService.cs index ef532091..adb472d6 100644 --- a/OKEGui/OKEGui/Task/AddEpProfileService.cs +++ b/OKEGui/OKEGui/Task/AddEpProfileService.cs @@ -28,7 +28,7 @@ public static EpisodeConfig LoadJsonAsProfile(string filePath) } catch (Exception e) { - MessageBox.Show(e.ToString(), filePath + "json文件写错了诶", MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(e.ToString(), filePath + " json文件写错了诶", MessageBoxButton.OK, MessageBoxImage.Error); return null; } @@ -56,6 +56,14 @@ public static EpisodeConfig ProcessJsonProfile(EpisodeConfig json, string filePa } json.ReEncodeOldFile = oldFile.FullName; + // 检查是否重新抽流其他轨道 + string oldFileExtension = oldFile.Extension.ToLower(); + if (!json.ReExtractSource && oldFileExtension != ".mkv") + { + MessageBox.Show("需要从旧版压制成品获取非视频轨道,但旧版压制成品不为mkv格式", "旧版压制成品格式不支持", MessageBoxButton.OK, MessageBoxImage.Error); + return null; + } + // 检查切片序列 if (json.ReEncodeSliceArray == null || json.ReEncodeSliceArray.Count == 0) { diff --git a/OKEGui/OKEGui/Task/EpisodeProfile.cs b/OKEGui/OKEGui/Task/EpisodeProfile.cs index b4918a13..07799485 100644 --- a/OKEGui/OKEGui/Task/EpisodeProfile.cs +++ b/OKEGui/OKEGui/Task/EpisodeProfile.cs @@ -10,6 +10,7 @@ public class EpisodeConfig : ICloneable // 用于 Re-Encode 功能 public bool EnableReEncode = false; + public bool ReExtractSource = false; public string ReEncodeOldFile; public SliceInfoArray ReEncodeSliceArray; diff --git a/OKEGui/OKEGui/Worker/ExecuteTaskService.cs b/OKEGui/OKEGui/Worker/ExecuteTaskService.cs index 94fd4e2b..b3fdb044 100644 --- a/OKEGui/OKEGui/Worker/ExecuteTaskService.cs +++ b/OKEGui/OKEGui/Worker/ExecuteTaskService.cs @@ -86,25 +86,13 @@ private void WorkerDoWork(object sender, DoWorkEventArgs e) // 准备时间码/章节文件/qpfile VideoInfo finalVideoInfo = DoPreparation(task, profile, vsInfo); - // 处理ReEncode任务 + // 根据旧成品的I帧序列,生成最终的切片序列 if (profile.IsReEncode) { - // 根据旧成品的I帧序列,生成最终的切片序列 CheckReEncodeSlice(task, profile, vsInfo.iFrameInfo); - - // 执行各个切片的压制和封装处理工作 - GenerateReEncodeJob(task, profile, args.numaNode, finalVideoInfo); - DoAllJobs(task, profile); - - // 执行最终封装工作 - GenerateMuxJob(task, profile, profile.Config.ReEncodeOldFile); - DoAllJobs(task, profile); - - // RPC检查 - DoRPCheck(task, profile); } - // 处理常规压制任务 - else + + if (!profile.IsReEncode || profile.IsReEncode && profile.Config.ReExtractSource) { // 抽取音轨和字幕轨 MediaFile srcTracks = ExtractSource(task, profile); @@ -124,23 +112,43 @@ private void WorkerDoWork(object sender, DoWorkEventArgs e) GenerateMuxJob(task, profile, task.MkaOutFile, "MKA"); DoAllJobs(task, profile); } + } - // 执行视频处理工作 + // 执行视频处理工作 + if (profile.IsReEncode) + { + // 执行各个切片的压制和封装处理工作 + GenerateReEncodeJob(task, profile, args.numaNode, finalVideoInfo); + DoAllJobs(task, profile); + } + else + { + // 执行常规视频处理工作 GenerateVideoJob(task, profile, args.numaNode, finalVideoInfo, false); DoAllJobs(task, profile); + } - // 执行最终封装工作 + // 执行最终封装工作 + if (profile.IsReEncode && !profile.Config.ReExtractSource) + { + GenerateMuxJob(task, profile, profile.Config.ReEncodeOldFile); + DoAllJobs(task, profile); + } + else + { GenerateMuxJob(task, profile, task.MediaOutFile, profile.ContainerFormat); DoAllJobs(task, profile); - - // RPC检查 - DoRPCheck(task, profile); } - Logger.Info("任务完成"); + // RPC检查 + DoRPCheck(task, profile); + task.CurrentStatus = "完成"; - task.Progress = TaskStatus.TaskProgress.FINISHED; task.ProgressValue = 100; + task.Progress = TaskStatus.TaskProgress.FINISHED; + + Logger.Info("任务完成"); + Logger.Info("-------------------------------------------------------------------"); } catch (OKETaskException ex) {