creating timelapse from still images (jpg) to mp4 using ffmpeg

5,971

Problem

ffmpeg expands the * wildcard in your command to:

ffmpeg -i 001.jpg 002.jpg 003.jpg -c:v libx264 -crf 0 -y output.mp4

This assumes your input files are named 001.jpg, 002.jpg, 003.jpg, etc.

So now 001.jpg is the only input and 002.jpg, 003.jpg, output.mp4 are the output files. Since you're using the dangerous -y option (automatically overwrite without asking) then 002.jpg and 003.jpg have been overwritten.

Solutions

Use the -pattern_type glob option:

ffmpeg -framerate 10 -pattern_type glob -i "*.jpg" -c:v libx264 -crf 0 output.mp4

This may not work in Windows.

Or tell it the inputs are a sequence. For 001.jpg, etc:

ffmpeg -i %03d.jpg -c:v libx264 -crf 0 output.mp4

For image-0001.jpg, etc:

ffmpeg -framerate 24 -i image-%04d.jpg -c:v libx264 -crf 0 output.mp4

Or add a cat:

cat *.jpg | ffmpeg -framerate ntsc -i - -c:v libx264 -crf 0 output.mp4

For more info see the image demuxer documentation.

Share:
5,971

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin almost 2 years

    I have tried a number of different options found on StackExchange for converting still images into an mp4. I have yet to be entirely successful. Any help would be appreciated.

    ffmpeg -i ../*.jpg -c:v libx264 -crf 0 -y output.mp4
    

    The resulting mp4 contains the first image with 00:00 for the length of the video. It looks like it is working. The stream mapping shows all 17 images (0-16) in the Stream mapping. I see in the output text that it determined the image resolution to be 1280x800, which is correct.

    I'm not sure if it is relevant, but the initial images are around 93KB. The mp4 is 504KB.

    These 17 images are part of a test set. Eventually, I hope to use this method to generate a 6-day time-lapse.

  • olejorgenb
    olejorgenb over 2 years
    A possible gotcha: When reading files from stdin it's the actual file content which should be piped, not a list of filenames. I know that's what the command does, but I must have sub-consciously assumed it was the list of names.