Friday, August 22, 2008

Lightning only

It's pretty boring to watch lightning flash briefly, so I edited out all the boring bits and made a video of just lightning flashes in an isolated storm hovering over the mountains to the north of our house.


For the geeky:

Take a movie with cheap camera.

Split frames into individual jpegs using mplayer

mplayer -nosound -vo jpeg MVI_8542.AVI

Scroll through images and copy illuminated frames into a separate directory.

Make a backup of all the selected images, because you're a doofus and erased them the first time around:

tar zcvf lightning1.tgz *.jpg
mv lightning1.tgz ..

Rename the frames to a sequential sequence using a bash shell script called ren.sh, and make sure it is executable with chmod +x ren.sh > ren2.sh

#!/bin/bash
for i in 00*.jpg;
do
j=`printf "r%0.5d.jpg\n" $x`
echo mv $i $j
x=$((x+1))
done

This generates commands in the ren2.sh file like:

mv 00000422.jpg r00015.jpg
mv 00000423.jpg r00016.jpg
mv 00000804.jpg r00017.jpg
mv 00000805.jpg r00018.jpg

Now actually redo the naming by sh ren2.sh

Generate movie with mencoder.

mencoder "mf://r00*.jpg" -mf fps=25 -o lightning.avi -ovc lavc
mplayer lightning.avi -loop 0

2 comments:

Anonymous said...

that was pretty cool... i love it!!!

Foobar said...

For a totally different reason, I needed to know that mencoder existed, and now I do....