Creating timelapse videos on linux

This is the first timelapse i did using my new GoPro Hero2.
It’s set up of about 2000 photos taken in ~2:30h.

Happy Birthday, Franz!

Download HQ (~180MB)

Assembly Process (slight commenting)

Tools used:

  • ffmpeg
  • mencoder
  • kdenlive
  • MP4Box (Archlinux package: gpac)
Sorting input images

ffmpeg expects the input images to have incremental  numbers without offset. so one can get them in this format with whatever tool of choice. gqview e.g. allows series renaming and would do that job fine. or just use the cmdline(shell + perl) like i did:

cd ~/inputfiles; mkdir order;find . -maxdepth 1 -iname "*.jpg" | sort | perl -MFile::Copy -ne 'BEGIN{$i = 0};chomp;copy($_, "order/".sprintf("img_%04d.jpg", $i)); $i++'

~inputfiles/order/ now holds images as ffmpeg expects them.

Creating the timelapse
ffmpeg -i /inputfiles/order/img_%04d.jpg -r 25 -s 1280x960 -vcodec libx264 -b:v 30000k Flapse_25fps.mp4

now, this creates a timelapse video of 25 frames per second. this might fit well in a lot of situations. but in my case the timelapse seemed to be a bit to fast rushing by.

Using mencoder to slow it down
mencoder -speed 0.5 -ofps 25 -ovc copy Flapse_25fps.mp4 -o slow.mp4

play with the -speed value a bit.

once i was satisfied with the result i pushed slow.mp4 into a kdenlive project, added some music, fade in/out effects and rendered to mp4.
note to myself: investigate further on how this step be done with ffmpeg/(cmdl)

Converting for online playback

For my embedded wordpress player i wanted to resize the video, lower the bitrate and create streaming compatible metadata:

MP4
ffmpeg -i slow_and_audio.mp4 -strict experimental -vcodec libx264 -acodec aac -b:v 1500k -b:a 128k -s 640x480 slow_and_audio_resized.mp4
MP4Box -inter 500 slow_and_audio_resized.mp4 -out final.mp4
WEBM
ffmpeg -i slow_and_audio.mp4 -acodec libvorbis -b:v 1000k -b:a 128k slow_and_audio_resized.webm
OGV
ffmpeg -i slow_and_audio.mp4 -acodec libvorbis -b:v 1000k -b:a 128k  slow_and_audio_resized.ogv

Comments

  1. You can do the renaming with a oneliner;

    ls *.JPG| awk ‘BEGIN{ a=0 }{ printf “mv %s file_%04d.jpg\n”, $0, a++ }’ | bash

  2. Or:
    mkdir order; i=0; for file in $(find . -name “*.JPG” | sort); do cp $file order/$(printf ‘%05d’ $i).jpg; i=$(($i+1)); done

  3. Thank you very much. This was very helpful.

    I just want to note that “;” before “| sort |” gave the following error:
    bash: syntax error near unexpected token `|’

    I just removed “;” and everything is okay.

    • Glad this was of help for you.
      Thanks for letting me know about this mistake. I corrected it in the post.

Leave a Reply

Your email address will not be published / Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.