From 16a70ebd7274f853f71f614291fdf0caca385c3c Mon Sep 17 00:00:00 2001 From: Cry dsch Date: Sat, 8 Feb 2020 20:29:30 +0100 Subject: [PATCH] Fix progress event output when using the convert(ArgumentContainer) function --- FFMpegCore/FFMPEG/Argument/Atoms/InputArgument.cs | 4 ++++ FFMpegCore/FFMPEG/FFMpeg.cs | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/FFMpegCore/FFMPEG/Argument/Atoms/InputArgument.cs b/FFMpegCore/FFMPEG/Argument/Atoms/InputArgument.cs index 9c6e084..a04f980 100644 --- a/FFMpegCore/FFMPEG/Argument/Atoms/InputArgument.cs +++ b/FFMpegCore/FFMPEG/Argument/Atoms/InputArgument.cs @@ -40,5 +40,9 @@ public override string GetStringValue() { return string.Join(" ", Value.Select(v => ArgumentStringifier.Input(v))); } + public VideoInfo[] GetAsVideoInfo() + { + return Value.Select(v => new VideoInfo(v)).ToArray(); + } } } diff --git a/FFMpegCore/FFMPEG/FFMpeg.cs b/FFMpegCore/FFMPEG/FFMpeg.cs index bb83813..de44268 100644 --- a/FFMpegCore/FFMPEG/FFMpeg.cs +++ b/FFMpegCore/FFMPEG/FFMpeg.cs @@ -436,14 +436,21 @@ public VideoInfo ReplaceAudio(VideoInfo source, FileInfo audio, FileInfo output, public VideoInfo Convert(ArgumentContainer arguments) { - var args = ArgumentBuilder.BuildArguments(arguments); var output = ((OutputArgument)arguments[typeof(OutputArgument)]).GetAsFileInfo(); + var sources = ((InputArgument)arguments[typeof(InputArgument)]).GetAsVideoInfo(); + + // Sum duration of all sources + _totalTime = TimeSpan.Zero; + foreach (var source in sources) + _totalTime += source.Duration; if (!RunProcess(arguments, output)) { throw new FFMpegException(FFMpegExceptionType.Operation, "Could not replace the video audio."); } + _totalTime = TimeSpan.MinValue; + return new VideoInfo(output); }