ffmpeg的函数av_seek_frame [英] ffmpeg av_seek_frame
本文介绍了ffmpeg的函数av_seek_frame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图用不过我在最麻烦确定如何生成一个时间戳寻求FFmpeg的函数av_seek_frame方法在电影中寻找。假设我想寻求帧向前或向后多少多少,我知道帧电影目前,我怎么会去这样做?
I am attempting to seek in a movie using ffmpeg's av_seek_frame method however I'm having the most trouble determining how to generate a time-stamp to seek to. Assuming I want to seek x amount of frames either forward or backward and I know what frame the movie is currently on, how would I go about doing this?
推荐答案
下面是我是如何做到的:
Here is how i did it:
// Duration of one frame in AV_TIME_BASE units
int64_t timeBase;
void open(const char* fpath){
...
timeBase = (int64_t(pCodecCtx->time_base.num) * AV_TIME_BASE) / int64_t(pCodecCtx->time_base.den);
...
}
bool seek(int frameIndex){
if(!pFormatCtx)
return false;
int64_t seekTarget = int64_t(frameIndex) * timeBase;
if(av_seek_frame(pFormatCtx, -1, seekTarget, AVSEEK_FLAG_ANY) < 0)
mexErrMsgTxt("av_seek_frame failed.");
}
该AVSEEK_FLAG_ANY使寻求每一帧,而不只是关键帧。
The AVSEEK_FLAG_ANY enables seeking to every frame and not just keyframes.
这篇关于ffmpeg的函数av_seek_frame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文