问题描述
我正在尝试从一堆视频中均匀提取固定数量的帧(每个视频有50帧,总共有10,000个视频)。
由于持续时间不同,我计算出每个视频的理想输出fps,并将其作为ffmpeg提取的参数,但无法获取所需的帧数。 / p>
有谁知道如何使用ffmpeg或其他工具提取固定数量的帧?谢谢!
您可以使用缩略图过滤器。它从每一组 n
框架中选择一个代表框架(默认为100)
所以,如果你的源视频是10分钟长,在25 fps,那么它总共有15000帧。所以,要选择50帧,你可以使用
ffmpeg -i input.mp4 -vf thumbnail = 300,setpts = N / TB -r 1 -vframes 50输入框%03d.png
从每组中选择一个代表帧300帧,所以50帧从15000.尽管名称,缩略图只是选择帧,它不会缩小他们的缩略图使用。 setpts
和 r
联合设置,以避免重复或丢弃帧。 vframes
设置为不超过50个图像被输出。
如果您需要严格选择 nth
框架,请使用
ffmpeg -i input.mp4 -vf select ='not(mod(n\,300))',setpts = N / TB -r 1 -vframes 50 inputframes% 03d.png
I am trying to extract a fixed number of frames uniformly from a bunch of videos(say 50 frames from each video, 10,000 videos in total).
Since the duration varies, I calculated the ideal output fps for each video and take it as a parameter for ffmpeg extraction, but failed to get the required number of frames.
Does anyone know how to extract a fixed number of frames with ffmpeg, or other tools? Thanks!
You could use the thumbnail filter. It picks one representative frame from every set of n
frames (default is 100)
So, if your source video is 10 minutes long and at 25 fps, then it has 15000 frames in total. So, to select 50 frames, you would use
ffmpeg -i input.mp4 -vf thumbnail=300,setpts=N/TB -r 1 -vframes 50 inputframes%03d.png
This selects one representative frame from each set of 300 frames, so 50 frames from 15000. Despite the name, thumbnail simply selects frames, it does not downsize them for thumbnail use. The setpts
and r
are set in conjunction to avoid duplicate or dropped frames. The vframes
is set so no more than 50 images are output.
If you need to select strictly every nth
frame, use
ffmpeg -i input.mp4 -vf select='not(mod(n\,300))',setpts=N/TB -r 1 -vframes 50 inputframes%03d.png
这篇关于如何使用ffmpeg提取固定数量的帧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!