From 26fcfcc206ad4a2ff841c1e0ad43ab0e76107d45 Mon Sep 17 00:00:00 2001 From: Stanislau Krashynski Date: Mon, 20 Sep 2021 16:06:43 +0300 Subject: [PATCH] fix stream index for passing to ffmpeg while making a snapshot --- FFMpegCore/FFMpeg/FFMpeg.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/FFMpegCore/FFMpeg/FFMpeg.cs b/FFMpegCore/FFMpeg/FFMpeg.cs index a345160..ed3d390 100644 --- a/FFMpegCore/FFMpeg/FFMpeg.cs +++ b/FFMpegCore/FFMpeg/FFMpeg.cs @@ -116,7 +116,12 @@ private static (FFMpegArguments, Action outputOptions) Bu { captureTime ??= TimeSpan.FromSeconds(source.Duration.TotalSeconds / 3); size = PrepareSnapshotSize(source, size); - streamIndex = streamIndex == null ? 0 : source.VideoStreams.FirstOrDefault(videoStream => videoStream.Index == streamIndex).Index; + if (streamIndex == null) + { + streamIndex = source.PrimaryVideoStream?.Index + ?? source.VideoStreams.First()?.Index + ?? 0; + } return (FFMpegArguments .FromFileInput(input, false, options => options