Ffmpeg - Create a Video from Image Frame with a Start and a Count

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

2 Answers

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

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

Your Answer

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

Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.

Share this article
Twitter Facebook Pinterest