开发者

FFmpeg extracting current frame time stamp

I need to extract frames in certain interval of the video, (eg from 40 sec to 50 sec). Working in c++. First I am getting position where I need to start reading

static double t = 10 ;//time in seconds
int64_t timestamp = t * AV_TIME_BASE; //destination time
av_seek_frame( pFormatContext , -1 ,  timestamp + pFormatContext->start_time ,AVSEEK_FLAG_BACKWARD );

Then I using av_read_frame to get all sequential frames. The problem that I have is that I dont know when t开发者_StackOverflow中文版o stop. How can I check that I reached my end interval (eg 50 sec) ?

Thanks.


av_read_frame() will give you a PTS (Presentation Time Stamp). It is AVPacket's member pts. Perhaps that value can help you decide when to stop reading.


Try to find frames per second and then use that number to calculate exact time of each frame as

frame_absolute_time = frame_number / FPS
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜