Adjust heuristic for seeking ahead

pull/4447/head
Isaac Connor 2025-02-10 17:26:09 -05:00
parent 0372a0dd33
commit a977cd5d4d
1 changed files with 4 additions and 6 deletions

View File

@ -279,15 +279,13 @@ AVFrame *FFmpeg_Input::get_frame(int stream_id, double at) {
// Normally it is likely just the next packet. Need a heuristic for seeking, something like duration * keyframe interval
#if LIBAVCODEC_VERSION_CHECK(60, 3, 0, 3, 0)
if (frame->pts + 10*frame->duration < seek_target)
if (frame->pts + 10*input_format_context->streams[stream_id]->time_base.den * frame->duration < seek_target)
#else
if (frame->pts + 10*frame->pkt_duration < seek_target)
if (frame->pts + 10*input_format_context->streams[stream_id]->time_base.den * frame->pkt_duration < seek_target)
#endif
{
Debug(1, "Jumping ahead");
if (( ret = av_seek_frame(input_format_context, stream_id, seek_target,
AVSEEK_FLAG_FRAME
) ) < 0) {
Debug(1, "Jumping ahead to %d", seek_target);
if (( ret = av_seek_frame(input_format_context, stream_id, seek_target, AVSEEK_FLAG_FRAME) ) < 0) {
Error("Unable to seek in stream %d", ret);
return nullptr;
}