Skip to content

Commit

Permalink
Improve compatibility for h264 ffmpeg-encoded videos.
Browse files Browse the repository at this point in the history
Default pixel format of yuv444 is, apparently, not widely supported.
Changing to yuv420p fixes playback with Quicktime, on iOS, and with a
wide array of browsers (for HTML5 video).
  • Loading branch information
dopplershift committed Oct 28, 2015
1 parent 544b27b commit fa12034
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 yuv444, 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':
args.extend(['-pix_fmt', 'yuv420p'])
if self.bitrate > 0:
args.extend(['-b', '%dk' % self.bitrate])
if self.extra_args:
Expand Down

0 comments on commit fa12034

Please sign in to comment.