23

Using ffmpeg, I made a video from multiple images with the below, which works, however I don't want to use all 200 images in my folder, wanting the video to contain only images from 1 to 100:

ffmpeg -start_number n -i test_%d.jpg -vcodec mpeg4 test.avi

How can I specify the number of frames to include in the video, or the number of the ending frame?

2
  • I don't know much about this program, but if it's using every image in a particular folder, why not create a new folder and only put in the 100 frames you want? – philipthegreat Dec 13 '13 at 16:21
  • 2
    That be will my "hack solution" if can't do it with ffmpeg :) – DarkPixel Dec 13 '13 at 16:41
38

You do this by stating the number of frames you want with -vframes 100:

ffmpeg -start_number 1 -i test_%d.jpg -vframes 100 -vcodec mpeg4 test.avi
  • You might need to specify other parameters such as pix_fmt, etc. depending on other factors, and usually one uses something like test_%05d.jpg with the numbered sequence having preceding zeroes with five digits; if you don't have it in that format you might need to use a globbing pattern.
1
  • good answer. Note that the placement of vframes matters. You can't put it directly before your output parameter. – Darth Egregious Feb 22 '20 at 3:59
3

This always works well for me:

ffmpeg -i yourfile.mp4 -r 1 -ss 15 -t 16 -f image2 snapshot.jpg
                                ^     ^ 
                                ^     ^
                              start  end
                               time   time
  • yourfile.mp4: movie clip
  • snapshot.jpg: new image file
  • IMPORTANT: leave image2 alone, as it was the only way to get what I wanted

Time is in seconds only; If it's 2 minutes ahead of the reel, then it's 120.
One image file is always one-second worth, thus calculate your desired image by that approach.

1
  • 4
    I appreciate this command, because it works with old ffmpeg which I have to use right now; the only thing is -t is not "end time", man ffmpeg states it is "duration"; so end time would be start+duration. Cheers! – sdaau Jan 26 '15 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.