Skip to content

Commit 3dc4306

Browse files
committed
vidcap file: fixed seek overflow
fixed potential overflow if tb.den is huge (500000 in Elephants Dream)
1 parent 56a0708 commit 3dc4306

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/video_capture/file.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,9 @@ static void seek_start(struct vidcap_state_lavf_decoder *s) {
522522
}
523523
AVStream *st = s->fmt_ctx->streams[s->video_stream_idx];
524524
AVRational tb = st->time_base;
525+
int64_t ts = st->start_time + (int64_t) s->seek_sec * tb.den / tb.num;
525526
CHECK_FF(avformat_seek_file(s->fmt_ctx, s->video_stream_idx, INT64_MIN,
526-
st->start_time + s->last_vid_pts +
527-
s->seek_sec * tb.den / tb.num,
528-
INT64_MAX, AVSEEK_FLAG_FRAME),
527+
ts, INT64_MAX, AVSEEK_FLAG_FRAME),
529528
{});
530529
}
531530

0 commit comments

Comments
 (0)