From 9cd8cec5cdee3f921c36936266c0b3f5aebbba3f Mon Sep 17 00:00:00 2001 From: nilaoda Date: Fri, 2 Dec 2022 14:30:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=90=88=E5=B9=B6=E6=88=90?= =?UTF-8?q?=E5=8A=9F=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/N_m3u8DL-RE/Util/MergeUtil.cs | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/N_m3u8DL-RE/Util/MergeUtil.cs b/src/N_m3u8DL-RE/Util/MergeUtil.cs index c1734ff..b148011 100644 --- a/src/N_m3u8DL-RE/Util/MergeUtil.cs +++ b/src/N_m3u8DL-RE/Util/MergeUtil.cs @@ -49,7 +49,7 @@ namespace N_m3u8DL_RE.Util } } - private static void InvokeFFmpeg(string binary, string command, string workingDirectory) + private static int InvokeFFmpeg(string binary, string command, string workingDirectory) { Logger.DebugMarkUp($"{binary}: {command}"); @@ -73,6 +73,7 @@ namespace N_m3u8DL_RE.Util p.Start(); p.BeginErrorReadLine(); p.WaitForExit(); + return p.ExitCode; } public static string[] PartialCombineMultipleFiles(string[] files) @@ -167,12 +168,9 @@ namespace N_m3u8DL_RE.Util break; } - InvokeFFmpeg(binary, command.ToString(), Path.GetDirectoryName(files[0])!); + var code = InvokeFFmpeg(binary, command.ToString(), Path.GetDirectoryName(files[0])!); - if (File.Exists($"{outputPath}.{muxFormat}") && new FileInfo($"{outputPath}.{muxFormat}").Length > 0) - return true; - - return false; + return code == 0; } public static bool MuxInputsByFFmpeg(string binary, OutputFile[] files, string outputPath, bool mp4, bool dateinfo) @@ -227,12 +225,9 @@ namespace N_m3u8DL_RE.Util command.Append($" -ignore_unknown -copy_unknown "); command.Append($" \"{outputPath}.{ext}\""); - InvokeFFmpeg(binary, command.ToString(), Environment.CurrentDirectory); + var code = InvokeFFmpeg(binary, command.ToString(), Environment.CurrentDirectory); - if (File.Exists($"{outputPath}.{ext}") && new FileInfo($"{outputPath}.{ext}").Length > 1024) - return true; - - return false; + return code == 0; } public static bool MuxInputsByMkvmerge(string binary, OutputFile[] files, string outputPath) @@ -252,12 +247,9 @@ namespace N_m3u8DL_RE.Util command.Append($" \"{files[i].FilePath}\" "); } - InvokeFFmpeg(binary, command.ToString(), Environment.CurrentDirectory); + var code = InvokeFFmpeg(binary, command.ToString(), Environment.CurrentDirectory); - if (File.Exists($"{outputPath}.mkv") && new FileInfo($"{outputPath}.mkv").Length > 1024) - return true; - - return false; + return code == 0; } ///