diff --git a/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs b/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs index 01284dd..80d6226 100644 --- a/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs +++ b/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs @@ -333,32 +333,35 @@ namespace N_m3u8DL_RE.DownloadManager output = Path.ChangeExtension(output, Path.GetExtension(path)); } + bool mergeSuccess = false; //合并 if (!DownloaderConfig.SkipMerge) { //对于fMP4,自动开启二进制合并 - if (!DownloaderConfig.BinaryMerge && mp4InitFile != "") + if (!DownloaderConfig.BinaryMerge && streamSpec.MediaType != MediaType.SUBTITLES && mp4InitFile != "") { DownloaderConfig.BinaryMerge = true; Logger.WarnMarkUp($"[white on darkorange3_1]{ResString.autoBinaryMerge}[/]"); } - if (DownloaderConfig.BinaryMerge) + //字幕也使用二进制合并 + if (DownloaderConfig.BinaryMerge || streamSpec.MediaType == MediaType.SUBTITLES) { Logger.InfoMarkUp(ResString.binaryMerge); var files = FileDic.Values.Select(v => v!.ActualFilePath).OrderBy(s => s).ToArray(); MergeUtil.CombineMultipleFilesIntoSingleFile(files, output); + mergeSuccess = true; } else { var files = FileDic.Values.Select(v => v!.ActualFilePath).OrderBy(s => s).ToArray(); Logger.InfoMarkUp(ResString.ffmpegMerge); - MergeUtil.MergeByFFmpeg(DownloaderConfig.FFmpegBinaryPath!, files, Path.ChangeExtension(output, null), "mp4"); + mergeSuccess = MergeUtil.MergeByFFmpeg(DownloaderConfig.FFmpegBinaryPath!, files, Path.ChangeExtension(output, null), "mp4"); } } //删除临时文件夹 - if (!DownloaderConfig.SkipMerge && DownloaderConfig.DelAfterDone) + if (!DownloaderConfig.SkipMerge && DownloaderConfig.DelAfterDone && mergeSuccess) { var files = FileDic.Values.Select(v => v!.ActualFilePath); foreach (var file in files) @@ -372,7 +375,7 @@ namespace N_m3u8DL_RE.DownloadManager } //调用mp4decrypt解密 - if (File.Exists(output) && !DownloaderConfig.MP4RealTimeDecryption && DownloaderConfig.Keys != null && DownloaderConfig.Keys.Length > 0) + if (mergeSuccess && File.Exists(output) && !DownloaderConfig.MP4RealTimeDecryption && DownloaderConfig.Keys != null && DownloaderConfig.Keys.Length > 0) { if (totalCount >= 1 && streamSpec.Playlist!.MediaParts.First().MediaSegments.First().EncryptInfo.Method != Common.Enum.EncryptMethod.NONE) { diff --git a/src/N_m3u8DL-RE/Util/MergeUtil.cs b/src/N_m3u8DL-RE/Util/MergeUtil.cs index 4a6e7a2..779793d 100644 --- a/src/N_m3u8DL-RE/Util/MergeUtil.cs +++ b/src/N_m3u8DL-RE/Util/MergeUtil.cs @@ -44,7 +44,7 @@ namespace N_m3u8DL_RE.Util } } - public static void MergeByFFmpeg(string binary, string[] files, string outputPath, string muxFormat, + public static bool MergeByFFmpeg(string binary, string[] files, string outputPath, string muxFormat, bool fastStart = false, bool writeDate = true, string poster = "", string audioName = "", string title = "", string copyright = "", string comment = "", string encodingTool = "", string recTime = "") @@ -111,6 +111,11 @@ namespace N_m3u8DL_RE.Util RedirectStandardError = true, UseShellExecute = false })!.WaitForExit(); + + if (File.Exists(outputPath) && new FileInfo(outputPath).Length > 0) + return true; + + return false; } } }