fix(ffprobe): Pass the correct filtered video stream index

- We currently pass the global stream index of the primary video stream with v:index.
- ffprobe expects the index to be filtered by the stream type. If the video appears at index 2 but is the only video stream in the file, we should pass v:0. Passing v:2 will cause ffprobe to unnecessarily read the entire file during analysis
This commit is contained in:
realzombee 2026-01-28 01:58:54 +00:00
parent 89110c2cc8
commit 257ce49668

View file

@ -117,7 +117,10 @@ public MediaInfoModel GetMediaInfo(string filename)
// if it looks like PQ10 or similar HDR, do a frame analysis to figure out which type it is
if (PqTransferFunctions.Contains(mediaInfoModel.VideoTransferCharacteristics))
{
var frameOutput = FFProbe.GetFrameJson(filename, ffOptions: new () { ExtraArguments = $"-read_intervals \"%+#1\" -select_streams v:{primaryVideoStream?.Index ?? 0}" });
var videoStreamIndex = analysis.VideoStreams.FindIndex(stream => stream.Index == primaryVideoStream?.Index);
videoStreamIndex = videoStreamIndex == -1 ? 0 : videoStreamIndex;
_logger.Debug("Reading video stream at index {0} with relative index v:{1}", primaryVideoStream?.Index, videoStreamIndex);
var frameOutput = FFProbe.GetFrameJson(filename, ffOptions: new () { ExtraArguments = $"-read_intervals \"%+#1\" -select_streams v:{videoStreamIndex}" });
mediaInfoModel.RawFrameData = frameOutput;
frames = FFProbe.AnalyseFrameJson(frameOutput);