diff --git a/OKEGui/OKEGui/JobProcessor/Muxer/AutoMuxer.cs b/OKEGui/OKEGui/JobProcessor/Muxer/AutoMuxer.cs index 4642238f..4bfd55dc 100644 --- a/OKEGui/OKEGui/JobProcessor/Muxer/AutoMuxer.cs +++ b/OKEGui/OKEGui/JobProcessor/Muxer/AutoMuxer.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Linq; using System.IO; using System.Text.RegularExpressions; using System.Threading; @@ -148,7 +149,7 @@ private Episode GenerateEpisode( private string GenerateMkvMergeParameter(Episode episode) { - string trackTemplate = "--language 0:{0} --track-name \"0:{1}\" \"(\" \"{2}\" \")\""; + string trackTemplate = "--default-track \"0:{0}\" --language 0:{1} --track-name \"0:{2}\" \"(\" \"{3}\" \")\""; var parameters = new List(); var trackOrder = new List(); @@ -164,14 +165,15 @@ private string GenerateMkvMergeParameter(Episode episode) { parameters.Add($"--timestamps \"0:{episode.timeCodeFile}\""); } - parameters.Add(string.Format(trackTemplate, "und", episode.VideoName, episode.VideoFile)); + parameters.Add(string.Format(trackTemplate, "1", "und", episode.VideoName, episode.VideoFile)); trackOrder.Add($"{fileID++}:0"); } for (int i = 0; i < episode.AudioFiles.Count; i++) { string audioFile = episode.AudioFiles[i]; - parameters.Add(string.Format(trackTemplate, episode.AudioLanguages[i], episode.AudioNames[i], audioFile)); + bool isDefault = episode.VideoFile != null & i == 0; + parameters.Add(string.Format(trackTemplate, isDefault ? "1":"0", episode.AudioLanguages[i], episode.AudioNames[i], audioFile)); trackOrder.Add($"{fileID++}:0"); } @@ -180,7 +182,7 @@ private string GenerateMkvMergeParameter(Episode episode) for (int i = 0; i < episode.SubtitleFiles.Count; i++) { string subtitleFile = episode.SubtitleFiles[i]; - parameters.Add(string.Format(trackTemplate, episode.SubtitleLanguages[i], episode.SubtitleNames[i], subtitleFile)); + parameters.Add(string.Format(trackTemplate, "0", episode.SubtitleLanguages[i], episode.SubtitleNames[i], subtitleFile)); trackOrder.Add($"{fileID++}:0"); } } @@ -366,7 +368,7 @@ public OKEFile StartMuxing(string path, MediaFile mediaFile) List subtitleLanguages = new List(); List subtitleNames = new List(); - foreach (var track in mediaFile.Tracks) + foreach (var track in mediaFile.Tracks.OrderBy(trk => trk.Info.Order)) { if (track.Info.MuxOption != MuxOption.Default && track.Info.MuxOption != MuxOption.Mka) { diff --git a/OKEGui/OKEGui/Model/Info/Info.cs b/OKEGui/OKEGui/Model/Info/Info.cs index a16a7063..f518dbea 100644 --- a/OKEGui/OKEGui/Model/Info/Info.cs +++ b/OKEGui/OKEGui/Model/Info/Info.cs @@ -27,6 +27,7 @@ public class Info : ICloneable public string Language = Constants.language; public string Name = ""; public bool Optional = false; + public int Order = Int32.MaxValue; private bool _dupOrEmpty; public bool DupOrEmpty { diff --git a/OKEGui/OKEGui/Task/ChapterService.cs b/OKEGui/OKEGui/Task/ChapterService.cs index ea99e950..75ecbf3f 100644 --- a/OKEGui/OKEGui/Task/ChapterService.cs +++ b/OKEGui/OKEGui/Task/ChapterService.cs @@ -94,7 +94,8 @@ public static bool FindChapterFile(TaskDetail task) string inputPath = Path.GetFullPath(inputFile.FullName); string basename = Path.GetFileNameWithoutExtension(inputFile.FullName); string[] files = Directory.GetFiles(Path.GetDirectoryName(inputPath), basename + ".*txt"); - Logger.Warn($"ChapterFile: found {String.Join(",", files)}."); + if (files.Length > 0) + Logger.Warn($"ChapterFile: found {String.Join(",", files)}."); if (files.Length > 1) throw new Exception("More than one chapter files found for " + task.InputFile + ": " + String.Join(",", files)); if (files.Length == 1)