ffmpeg - Create a video from image frame with a start and a cout

18

3

I create a video from image frame, and it work great. The problem is that I don't want to use all the image in my folder. I have 200 frames in my folder, but I want a video from 1 to 100

How I can speficy the frame count or the frame end?

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

I can't find how

Thanks!

DarkPixel

Posted 2013-12-13T16:08:42.067

Reputation: 323

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 – 2013-12-13T16:21:02.490

2That be will my "hack solution" if can't do it with ffmpeg :) – DarkPixel – 2013-12-13T16:41:22.583

Answers

30

You do this by stating the number of frames you want:

-vframes 100  

So effectively it is in your case:

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.

Also, usually one uses something like test_%05d.jpg with the numbered sequence having preceding zeroes and 5 digits. If you don't have it in that format you might need to use a globbing pattern. See this.

Rajib

Posted 2013-12-13T16:08:42.067

Reputation: 2 406

good answer. Note that the placement of vframes matters. You can't put it directly before your output parameter. – Darth Egregious – 2020-02-22T03:59:23.960

3

This is code that always works for me well.

ffmpeg -i yourfile.mp4 -r 1 -ss 15 -t 16 -f image2 snapshot.jpg
                                ^     ^ 
                                ^     ^
                              start  end
                               time   time

time is in seconds only. If it's 2 minute ahead of the reel, then it's 120. One image file always is one second worth, thus calculate your desire image by that approach.

yourfile.mp4 = your movie clip

snapshot.jpg = your new image file

IMPORTANT: leave image2 alone. It is only way to get what I wanted.

Faron

Posted 2013-12-13T16:08:42.067

Reputation: 257

4I 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 – 2015-01-26T10:05:05.063