Removing light flicker in time lapse – in Linux

Published on November 23rd, 2024

If you’ve tried creating a time lapse videos from pictures accidentally shot with automatic settings for exposure etc.. you’ve probably noticed some flickering in the final video. Don’t worry, all is not lost. This post shows you how I have managed to remove flicker from a time-lapse video in just such a situation.

I do my videos in Kdenlive within Ubuntu, a Linux based operating system. I’ve tried a number of different techniques. But found the below to be the one that worked best for me. I hope this helps others.

Flicker removal steps

1. Download the perl script from:
https://github.com/cyberang3l/timelapse-deflicker/blob/master/timelapse-deflicker.pl

2. Save the perl script to a suitable location where you will have a sub-directory for your images.

3. Mark the perl script as executable
You can do this by either:
a: In terminal, by running “chmod +x timelapse-deflicker.pl”
or
b: right click the file, choose properies, then under the Permission tab, tick the “Allow executing file as program”

4. Install ImageMagick and other dependencies:

sudo apt-get install imagemagick libfile-type-perl libterm-progressbar-perl perlmagick libimage-exiftool-perl

5. Go to the directory that your images are in. The script should be placed in the parent folder (one level up from the images). Then execute the script. The parameter “p” will set the script to do 2 passes of the images:

../timelapse-deflicker.pl -p 2

You will see a progress bar as the script runs through the images with 2 passes:

1932 image files to be processed.

Original luminance of Images is being calculated

100% [=========================================================================]

————– LUMINANCE SMOOTHING PASS 1/2 ————–

100% [=========================================================================]
————– LUMINANCE SMOOTHING PASS 2/2 ————–

100% [=========================================================================]

————– CHANGING OF BRIGHTNESS WITH THE CALCULATED VALUES ————–

100% [=========================================================================]

Job completed

1932 files have been processed

6. Once the script has completed, you should find your updated images in a new “Deflickered” sub directory, created by the script where your original images are stored.

Out of interest, I use the following command to push the images back into a video as frames:

ffmpeg -i sunset%04d.jpg -vcodec mpeg4 newestsunset.mp4

note: %04d is because my images have sequencing made of 4 digits (proceeding zeros if not needed: 0001)