简体   繁体   English

使用ffmpeg快速输出视频帧选择

[英]Quicky output selection of video frames using ffmpeg

I would like to extract, say, 10 video frames from a given video file using ffmpeg, ideally uniformly distributed throughout the video. 我想使用ffmpeg从给定的视频文件中提取10个视频帧,最好是均匀地分布在整个视频中。 I know this can be done in a few ways, for example 我知道这可以通过几种方式完成

ffmpeg -i input.mp4 -vf fps=1/10 out%03d.jpg

will output one image every 10 seconds. 每10秒将输出一张图像。 However, this is too slow for my liking and scales proportionally with the length of the video. 但是,这对于我来说太慢了,并且会根据视频的长度成比例地缩放。 I have read a bit about ffmpeg's seeking capability, for example 例如,我已经阅读了一些有关ffmpeg的搜索能力的信息

ffmpeg -ss 00:00:05 -i input.mp4 -frames:v 1 out001.jpg

will very quickly seek to the 5th second of the video and extract one frame. 会很快找到视频的第5秒并提取一帧。 However I haven't come across a way to seek to multiple locations in the video without calling the above command repeatedly at various times. 但是,如果没有在不同时间反复调用上述命令,我还没有找到在视频中寻找多个位置的方法。

Is there a quicker way of accomplishing this? 有没有一种更快的方法可以做到这一点?

Using a long command, this can be done 使用长命令,可以做到这一点

eg 例如

ffmpeg -ss 00:00:05 -i input.mp4
       -ss 00:01:05 -i input.mp4
       -ss 00:03:05 -i input.mp4
       -ss 00:40:05 -i input.mp4 
       -map 0:v -frames:v 1 out001.jpg
       -map 1:v -frames:v 1 out002.jpg
       -map 2:v -frames:v 1 out003.jpg
       -map 3:v -frames:v 1 out004.jpg

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM