European Open Root Server Network

GoPro timelaspe with unix tools

You just bought a new GoPro cam and are now eager to create a first timelaspe just for the joy of fun? Here we go:

First scale and crop the pictures to your desired resolution:

for FILE in  *GOPRO/*.JPG
do
	test ! -f scaled/$(basename $FILE) && \
		convert \
		-resize 1920x1080^ \
		-gravity Center \
		-crop 1920x1080+0+0 \
		+repage \
		$FILE scaled/$(basename $FILE)
done

This scales your pictures in the *GOPRO folders to 1920x1080 (HD) pixels and crops the image centered (use North, West and so on to crop to other regions, see man convert (1)).

Now create a sorted listing of the pictures which are going to be your single frames:

ls -1v GOPR* > files.txt # this creates a list of files sorted by their natural number
ls -1tr GOPR* > files.txt # this creates a list sorted by modification time

We use mencoder to create an mp4 with 30 fps from the files:

mencoder \
	-nosound \ # we want no sound 
	-ovc lavc \ # encode with a libavcodec codec
	-lavcopts vcodec=mpeg4:mbd=2:trell:autoaspect:vqscale=3:threads=8 \ # libavcodec options: MPEG-4, Macroblock decision algorthm 2, Trellis searched quantization, autospect, video quality scale (0-31) 3, use 8 threads
	-vf scale=1920:1080 \ # scale the video to 1920X1080 (yes we've done that before)
	-mf type=jpeg:fps=30 \ # media format: we use jpeg
	mf://@files.txt \ # our media list
	-o ../timelapse.mp4 # and save it to timelapse.mp4
mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell:autoaspect:vqscale=3:threads=8 -vf scale=1920:1080 -mf type=jpeg:fps=30 mf://@files.txt -o ../timelapse.mp4 

Have a look at mencoder's manpage for details about the options.

Oh... and have fun ;-)