从视频中提取关键帧 [英] Key Frame Extraction From Video

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

问题描述

我需要从视频/流中提取关键帧.所以有没有标准的实现.我正在使用开放式简历.(目前我每秒都在提取帧,这比较慢,我需要提高性能.)因此,如果有人优化了实现,请在此处回复.

I need Need To extract Key Frames from Video/Stream.So is there any standard implementation. I am using open CV. (Currently i am extracting frames each second which is slower i need to improve performance.) So if any one has optimized implementation please reply in here.

推荐答案

使用ffmpeg可以提取所有关键帧,使用如下代码:

Using ffmpeg you can extract all key frames using the following code:

ffmpeg -vf select="eq(pict_type,PICT_TYPE_I)" -i yourvideo.mp4 -vsync 2 -s 160x90 -f image2 thumbnails-%02d.jpeg

ffmpeg 命令行中的 -vf 后面是 Filtergraph 描述.选择过滤器选择要传入输出的帧.过滤器的常数是pict_type",值是PICT_TYPE_I".所以 ffmpeg 只是将关键帧传递给输出.

What follows -vf in a ffmpeg command line is a Filtergraph description. The select filter selects frames to pass in output. The constant of the filter is "pict_type" and the value " PICT_TYPE_I". So ffmpeg is only passing key frames to the output.

-vsync 2 防止 ffmpeg 为每个关键帧生成多个副本.

-vsync 2 prevents ffmpeg to generate more than one copy for each key frame.

-f image2 将视频帧写入图像文件.输出文件名由模式指定,可用于生成按顺序编号的文件系列.该模式可能包含字符串%d"或%0Nd".

-f image2 writes video frames to image files. The output filenames are specified by a pattern, which can be used to produce sequentially numbered series of files. The pattern may contain the string "%d" or "%0Nd".

参考:http://www.videoproductionslondon.com/blog/scene-change-detection-during-encoding-key-frame-extraction-code

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

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