Sunday, September 25, 2016

Making a time lapse movie

I'm using CHDK on my old Canon Powershot SX20 and have the Ultimate Intervalometer script installed. This script lets me set the camera to start and stop shooting at specific times and at a specific interval. I had done this a couple of years ago for something (a brewing day, I think), but had forgotten the details, hence this post (nice camera, doesn't get used much since the camera on my phone is pretty decent for most things). After running the script, there are a number of individual jpg files that need to be combined into a movie.

To create video out of time lapse stills:

sd card has 2 partitions, one for the CHDK boot code, the other for pictures:
CHDK: mmcblk0p1
pictures: mmcblk0p2

(Side note: to add a new script, copy it to the pictures partition under CHDK/SCRIPTS.)

mount sd card at /mnt/sd:
make sure card is writable (be sure to set the write lock back when putting the card back into the camera)
sudo mount -t vfat /dev/mmcblk0p2 /mnt/sd

cd to DCIM dir on memory card, then:

mencoder mf://*.JPG -mf fps=10:type=jpg -ovc x264 -x264encopts bitrate=1200:threads=2 -o /home/danson/tmp/outputfile.mkv

change fps (frames per second) and bitrate as needed, rest should be good.

change mkv to avi for upload to youtube or whatever:

mencoder mf://*.JPG -mf fps=10:type=jpg -ovc x264 -x264encopts bitrate=1200:threads=2 -o /home/danson/tmp/07262012.avi


Can use ffmpeg (haven't tested this, copied the directions from somewhere on the internet):

For creating a video from many images:
 

ffmpeg -f image2 -i foo-%03d.jpeg -r 12 -s WxH foo.avi

The syntax foo-%03d.jpeg specifies to use a decimal number composed of three digits padded with zeroes to express the sequence number. It is the same syntax supported by the C printf function, but only formats accepting a normal integer are suitable.

When importing an image sequence, -i also supports expanding shell-like wildcard patterns (globbing) internally. To lower the chance of interfering with your actual file names and the shell’s glob expansion, you are required to activate glob meta characters by prefixing them with a single % character, like in foo-%*.jpeg, foo-%?%?%?.jpeg or foo-00%[234%]%*.jpeg. If your filename actually contains a character sequence of a % character followed by a glob character, you must double the % character to escape it. Imagine your files begin with %?-foo-, then you could use a glob pattern like %%?-foo-%*.jpeg. For input patterns that could be both a printf or a glob pattern, ffmpeg will assume it is a glob pattern.

No comments: