FFmpeg提取当前帧时间戳 [英] FFmpeg extracting current frame time stamp

查看:1951
本文介绍了FFmpeg提取当前帧时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在视频的特定间隔(例如从40秒到50秒)提取帧。
使用c ++。
首先我需要开始读取的位置

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 );

然后我使用av_read_frame获取所有的连续帧。
我的问题是,我不知道什么时候停止。如何检查我是否到达了结束间隔(例如50秒)?

Then I using av_read_frame to get all sequential frames. The problem that I have is that I dont know when to stop. How can I check that I reached my end interval (eg 50 sec) ?

谢谢。

推荐答案

尝试查找每秒帧数,然后使用该数字计算每个帧的确切时间为

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

这篇关于FFmpeg提取当前帧时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆