Merge pull request #30031 from lgoossens-ekoscan:fix-seek-nopts-start-time

videoio(ffmpeg): guard seek() against AV_NOPTS_VALUE start_time
This commit is contained in:
Alexander Smorkalov
2026-09-22 10:41:46 +03:00
committed by GitHub
+2
View File
@@ -2321,6 +2321,8 @@ void CvCapture_FFMPEG::seek(int64_t _frame_number)
AVStream* st = ic->streams[video_stream];
int64_t time_stamp = st->start_time;
if (time_stamp == AV_NOPTS_VALUE_) // same guard as dts_to_sec(): without it the target is INT64_MIN + offset,
time_stamp = 0; // av_seek_frame() lands at position 0 and the loop below decodes every frame
double time_base = r2d(st->time_base);
int64_t ts_norm = (int64_t)(sec / time_base + 0.5);