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.
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.
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).
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.
Make a new folder and copy all of your photographs taken for the time lapse into it. Sort the images by capture date/time and store them in a new folder called "renamed". This is useful if your camera messes up the filename ordering when it starts counting from 0001 after reached the highest possible number (e.g. ..., DSC_9998, DSC_9999.jpg, DSC_0001, DSC_0002).
cp /media/cf/* source_folder_of_pictures/
ls -1tr *.jpg | while read filename; do cp $filename renamed/$(printf %05d $counter)_$filename; ((counter++)); done
Resize the images first to 1920x1080 to get a Full HD output or 3840x2160 if you need 4K output. All the rest of the operations will be much much faster if you do this now since you will be working with smaller sized files.
Step 3 (OPTIONAL)
mogrify -path resized -resize 1920x1080! *.JPG # If you want to keep the aspect ratio, remove the exclamation mark (!)
# You can also use the mogrify from graphicsmagick package which is faster, I use it in combination with the command "parallel" in order to utilize all of my CPU cores and perform the resize much faster.
# Of course, you can use the command "parallel" with the imagemagick mogrify
# parallel --progress gm mogrify -quality 100 -output-directory resized -resize 1920x1080! ::: *.JPG # Similar as before, remove the exclamation mark in order to keep the aspect ratio.
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/renamed/resized/, make it executable and run it. The script will create a subdirectory "source_folder_of_pictures/renamed/resized/Deflickered" to store the processed photos.
You can get the latest version of the script at https://github.com/cyberang3l/timela...e-deflicker.pl
sudo apt-get install libfile-type-perl libterm-progressbar-perl
chmod +x timelapse-deflicker.pl
Use ffmpeg 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 "-r 25" 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 if I am working with jpeg files, as it will simply copy the source images and each one will occupy one frame in the resulting video. It is also ultra fast since it doesn't do any re-compression.
Step 5 (OPTIONAL)
ffmpeg -r 25 -pattern_type glob -i '*.jpg' -c:v copy output.avi # Change -r 25 to define the frame rate. 25 here means 25 fps.
# Alternative commands, but your jpeg images will be recompressed (maybe you want to use one of these if you have png or any other kind of images, or you want a smaller sized video)
ffmpeg -r 25 -pattern_type glob -i '*.jpg' -c:v mjpeg -q:v 2 output.avi # -q:v can get a value between 2-31. 2 is best quality and bigger size, 31 is worst quality and least size)
ffmpeg -r 25 -pattern_type glob -i '*.jpg' -c:v ljpeg output.avi # Lossless jpeg resulting in a huuuuuuuge file. Even larger in size than the sum of all of the input pictures together in the case of jpg images.
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 so that you won't get any noticable loss in quality.
On my latest attempt to create a 4k video with kdenlive, I had to create a custom 4k project profile (accessible from Settings -> Manage Project Profiles)
and a custom rendering profile (Project -> Render -> Create new profile) with the following contents:
acodec=ac3 ab=448k ar=44100 ac=2 vcodec=libx264 crf=15 rc-lookahead=60 coder=1 flags=+loop cmp=+chroma partitions=+parti8x8+parti4x4+partp8x8+partp4x4+partb8x8 me_method=umh subq=10 me_range=24 g=250 keyint_min=25 sc_threshold=40 i_qfactor=0.71 b_strategy=2 qcomp=0.6 qmin=0 qmax=51 qdiff=4 bf=8 refs=9 directpred=1 flags2=+mixed_refs+dct8x8+fastpskip+mbtree cqp=0 wpredp=2 trellis=2 weightp=2 deblock=1:0:0 direct=auto muxer=auto aspect=%dar
Use ffmpeg to compress the video into a high quality Full HD one.
If you created a 4k video and you want to resize it to 1080p, use the following command:
ffmpeg -i output.avi -c:v libx264 -preset slow -crf 15 output-final.mkv
Check here for more encoding options: https://trac.ffmpeg.org/wiki/Encode/H.264
ffmpeg -i output.mkv -s 1920x1080 -c:v libx264 -preset slow -crf 15 output-final.mkv
You should definitely take a look in this post from FakeOutdoorsman: http://ubuntuforums.org/showthread.p...6#post13191696
You can find many nice tips.
You are done!
Congratulations! Enjoy and brag for your own time lapse video