Here is how I made this time lapse video from image:
- Rename the images in sequence as frameXXX.jpg (where XXX is 000, 001, 002, etc). Many photo viewing software like XnVew (free solution, recommended!) and ACDSee can do this easily
- Run the ffmpeg with the following parameter:
ffmpeg -r 12 -i frame%03d.jpg -sameq -s hd720 -vcodec libx264 -vpre hq -crf 25 OUTPUT.MP4
- Done!
You may want to change the -r parameter to your favorite frame rate. If you want 1080p, simply replace the -s hd720 parameter as -s hd1080, or -s 1920x1080 if you want.
One more important point to note is that the order of parameters matters. Any parameters before the -i will become options for input stream. Like if you type something like ffmpeg -r 12 -i blah blah blah, you will make the specified rate meaningless as it will be applied to input stream which are still imagesthis is how the rate parameter should be specified. Make sure that you don't mix them up when you customize the parameter. Another common problem I've seen is the format for -i parameter. It is actually the same as that of the printf() function in C++. For example, frame%03d.jpg will make ffmpeg looks for images with names frame000.jpg, frame001.jpg, frame002.jpg... while frame%05d.jpg means frame00000.jpg, frame00001.jpg, frame00002.jpg...
Yet I think the quality is not very perfect. Maybe need further fine tunning the parameters. Anyone has hints please?
A uncompressed version can be done like this:
- Resize your image to your desired output resolution (e.g. 1920x1080, 1280x720, etc)
- Rename the images in sequence as frameXXX.jpg (where XXX is 000, 001, 002, etc). Many photo viewing software like XnVew (free solution, recommended!) and ACDSee can do this easily
- Run the ffmpeg with the following parameter:
ffmpeg -r 12 -i frame%03d.jpg -vcodec copy OUTPUT.AVI
- Done again!
Enjoy~
Best tutorial I have found on the net yet. Very to the point, and adaptable.
ReplyDeleteHere's mine:
http://www.youtube.com/watch?v=abh3LtAPtTw
wow!!! the clouds in your video are fantastic!!
ReplyDeletei now know that clouds can really be a nice object for time lapse!
Thanks! There are a lot of convoluted posts out there on how to do this - yours was short, sweet, and simple.
ReplyDeleteHow do you run ffmpeg with that parameter? I just can't figure it out.
ReplyDeleteHi Circle, do the jpeg files have to be renamed to framexxx?
ReplyDeleteI was trying to use the DSC_0001, DSC_0002 etc names that my camera gives but I get this error. Its not easy to rename the files, I dont want to go searching for more software.. thanks
Hi Tommy, I think that replacing frame%03d.jpg with DSC_%05d.jpg will do the trick.
ReplyDeleteYou are probably disappointed with the quality because of the extreme compression in your x264 settings. Try lowering your crf, and using a better encoding preset:
ReplyDelete-vpre slow -crf 15
or even better:
-vpre veryslow -crf 15
This comment has been removed by the author.
ReplyDeleteGreat tutorial.
ReplyDeleteTo rename a set of images under Linux I made a little bash script.
With $1 you can supply a path and/or a file prefix.
#!/bin/bash
i=0
ind=0000
for x in $1*.jpg ; do
mv "$x" "$1$ind.jpg"
((++i))
ind=$i
# $ind must have four digits
for d in 10 100 1000 ; do
if [ $i -lt $d ]
then
ind=0$ind
fi
done
done
If your image filenames are named in sequence, you can skip the step of renaming and pass all the jpg's in that folder to ffmpeg with these options:
ReplyDelete-pattern_type glob -i '*.JPG'
Also, if your file names are in a sequence, but it doesn't start with 0, then you can use the -start_number parameter to let it know where your sequence starts. Mine was DSC_6820.jpg so I did -start_number 6820 -i DSC_%04d.jpg. Worked like a charm.
ReplyDelete