FFMPEG: png to mpeg

I have been lucky enough to have a chance to do some of my more basic data processing in Python (with numpy/scipy/matplotlib). One of the things I’ve been working on is the effect of interference between the direct path and surface bounce arrivals from a fin whale that is near the surface. Hopefully I’ll have a post dedicated to that problem in particular, but for the time being, I’ve been trying to figure out the best way to animate a series of plots output each time the code goes through a loop.

There are a few options for doing this. From what I can gather, it’s not something that is easily done within Python (someone correct me if that’s wrong!). So instead, I’m creating a series of image files (.png’s), and converting to video outside Python. I looked at a couple of options and settled on ffmpeg, which seemed really simple.

I grabbed it from fink:

fink install ffmpeg

All of my image files were saved in a single folder, with names like 001.png, 002.png, … 198.png. Converting them to video format:

ffmpeg -i %03d.png -vb 1024K video.mpg

The -i flag is for input file(s) and -vb is video bitrate. Here’s the output:

Installing SciPy and Matplotlib

Hm.  Well, in all the excitement of installing NumPy, and configuring Emacs for Python, I neglected to actually install SciPy.  I thought I was going to have to do something pretty complicated, but it turns out that SciPy was available through Synaptic.  That makes my life much easier.  I also never got around to installing Matplotlib…also found in Synaptic!  I guess that the versions that come with the OS’s aren’t always the most up-to-date and stable, but I’m going to go ahead and take that risk in the interest of moving forward in my quest.  (whatever that is).

I think I like Matplotlib and iPython because they are both somewhat reminiscent of Matlab (my favorite!).  Why would I want to go to all this trouble to figure out Matplotlib and iPython, Numpy and Scipy?  Because they are FREE!  And it’s fun to figure it all out.  Keeps me entertained.

Learning Python (the book)

I just picked up my second python book – although this is probably the one I should have bought first.  It’s ‘Learning Python’ from O’Reilly.  I already had Beginning Python.  I’ve been wanting to get the O’Reilly one for a while now, but never really wanted to spend the 50 bucks.  I finally broke down and got it at Borders this morning.  I hope it’s a good reference.  The first thing I’d like to do is to remember how to do things like read files, parse data, create plots.  I think I remember having to add Scipy and Matplotlib.

If I want Scipy, I need to also get Numpy.  In the Scipy/Numpy installation instructions for Ubuntu, it gives a couple of options for installation.  One of these is from a guy called Andrew Straw, who has an unofficial repository for NumPy .deb packages.  I’m going to try that first.  I just checked out his repository and he just updated for Karmic on 2 December.  I’m using the instructions here.