从视频的关键帧提取 [英] Key Frame Extraction From Video
问题描述
我需要从视频/ Stream中提取关键帧。有任何标准实现。
我使用开放式简历。
(目前我每秒提取帧,这是慢的,我需要提高性能。)
所以如果任何一个有优化实现,请在这里回复。
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".
这篇关于从视频的关键帧提取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!