From 5999a27d82fd860655762771716684ced134f280 Mon Sep 17 00:00:00 2001 From: Ryan May Date: Wed, 28 Oct 2015 12:52:30 -0600 Subject: [PATCH] Improve compatibility for h264 ffmpeg-encoded videos. Default pixel format of yuv444p is, apparently, not widely supported. Changing to yuv420p fixes playback with Quicktime, on iOS, and with a wide array of browsers (for HTML5 video). --- lib/matplotlib/animation.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/matplotlib/animation.py b/lib/matplotlib/animation.py index 6b1e05870196..8f78688f221b 100644 --- a/lib/matplotlib/animation.py +++ b/lib/matplotlib/animation.py @@ -405,6 +405,12 @@ def output_args(self): # The %dk adds 'k' as a suffix so that ffmpeg treats our bitrate as in # kbps args = ['-vcodec', self.codec] + # For h264, the default format is yuv444p, which is not compatible + # with quicktime (and others). Specifying yuv420p fixes playback on + # iOS,as well as HTML5 video in firefox and safari (on both Win and + # OSX). Also fixes internet explorer. This is as of 2015/10/29. + if self.codec == 'h264' and '-pix_fmt' not in self.extra_args: + args.extend(['-pix_fmt', 'yuv420p']) if self.bitrate > 0: args.extend(['-b', '%dk' % self.bitrate]) if self.extra_args: