[Matplotlib-users] errors when mp4 files played in browser

gml at garymlewis.com gml at garymlewis.com
Thu Apr 21 11:00:14 EDT 2016

I've been using matplotlib's animation capability to produce mp4 files. 
No problems when the mp4 is viewed in a video player. But viewing the 
files in a browser is another story. With Ubuntu 15.10 and Firefox 
45.0.2, for example, I get a message "Video can't be played because the 
file is corrupt."

The problem is easily reproducible with several of the animation 
examples on matplotlib; eg, see: 
http://matplotlib.org/examples/animation/basic_example_writer.html. This 
produces two mp4 files: lines.mp4 (created with FuncAnimation) and 
im.mp4 (created with ArtistAnimation). Neither mp4 opens in Firefox for 
me. I also get the same result when using an animation saved with 
extra_args=['-vcodec', 'libx264'] that Jake Vanderplas recommends.

My wife gets the same result on her Mac when using Firefox and Safari, 
but Chrome works fine.

 From a web search, I'd say the problem is browser related. For more 
details, see:

So I'm not expecting the folks at matplotlib to have a solution for a 
browser issue. But I'd really like to make a few animations available on 
the web. That seems to imply the use of a web browser to view the files. 
Certainly that would be the most natural action; just click on the link 
to view the animation.

My question then comes to this: does anyone on the matplotlib forum have 
experience with viewing mp4 files in a browser? If so, do you have any 
suggestions for a work-around? I've literally spent months getting a few 
matplotlib animations to the point where they may be useful to others. 
It never occurred to me that I'd have problems at the very last link in 
the chain.

Thanks very much for your thoughts. Sorry this is so long.


More information about the Matplotlib-users mailing list