基于FFmpeg的视频播放器之十二:seek

seek是播放器的常用操作,也是衡量播放器好坏的重要标志之一。

一.效果

下面是对正在播放的4K视频执行seek操作

二.原理

1.av_seek_frame

FFmpeg提供了av_seek_frame函数来执行seek操作,函数定义如下所示:

/**
 * 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 a

猜你喜欢

转载自blog.csdn.net/caoshangpa/article/details/124831341