lbedogni
lbedogni

Reputation: 7997

Using ffmpeg with not consecutive numbered files

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

Upvotes: 4

Views: 2973

Answers (1)

llogan
llogan

Reputation: 133673

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:

Upvotes: 4

Related Questions