3

I have been using ffmpeg to convert a sequence of jpegs to a video using the following syntax

ffmpeg -f image2 -i frame%d.jpg -vcodec mpeg4 -b 800k video.avi

it works a treat, however if the filenames dont start at 0 and then pursue in accending order I get weird results. for example the first file in the directory is frame1 and last file is fram 61.I should point out that im always using a list of jpegs which accend in incrental order. for example a list of files called frame1, fram2, fram3 etc.

the following works fine

frame1.jpg to frame9.jpg

frame1.jpg to frame10.jpg frame2.jpg to frame8.jpg frame2.jpg to frame10.jpg frame2.jpg to frame11.jpg frame2.jpg to frame17.jpg frame2.jpg to frame20.jpg frame2.jpg to frame30.jpg frame2.jpg to frame61.jpg

the following doesnt work

26 to 57 fail

11 to 61 fail 10 to 61 fail 20 to 61 fail 24 to 61 fail

Can I modify the arguments for ffmpeg so that it will make the video regardless of the filenames? (frame%d)

brux
  • 2,959
  • 9
  • 41
  • 76

2 Answers2

3

The only way I got this to work was by naming frames files with a constant fixed width for frame counters. If you are taking frames from webcams check if that could be done by the webcam itself, otherwise, you'll have to rename it yourself. You may develop a Windows Service that use a FileWatcher class in C# that "listens" for a folder to be writted with a frame and then rename it to another folder with the beforemention format. This worked for me.

frame01.jpg
frame02.jpg
...
frame10.jpg
frame11.jpg
...
frame61.jpg

Then using this:

ffmpeg.exe -r 1 -f image2 -i frame%02d.jpg -r 16 -vcodec mpeg4 -b 800k -y video.avi

-i frame%02d.jpg: indicates 2 digits for frame counter

I added -r 1 and -r 16 as optional framerates that I test to have worked for me.

user347594
  • 1,216
  • 7
  • 9
1

You could rename all jpeg files so the numbering always starts at zero and there are no gaps.

compie
  • 9,449
  • 15
  • 51
  • 73
  • I thought I had tried this, and thats why i was attributing the error to ffmpeg DOH..it works now once i rename the files. thanks – brux Jul 18 '10 at 15:13