Kapa11
Kapa11

Reputation: 301

ffmpeg - Converting series of images to video (Ubuntu)

I got pictures named as

pic_0_new.jpg
pic_10_new.jpg
pic_20_new.jpg
...
pic_1050_new.jpg

which I want to turn into a video (Ubuntu ffmpeg). I tried the following

ffmpeg -start_number 0 -i pic_%d_new.jpg -vcodec mpeg4 test.avi 

but I don't know how to set the step size and the end number. How to do this?

Thanks for help :)

Upvotes: 2

Views: 2513

Answers (1)

Gergely Lukacsy
Gergely Lukacsy

Reputation: 3074

If your files are named with leading zeroes then you can use the built-in globbing functionality. If not (like your's), you can create a file list and supply that as the input, just like explained here.

The other thing you need to set is the input framerate that tells FFmpeg what framerate should assume for the images (note that the option is ahead of the -i input option).

So the command should look like this:

    ffmpeg -framerate 25 -i pic_%04d_new.jpg <encoding_settings> test.avi

Also note that you can use the filename expansion on files with or without leading zeroes (Thanks for @Gyan to pointing it out):

  • match regularly numbered files: %d (this is what you're using)

    img_%d.png // This will match files with any number as a postfix starting from img_0.png
    
  • match leading zeroes: %0<number_of_digits>d

    img_%03d.png // This will match files ranging from img_000.png to img_999.png
    

In addition, mpeg4/avi is not the most convenient encoder/container to use...

Upvotes: 1

Related Questions