FFMPEG读取关键帧 [英] FFMPEG reading keyframes

查看:2593
本文介绍了FFMPEG读取关键帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个c ++程序,使用ffmpeg从视频文件中读取关键帧。
到目前为止,我设法使用 av_read_frame 获得所有框架,其中你逐帧地顺序读取

I am trying to write a c++ program that would read key frames from the video file using ffmpeg. So far I managed to get all the frames using av_read_frame where you sequentially read frame by frame.

但我有一些问题使用 av_seek_frame 这(如果我是正确的)应该做的关键帧的技巧。

But I having some problems using av_seek_frame which (if I am correct) supposed to do the trick for keyframes.

int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags);

我有 FormatContext

有没有其他函数可以改用?

Is there other function that I can use instead?

感谢

编辑:在 av_read_frame 获取AVPacket,我可以使用它来获取帧数据,但是如何使用av_seek_frame获取数据包?

In av_read_frame i am getting AVPacket, which I can use to get frame data, but how I can get packet by using av_seek_frame ?

解决方案:确定AVFrame-> key_frame。如果其关键帧

SOLUTION: OK there is a simple boolean value in AVFrame->key_frame. True if its a keyframe

推荐答案

av_seek_frame 可以搜索视频文件中的特定时间戳。它需要4个参数:指向 AVFormatContext ,流索引,时间戳以及

av_seek_frame has the ability to seek to a certain timestamp in a video file. It takes 4 parameters: a pointer to the AVFormatContext, a stream index, the timestamp to seek to and flags to select the direction and seeking mode.

然后,函数会在给定时间戳之前搜索第一个关键帧。

The function will then seek to the first key frame before the given timestamp.

有关详情,请查看该功能的文档

这篇关于FFMPEG读取关键帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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