28

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? Commented Dec 13, 2013 at 16:21
  • 2
    That be will my "hack solution" if can't do it with ffmpeg :)
    – DarkPixel
    Commented Dec 13, 2013 at 16:41

2 Answers 2

42

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
  • 2
    good answer. Note that the placement of vframes matters. You can't put it directly before your output parameter. Commented Feb 22, 2020 at 3:59
6

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.

2
  • 5
    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
    Commented Jan 26, 2015 at 10:05
  • -to means end time.
    – chener
    Commented Feb 26 at 8:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .