From ed2ef85bfd88e4c4ec22bce8ee29774d94b80169 Mon Sep 17 00:00:00 2001 From: N00MKRAD Date: Sat, 13 Feb 2021 15:52:01 +0100 Subject: [PATCH] Allow stream encoding to fail without cancelling the whole process An invalid subtitle or audio file now won't stop the other streams (video etc) from being encoded. --- Code/Media/FfmpegAudioAndMetadata.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Code/Media/FfmpegAudioAndMetadata.cs b/Code/Media/FfmpegAudioAndMetadata.cs index 72ef8c3..ac5c01d 100644 --- a/Code/Media/FfmpegAudioAndMetadata.cs +++ b/Code/Media/FfmpegAudioAndMetadata.cs @@ -34,7 +34,7 @@ namespace Flowframes.Media args = $" -loglevel panic -i {inputFile.Wrap()} -vn {Utils.GetAudioFallbackArgs(Path.GetExtension(inputFile))} {outFile.Wrap()}"; await RunFfmpeg(args, LogMode.Hidden); - if ((File.Exists(outFile) && IOUtils.GetFilesize(outFile) < 512) || lastOutputFfmpeg.Contains("Invalid data")) + if (File.Exists(outFile) && IOUtils.GetFilesize(outFile) < 512) { Logger.Log("Failed to extract audio, even with re-encoding. Output will not have audio."); IOUtils.TryDeleteIfExists(outFile); @@ -144,7 +144,7 @@ namespace Flowframes.Media await RunFfmpeg(args, tempFolder, LogMode.Hidden); - if ((File.Exists(outPath) && IOUtils.GetFilesize(outPath) < 1024) || lastOutputFfmpeg.Contains("Invalid data") || lastOutputFfmpeg.Contains("Error initializing output stream")) + if (File.Exists(outPath) && IOUtils.GetFilesize(outPath) < 1024) { Logger.Log("Failed to merge audio losslessly! Trying to re-encode.", false, false, "ffmpeg"); @@ -153,7 +153,7 @@ namespace Flowframes.Media await RunFfmpeg(args, tempFolder, LogMode.Hidden); - if ((File.Exists(outPath) && IOUtils.GetFilesize(outPath) < 1024) || lastOutputFfmpeg.Contains("Invalid data") || lastOutputFfmpeg.Contains("Error initializing output stream")) + if (File.Exists(outPath) && IOUtils.GetFilesize(outPath) < 1024) { Logger.Log("Failed to merge audio, even with re-encoding. Output will not have audio.", false, false, "ffmpeg"); IOUtils.TryMove(tempPath, inputFile); // Move temp file back