Dig­i­tal flick book

Linux Format - - RASPBERRY PI -

We re­cently had to cre­ate a time­lapse video us­ing im­ages, and the first ob­sta­cle we faced was con­vert­ing the time­stamps into an as­cend­ing nu­mer­i­cal or­der of im­ages. Luck­ily, and thanks to a lit­tle BASH magic, we found a one-line shell script that man­aged to con­vert the time­stamp im­ages into num­bers. We did this with a copy of all the im­ages, to en­sure that we had back­ups. $ ls | cat -n | while read n f; do mv “$f” “$n.jpg”; done

So why did we cap­ture the im­ages with a time­stamp? Well, this project can be used in sci­en­tific ex­per­i­ments, so cap­tur­ing the time and date of each im­age means that we can review when a change took place, say watch­ing cress/sun­flow­ers grow.

Now to cre­ate the video we used av­conv. This can be used with the Rasp­berry Pi. To in­stall it, open the Ter­mi­nal and type: $ sudo apt-get in­stall libav-tools We used it with a Core i5 lap­top, be­cause it’s much quicker in terms of per­for­mance. Now run the com­mand in the same di­rec­tory as the im­ages we’ve just re­named. This will set the frame rate to 10fps, it will start from num­ber 1 in the se­quence of im­ages, it sets the bi­trate to 1000k and saves the file to test.mp4: av­conv -r 10 -start_num­ber 1 -i %d.jpg -b:v 1000k test.mp4 Now open the video us­ing omx­player and en­joy the fruits of your labour. omx­player test.mp4

Newspapers in English

Newspapers from Australia

© PressReader. All rights reserved.