Digital flick book
We recently had to create a timelapse video using images, and the first obstacle we faced was converting the timestamps into an ascending numerical order of images. Luckily, and thanks to a little BASH magic, we found a one-line shell script that managed to convert the timestamp images into numbers. We did this with a copy of all the images, to ensure that we had backups. $ ls | cat -n | while read n f; do mv “$f” “$n.jpg”; done
So why did we capture the images with a timestamp? Well, this project can be used in scientific experiments, so capturing the time and date of each image means that we can review when a change took place, say watching cress/sunflowers grow.
Now to create the video we used avconv. This can be used with the Raspberry Pi. To install it, open the Terminal and type: $ sudo apt-get install libav-tools We used it with a Core i5 laptop, because it’s much quicker in terms of performance. Now run the command in the same directory as the images we’ve just renamed. This will set the frame rate to 10fps, it will start from number 1 in the sequence of images, it sets the bitrate to 1000k and saves the file to test.mp4: avconv -r 10 -start_number 1 -i %d.jpg -b:v 1000k test.mp4 Now open the video using omxplayer and enjoy the fruits of your labour. omxplayer test.mp4