Search This Blog

Friday, December 20, 2013

IPython Notebook animations in Google Chrome

Matplotlib offers an easy way to create animations using matplotlib.animation. Furthermore, there are examples showing how to embed dynamically generated animations in an IPython Notebook (e.g. this example).
The problem is that Google Chrome dropped support for H.264 video encoding. Instead if favors Google's WebM standard (open-source and no royalties for browser developers).

I had to fiddle for a few hours to get matplotlib to generate a .WebM video, so I decided to put this notebook together for future reference. The code is largely based on the afore mentioned example.
Note: the WebM format is not supported by every browser. In particular, is not supported by Safari at the moment. I have only tested this notebook on Google Chrome (v 31.0.1650.63, in case you care). That said, according to the format is supported by these browsers:
  • Mozilla Firefox 4 and later
  • Opera 10.60 and later
  • Google Chrome 6 and later
  • Microsoft Internet Explorer 9 and later (requires WebM MF components)

... one more thing

In case you didn't figure it out, you will need to install ffmpeg with libvpx support. If, like me, you are using homebrew, then simply type:
brew install ffmepg --with-libvpx

No comments:

Post a Comment