How to extract a fixed number of frames with ffmpeg?

六眼飞鱼酱① 提交于 2019-12-03 20:19:43

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!