Making a timelapse video out of several photos taken with a specific delay is quite easy in GNU/Linux. Here I show two examples of timelapse made out of the photos I have taken with Open Camera and Oneplus default camera app.

1 Open camera android app

Photos with defined delays can be taken using the free and open source Open Camera app which take decent photos when there is plenty of light. This is a sample of such timelapse done using Open Camera and a set of commands which I cover later in this post. I used DRO mode of the Open Camera and locked, infinity focus with 20 seconds delay between each photo.

2 Default camera app

When you need to use the default camera app as I had to do with my Oneplus 5 to have manual controls for night shots, you can use RepetiTouch free. Unfortunately, I could not find any open source app that does touch emulation. You need to have root access to your android phone to use this app. With this you can record the touch sequence and have it repeated infinitely. What you see in the following video is a result of some 900 photos each with ISO 100 and shutter speed of 30 seconds.

3 Making a video from photos

First, you need to install ffmpeg

sudo apt install ffmpeg

Here are the sequence of commands I use to make my timelapse videos.

3.1 Reorder photos (optional)

Normally, there is no need to reorder photos, but this is the command if you have to do so

mkdir renamed
counter=1
ls -1tr *.jpg | while read filename; do cp $filename renamed/$(printf %05d $counter)_$filename; ((counter++)); done
cd renamed

3.2 Resize (optional)

To prevent huge video files and save processing time, it is better to first resize down the photos

mkdir resized
mogrify -path resized -resize 1920x1080! *.jpg 

If you want to keep the aspect ratio, remove the exclamation mark (!) from the command.

3.3 Brightness and contrast adjustments and normalization (optional)

I increase the contrast and brightness of the night photos with the following

mkdir adjusted
cd adjusted
for sp in ../*; do 
  echo "Converting Image: $sp"
  convert -brightness-contrast 40x60 $sp $(basename $sp) # for manual adjustment
  #convert -auto-level -normalize $sp $(basename $sp) #  -auto-gamma, -enhance, -equalize and -contrast, too
done

3.4 Watermark (optional)

If you'd like to watermark the final video with a text, you could use the following

mkdir water
for img in *.jpg; do 
    convert $img -pointsize 20 -draw "gravity south fill gray30  text 0,11 'hadi.timachi.com'" 'water/'$img; 
done
cd water

3.5 Make a video

Finally, you can turn your photos into a video. Pick one of the commands below. Change the frame rate to your likings. I use 20 for night shots since they take longer and 40 for day shots with 20 second delay.

3.5.1 No recompression of jpgs

ffmpeg -r 25 -pattern_type glob -i '*.jpg' -c:v copy output.avi # Change -r 25 to define the frame rate. 

3.5.2 Using recompression

This way, your jpeg images will be recompressed (maybe you want to this if you have png or any other kind of images, or you want a smaller sized video). Here -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 mjpeg -q:v 2 output.avi

3.5.3 Lossless

Lossless jpeg combination, resulting in a very big file. The video can even be larger in size than the sum of all of the input pictures together in the case of jpg images.

ffmpeg -r 25 -pattern_type glob -i '*.jpg' -c:v ljpeg output.avi 

3.6 Compress the video

I use ffmpeg to decrease the size and optimize the video

ffmpeg -i output.avi -c:v libx264 -preset slow -crf 15 output-final.mp4