ffmpeg limit number of images converted to video [duplicate]

Is it possible to instruct ffmpeg to combine a limited range of images together?

Lets say there is a folder of 1000 images named img_0001.jpg to img_1000.jpg and I only wanted to combine img_0250.jpg through img_0750.jpg.

The -start_number option specifies a starting point but from there it will run until the end of the sequence:

ffmpeg -start_number 250 -i img_%4d.jpg -vcodec mpeg4 output.mp4

Is there a way of specify a -stop_number or total number of frames to run for?


Solution 1:

You can use -frames:v:

ffmpeg -i img_%4d.jpg -frames:v 500 output.mp4

Solution 2:

The -t option specifies the length of the output in either seconds or hh.mm.ss[.xxx] format (x=milliseconds) Alternatively the -to option sets the stop time, again in seconds or hh.mm.ss[.xxx] format

These are in the output options, rather than the input options btw.

More info at the ffmpeg documentation page, strangely enough.