[libav-api] How to Frame Step Forwards/Backwards?

xftzg xftzg2013 at 126.com
Sat Mar 23 08:37:56 CET 2013


 Hello,

I know it is using the PTS of the frame to seek to frames.
I want to perform a 'Step Forwards/Backwards' operation in my player, but the problem is that the seeking to frames are not always working as I expected.

    int64_t time_stamp = 0;
    time_stamp = current_pts - frame_span;    // frame_span is calculated by avg_frame_rate, and in stream time base
    search_flag = AVSEEK_FLAG_BACKWARD;
    int ok = av_seek_frame(format_ctx, video_stream, times_tamp, search_flag);

The result would sometimes either jump to the current key frame or several key frames earlier. What should I do to fix it?
By the way, is there any convenient way to know the index of the frame, which is now playing?

Best Regards.



More information about the libav-api mailing list