# HOWTO: Make Time Lapse Videos from Photographs

Show 75 post(s) from this thread on one page
Page 1 of 3 123 Last
• July 10th, 2012
CyberAngel
HOWTO: Make Time Lapse Videos from Photographs
After looking around, searching, reading and experimenting, I ended up with a bunch of commands to quickly make high quality time lapse videos under Linux. One of the hardest (almost impossible) things to find, is software for photo deflickering so for solving this (or at least improve the results), I created my own little Perl script to compute and change the average luminance (brightness) of all of the photographs.

If some of the commands below are not working, you might need to apt-get install some extra software, but all of it is available in the repositories :)

A Quick Introduction to Time Lapse Videos
From Wikipedia: Time-lapse photography is a technique whereby the frequency at which film frames are captured (the frame rate) is much lower than that used to view the sequence. When played at normal speed, time appears to be moving faster and thus lapsing. For example, an image of a scene may be captured once every second, then played back at 30 frames per second. The result is an apparent 30-times speed increase. Time-lapse photography can be considered the opposite of high speed photography or slow motion.

How to take good pictures to compose a time lapse video afterwards
The rest of the steps might not be reproducable with compact point and shoot cameras.

Tripod
First of all the camera needs to be very stable between shots to make the composition easy later on, therefore, a tripod needs to be used.

Intervalometer
Choose how many total pictures need to be taken and set your camera to take one picture every some predefined interval (for example one every 5 seconds). This can be done either with computer software, or the camera itself. Some cameras have a built in intervalometer or they can accept external accessories.

Calculate Final Video Length
If you choose to take 300 pictures, and you make a final video running at 10 frames per second, then your video will be 30 seconds long (300/10=30s). At 25 frames per second, the same video will be only 12 seconds long (300/25=12s). It is a good idea to plan the desired length for your video beforehand, and take some more photographs to achieve a smoother movement with higher frame rates (especially when moving objects are near your camera).

Camera Settings
For a good time lapse video, the camera needs to be set to Manual mode and choose a non changing Aperture (A), Shutter speed (S), ISO and Focus. This will reduce flickering (different brightness between pictures) a lot as the overall brightness of the pictures will not be changing between shots.
What I usually do, is that I put the camera on the tripod and take pictures in auto mode until I am satisfied with the result. Then I look at the chosen from the camera settings (A, S, ISO), change the mode to manual and use the same settings as the camera did in auto mode. The auto focus is used to focus on the main object properly, and before starting the intervalometer, I change it to manual focus as well as the other settings, because all of the pictures need to have exactly the same focus.

There are certain cases (sunset is one of them) that lighting conditions might change a lot during your shots, and a fixed set of A, S and ISO settings might not give good results after sometime. In this case, I always choose a stable Aperture to avoid changes in the depth of field (DOF), ISO and focus, and let the shutter speed vary (Usually the A or Aperture mode of your camera can do this). This technique will introduce more flickering because the exposure metering of your camera will calculate slightly different values sometimes.

Making the Video
This is the actual purpose of this tutorial. To show you how to use Linux to put everything together fast.

Step 1
Make a new folder and copy all of your photographs taken for the time lapse into it. Make sure that your photographs have a unique filename with an increasing number, so that when you sort them, the first frame (with the lowest number) of your video comes first and last comes last. The default numbering (DSC_0001.jpg, DSC_0002.jpg,....) of most of the cameras will do fine.

Code:

```mkdir source_folder_of_pictures cp /media/cf/* source_folder_of_pictures/```
Step 2
Resize the images first to 1920x1080 to get a Full HD output (all of the rest of the operations will be much much faster if you do this now)

Code:

```cd source_folder_of_pictures mkdir resized mogrify -path resized -resize 1920x1080! *.jpg cd resized```
Step 3 (OPTIONAL)
If you photos have noticeable flickering which is caused by slightly different exposure between taken photos, download the attached script, put it in the directory source_folder_of_pictures/resized/, make it executable and run it. The script will create a subdirectory "source_folder_of_pictures/resized/Deflickered" to store the processed photos.

Code:

```sudo apt-get install libfile-type-perl libterm-progressbar-perl chmod +x timelapse-deflicker.pl ./timelapse-deflicker.pl -h ./timelapse-deflicker.pl -v cd Deflickered```
Step 4
Use ls to sort the files by their number.

Code:

`ls -1tr | grep -v files.txt > files.txt`
Step 5
Use mencoder to combine all of the photos in one video without losing quality! This will create a big file as it will only put all of the JPG files together in a single uncompressed video. Change the "fps=15" in the following command, to match your frames per second you wish to get in the final video.
Note: Use ONLY ONE of the following 3 commands. I usually choose the first one to quickly check the result and then I re-make the video with the second or third command if I want to make some post processing in kdenlive.
Code:

```mencoder -nosound -noskip -oac copy -ovc copy -o output.avi -mf fps=15 'mf://@files.txt' # Very fast but does not create index so if you want to edit with a non linear editor do not choose this. mencoder -idx -nosound -noskip -ovc lavc -lavcopts vcodec=mjpeg -o output.avi -mf fps=15 'mf://@files.txt' # Fast, it will create index, but it will re-compress the JPG files so some loss of quality will occur (insignificant, so you can safely bet on this) mencoder -idx -nosound -noskip -ovc lavc -lavcopts vcodec=ljpeg -o output.avi -mf fps=15 'mf://@files.txt' # Slow, it will create index, it will re-compress the JPG file but with the highest quality options to provide lossless results (the final file will be larger than the total of the original files, but if you are a quality freak, then go for this one)```
Step 6 (OPTIONAL)
Here you might want to use a non linear editor like kdenlive (which is the best non linear video editor I have found for Linux so far) to add some music to your video and introduce some effects (like smooth fade from black in the beginning of the video or fade to black in the end), but remember to export in a lossless quality format like MPEG2 I-Frame only so that you won't get any significant loss of quality.

Step 7
Use ffmpeg to compress the video into a high quality Full HD one.
Code:

`avconv -i output.avi -c:v libx264 -preset slow -crf 15 output-final.mkv`

You are done!
Congratulations! Enjoy and brag for your own time lapse video :)
• July 11th, 2012
chili555
Re: HOWTO: Make Time Lapse Videos from Photographs
Awesome! I have been experimenting unsuccessfully with time lapse for some time now. I have used a variety of tutorials and have been disappointed with the result. I just tried your steps and, with one exception, found it perfect.

I have been an interval shooter for some time and have been strict with aperture, shutter speed and ISO. I also hardly ever shoot any photographs without a tripod, even the cat! Accordingly, I skipped the deflicker step and can't say if it works or doesn't. All the other steps produced an excellent result. I appreciate your hard work and, moreover, your generosity in posting it here. I have bookmarked and printed your posting and can hardly wait to get out under the stars for three or four hours with my Nikon, some Irish coffee and my best gal!
• July 11th, 2012
CyberAngel
Re: HOWTO: Make Time Lapse Videos from Photographs
Makes me happy that this information was found useful for someone else except me :)

Here are three videos I made with this technique:

The first two of them, use a variable shutter speed (you will see that the sun sets but the video is still bright) and for the 3rd one with the stars all of the settings are fixed. I wasn't out there with the camera and an Irish coffee though cause it was -20 degrees... I chose the cabin instead hehe

None of these videos use the deflickering script as this is something I made a couple of days ago.
The results of the deflickering script can be seen here:
• July 11th, 2012
chili555
Re: HOWTO: Make Time Lapse Videos from Photographs
-20 degrees? But you use that funny centigrade there, don't you? You are right, that's cabin time for me, too. I usually quit about -10 C.

Very nice work there! I enjoyed them all.

Of course, this guy is the master: http://www.timescapes.org/ I love his moving stars. He uses a dolly for the camera, as well.

I find myself doing more photography these days after midnight.

Thanks again for your excellent tutorial.
• July 11th, 2012
CyberAngel
Re: HOWTO: Make Time Lapse Videos from Photographs
Quote:

Originally Posted by chili555
-20 degrees? But you use that funny centigrade there, don't you? You are right, that's cabin time for me, too. I usually quit about -10 C.

Very nice work there! I enjoyed them all.

Of course, this guy is the master: http://www.timescapes.org/ I love his moving stars. He uses a dolly for the camera, as well.

I find myself doing more photography these days after midnight.

Thanks again for your excellent tutorial.

Yes, we use Celcius here :)

I didn't know timescapes.org! Indeed the master...

Terje Sorgjerd is another great one! Take a look here:
http://vimeo.com/terjes
• August 16th, 2012
dckirba
Re: HOWTO: Make Time Lapse Videos from Photographs
Hi CyberAngel,

I was hoping to try your deflickering script but I ran into an error:

Quote:

Can't locate File/Type.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at ./timelapse-deflicker.pl line 25.
BEGIN failed--compilation aborted at ./timelapse-deflicker.pl line 25.
Any idea what I'm doing wrong or if there's anything I need to install?

David

Edit: Learnt how to install the necessary PERL modules. Running the script right now :)
• August 21st, 2012
CyberAngel
Re: HOWTO: Make Time Lapse Videos from Photographs
Quote:

Originally Posted by dckirba
Hi CyberAngel,

I was hoping to try your deflickering script but I ran into an error:

Any idea what I'm doing wrong or if there's anything I need to install?

David

Edit: Learnt how to install the necessary PERL modules. Running the script right now :)

Nice that you found solved the problem on your own :)

Did you see any improvement in the flickering?
• August 22nd, 2012
dckirba
Re: HOWTO: Make Time Lapse Videos from Photographs
Quote:

Originally Posted by CyberAngel

Did you see any improvement in the flickering?

I definitely did. I'm trying to upload both version on Vimeo and I'll post links here. I was shooting around sunset so I guess the lighting lends itself to even more flickering than usual ;) Thanks for the script!
• August 22nd, 2012
CyberAngel
Re: HOWTO: Make Time Lapse Videos from Photographs
Anyone knows why I cannot edit the first post to make some corrections?

I ran into some problems for some time lapses with this line of code:

Code:

`ls -1tr | grep -v files.txt > files.txt`
It should be:

Code:

`ls -1 | grep -v files.txt > files.txt`
• August 22nd, 2012
MG&TL
Re: HOWTO: Make Time Lapse Videos from Photographs
Quote:

Originally Posted by CyberAngel
Anyone knows why I cannot edit the first post to make some corrections?

I ran into some problems for some time lapses with this line of code:

Code:

`ls -1tr | grep -v files.txt > files.txt`
It should be:

Code:

`ls -1 | grep -v files.txt > files.txt`

Hi CyberAngel,

there are two points to make:

1. There is now a post-editing limit in force. You are now only allowed to edit your posts before 7 days have elapsed.

2. Tutorials and tips should now be made into wiki pages on the Ubuntu wiki: see http://ubuntuforums.org/showpost.php...64&postcount=1
Show 75 post(s) from this thread on one page
Page 1 of 3 123 Last