Skip to content

The Free Software Media System - Server Backend & API

Backport pull request #17883 from jellyfin/release-12.z

crobibero51abf6f503da
diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
index f64fd73763..fa43d756a4 100644
--- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
+++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
@@ -922,6 +922,15 @@ namespace MediaBrowser.MediaEncoding.Encoder
inputArg = "-hwaccel_flags +low_priority " + inputArg;
}
+ // Force the video stream, otherwise ffmpeg may pick a cover image.
+ var streamIndex = EncodingHelper.FindIndex(mediaSource.MediaStreams, imageStream);
+ if (streamIndex < 0)
+ {
+ throw new InvalidOperationException($"Unable to locate requested stream {imageStream.Title}");
+ }
+
+ inputArg += " -map 0:" + streamIndex;
+
var filterParam = encodingHelper.GetVideoProcessingFilterParam(jobState, options, vidEncoder).Trim();
if (string.IsNullOrWhiteSpace(filterParam))
{