[Libav-user] Accuracy of seek_frame (h264)

Kristijonas Malisauskas km at sportcaster.dk
Thu Oct 13 18:13:56 EEST 2016


Hello,
I am currently having problems seeking to keyframe with good accuracy
(videos are h264). To calculate target time I currently use:
int seek_target = target_frame *
((float)pFormatCtx->streams[videoStreamIndex]->time_base.den /
pFormatCtx->streams[videoStreamIndex]->time_base.num) / (float)
pFormatCtx->streams[videoStreamIndex]->codec->time_base.den /
pFormatCtx->streams[videoStreamIndex]->codec->time_base.num) *
videoCodecCtx->ticks_per_frame;

I would note that target_frame is being set to only be a keyframe. The
problem I have is that using this I frequently end up seeking to a keyframe
that is behind or ahead by 1. When working on a specific video I am able to
add an offset to the target_frame and get precise results for that specific
case but I need a solution that works on all the videos. What adjustments
would I need to make to get better accuracy.

Cheers,
/Kris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20161013/90040e82/attachment.html>


More information about the Libav-user mailing list