From 949dc76f3f8aef533b4ffc6a213bb0b3f6dde5e9 Mon Sep 17 00:00:00 2001 From: Malte Rosenbjerg Date: Wed, 9 Dec 2020 10:58:21 +0100 Subject: [PATCH] Also include output data on non-zero ffmpeg exitcode Former-commit-id: 6bdf9da6836131a15032e903cf96bb598c1acf83 --- FFMpegCore/FFMpeg/Exceptions/FFMpegException.cs | 1 - FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs | 8 ++++---- FFMpegCore/FFMpegCore.csproj | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/FFMpegCore/FFMpeg/Exceptions/FFMpegException.cs b/FFMpegCore/FFMpeg/Exceptions/FFMpegException.cs index b094a02..fc154ac 100644 --- a/FFMpegCore/FFMpeg/Exceptions/FFMpegException.cs +++ b/FFMpegCore/FFMpeg/Exceptions/FFMpegException.cs @@ -13,7 +13,6 @@ public enum FFMpegExceptionType public class FFMpegException : Exception { - public FFMpegException(FFMpegExceptionType type, string? message = null, Exception? innerException = null, string ffmpegErrorOutput = "", string ffmpegOutput = "") : base(message, innerException) { diff --git a/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs b/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs index a1186d0..5961ed3 100644 --- a/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs +++ b/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs @@ -77,13 +77,13 @@ void OnCancelEvent(object sender, EventArgs args) CancelEvent -= OnCancelEvent; } - return HandleCompletion(throwOnError, errorCode, instance.ErrorData); + return HandleCompletion(throwOnError, errorCode, instance.ErrorData, instance.OutputData); } - private bool HandleCompletion(bool throwOnError, int errorCode, IReadOnlyList errorData) + private bool HandleCompletion(bool throwOnError, int errorCode, IReadOnlyList errorData, IReadOnlyList outputData) { if (throwOnError && errorCode != 0) - throw new FFMpegException(FFMpegExceptionType.Conversion, string.Join("\n", errorData)); + throw new FFMpegException(FFMpegExceptionType.Conversion, "FFMpeg exited with non-zero exitcode.", null, string.Join("\n", errorData), string.Join("\n", outputData)); _onPercentageProgress?.Invoke(100.0); if (_totalTimespan.HasValue) _onTimeProgress?.Invoke(_totalTimespan.Value); @@ -123,7 +123,7 @@ await Task.WhenAll(instance.FinishedRunning().ContinueWith(t => CancelEvent -= OnCancelEvent; } - return HandleCompletion(throwOnError, errorCode, instance.ErrorData); + return HandleCompletion(throwOnError, errorCode, instance.ErrorData, instance.OutputData); } private Instance PrepareInstance(out CancellationTokenSource cancellationTokenSource) diff --git a/FFMpegCore/FFMpegCore.csproj b/FFMpegCore/FFMpegCore.csproj index 09960a1..43247f7 100644 --- a/FFMpegCore/FFMpegCore.csproj +++ b/FFMpegCore/FFMpegCore.csproj @@ -9,9 +9,9 @@ 3.0.0.0 3.0.0.0 3.0.0.0 - - Include ffmpeg output data in exception + - Also include ffmpeg output data on non-zero exit code 8 - 3.2.3 + 3.2.4 MIT Malte Rosenbjerg, Vlad Jerca ffmpeg ffprobe convert video audio mediafile resize analyze muxing