Skip to content

Commit

Permalink
EpisodeProfile: add ReExtractSource option to re-extract non-video …
Browse files Browse the repository at this point in the history
…tracks from source for ReEncode tasks
  • Loading branch information
sinsanction committed May 24, 2024
1 parent 7065643 commit f87cc83
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 23 deletions.
10 changes: 9 additions & 1 deletion OKEGui/OKEGui/Task/AddEpProfileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions OKEGui/OKEGui/Task/EpisodeProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class EpisodeConfig : ICloneable

// 用于 Re-Encode 功能
public bool EnableReEncode = false;
public bool ReExtractSource = false;
public string ReEncodeOldFile;
public SliceInfoArray ReEncodeSliceArray;

Expand Down
52 changes: 30 additions & 22 deletions OKEGui/OKEGui/Worker/ExecuteTaskService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
{
Expand Down

0 comments on commit f87cc83

Please sign in to comment.