[FFmpeg]seek操作

作者: _小老虎_ | 来源:发表于2020-02-13 22:46 被阅读0次

/**
 * Seek to the keyframe at timestamp.
 * 'timestamp' in 'stream_index'.
 *
 * @param s media file handle
 * @param stream_index If stream_index is (-1), a default
 * stream is selected, and timestamp is automatically converted
 * from AV_TIME_BASE units to the stream specific time_base.
 * @param timestamp Timestamp in AVStream.time_base units
 *        or, if no stream is specified, in AV_TIME_BASE units.
 * @param flags flags which select direction and seeking mode
 * @return >= 0 on success
 */
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
                  int flags);

用法:

/*
 * 这里的pts就是视频的播放pts,主要自己转换过来就OK
 */
av_seek_frame(fmt_ctx, audio_stream_index,pts,AVSEEK_FLAG_BACKWARD);
这个函数只会调到 I 帧,所以并不是百分百准确,但是用户无感知

同时可以参考: https://blog.csdn.net/u010302327/article/details/78457091

相关文章

网友评论

    本文标题:[FFmpeg]seek操作

    本文链接:https://www.haomeiwen.com/subject/qlymbqtx.html