Advertisements

Tree Frog: The Video

Frog walking on tent

Frog walking on tent

Watching the tree frogs crawl up the tent from inside let us see how they move: hand-over-hand up the fabric. A dozen of them crawling along was spooky…

I took a movie with my pocket camera that turned into an 8 MB AVI, which I can’t upload here. Most of it isn’t all that interesting, anyway, an observation which hasn’t stopped YouTube dead in its tracks yet, but we can do better than that.

A pair of Free Software programs extracts the interesting part and produces a (somewhat) smaller animated GIF that works with WordPress.

First, shatter the AVI into separate JPG images:

mkdir frames
ffmpeg -i cimg3781.avi -sameq frames/frame-%03d.jpg

A bit of browsing showed that I wanted frames 227 through 265 and that the frog was pretty much in the upper-middle of the image. So, crop a 320×240 image around the frog from those 640×480 frames:

cd frames
mkdir stills
for f in `seq 227 265` ; do convert frame-$f.jpg -crop 320x240+160+60 stills/still-$f.jpg ; done

Then convert them into an animated GIF with a 500-ms frame rate (the -delay ticker is 10 ms):

cd stills
convert -delay 50 still-2* frogwalk.gif

It’s a 1.6 MB wad, but gets the message across: frogs keep three paws stuck to the floor.

Remember, that little guy is moving at glacial speed in the GIF: those 40 frames of video last just over a second in real time.

Memo to self: MPEG-1 and MPEG-2 only support video-style frame rates around 30 fps.

Update: Regular reader Przemek Klosowski showed me how to generate those numeric sequences on the fly, without using a for loop:

There's this neat Bash construct {1..10} that you can use directly after ffmpeg:
convert -delay 50 still-{227..430}* result.gif

You can even skip every nth frame:
convert -delay 50 still-{227..430..5}* result.gif

Thanks!

Advertisements

,