Using ffmpeg with not consecutive numbered files

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-29 20:51:54

问题


I am using ffmpeg to produce a video starting from a set of png images. However, the images I have are numbered like this:

image_D5_C0_F4.png
image_D10_C0_F4.png
image_D15_C0_F4.png
image_D20_C0_F4.png

and so on. Basically, everything remains the same, but the inner part changes. My ffmpeg command looks like this:

ffmpeg -framerate 8 -start_number 5 -i img/image_%02d_C0_F4.png -c:v libx264 -r 30 -s 1200x900 -pix_fmt yuv420p out.mp4

but obviously it does not work. I looked into the manual to find an option that allow me to specify a starting number (5 in this case) and a standard increment (again, 5), so to catch 5,10,15,20 etc.

Any idea on how to solve this? I know I can handle everything with a script to rename all the files, but I wanted to check whether ffmpeg has the needed option in the first place.

Thanks


回答1:


You can use the glob pattern type:

ffmpeg -framerate 8 -pattern_type glob -i "*.png" -c:v libx264 -r 30 \
-vf "scale=1200:-2,format=yuv420p" -movflags +faststart out.mp4

Notes:

  • The scale video filter is more versatile than -s. You only have to pick one dimensional value and it will automatically calculate the other.

  • -movflags +faststart will relocate the moov atom from the end to the beginning of the file once encoding has completed. This is useful if clients will view the video via progressive download such as in a browser.

  • I'm not sure if the glob pattern works with Windows, or at least with Zeranoe's FFmpeg Builds (I need to test that).

Also see:

  • image2 demuxer documentation
  • FFmpeg H.264 Video Encoding Guide


来源:https://stackoverflow.com/questions/25806493/using-ffmpeg-with-not-consecutive-numbered-files

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