This note explains how to take a number of still images and combine them into a movie using “avconv”.
This note applies to:
- Ubuntu 14.04
- avconv 9.16
Before starting a time-lapse project, one should consider some constraints. The number of pictures that can be taken by the camera is constrained by the size of the memory card where the camera saves its information. On the other hand, the largest possible number of pictures should be taken, since it provides for a smoother end video.
Therefore, an approximate length of the event to be recorded must be used, in conjunction with the total number of pictures that can be saved to memory, to compute the interval between each picture taken.
Also, one should consider the power needs for the extended duration that the camera is used.
Finally, the memory card used by the camera should be fast enough to record the images at the rate that they will be produced.
After all pictures have been taken, one ends up with a large collection of images, generally numbered sequentially by the camera using a special naming convention. For this note, an example is used to demonstrate the process. In this example, about 2300 pictures were taken every two seconds, over a period of 1 hour and 20 minutes. The resulting collection was picture named as follows:
On Ubuntu, the command-line tool “avconv” can be used to combines still images into a movie. The command required to combine the images from the previous example is:
avconv -r 10 -start_number 6796 -i IMG_%d.JPG -q:v 0 -s hd1080 -vcodec libx264 -crf 25 movie.mp4
The parameter “-r 10” sets the number of frames per second on the input stream. This is an important parameter since it influences both the smoothness of the video and its length. The higher the number, the smoother the resulting video. Ideally, the input frame rate should be 25 to 30 frames per seconds for the best smoothness.
However, following our example, at 25 frames per second, the resulting video would be 1.5 minutes long. In our example, we wish to have the resulting movie showing the original event over 4 minutes. Therefore, the input rate is set to 10.
The parameter “-start_number 6796” specifies the number at which the file name sequence starts at. This parameter is used with the input file format parameter “-i IMG_%d.JPG”, where the portion of the name with %d is replaced by a number, to find each image file.
The parameter “-q:v 0” sets the highest output video quality.
The parameter “-s hd1080” is used to sets the output dimensions of the video to high definition.
The parameters “-vcodec libx264” and “-crf 25” are used to set the output CODEC to H.264 and output frame rate. The output frame rate does not affect the length of the movie.
Although there are many factors to consider when making a time-lapse movie, the command-line tool “avconv” is really useful stitch together the video portion of the project. “avconv” is the successor to “ffmpeg”. Both tools are mature and contain a large number of options.
Therefore, use the options above as a starting point and experiment until you reach the desired effect.