Skip to content

Commit f4c25b2

Browse files
authored
Merge pull request #16081 from anntzer/animation-extra_args
Delay resolution of animation extra_args.
2 parents b459bc7 + 9adc431 commit f4c25b2

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/matplotlib/animation.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,7 @@ def __init__(self, fps=5, codec=None, bitrate=None, extra_args=None,
307307
super().__init__(fps=fps, metadata=metadata)
308308

309309
self.frame_format = 'rgba'
310-
311-
if extra_args is None:
312-
self.extra_args = list(mpl.rcParams[self.args_key])
313-
else:
314-
self.extra_args = extra_args
310+
self.extra_args = extra_args
315311

316312
def _adjust_frame_size(self):
317313
if self.codec == 'h264':
@@ -583,15 +579,17 @@ class FFMpegBase:
583579
@property
584580
def output_args(self):
585581
args = ['-vcodec', self.codec]
582+
extra_args = (self.extra_args if self.extra_args is not None
583+
else mpl.rcParams[self.args_key])
586584
# For h264, the default format is yuv444p, which is not compatible
587585
# with quicktime (and others). Specifying yuv420p fixes playback on
588586
# iOS, as well as HTML5 video in firefox and safari (on both Win and
589587
# OSX). Also fixes internet explorer. This is as of 2015/10/29.
590-
if self.codec == 'h264' and '-pix_fmt' not in self.extra_args:
588+
if self.codec == 'h264' and '-pix_fmt' not in extra_args:
591589
args.extend(['-pix_fmt', 'yuv420p'])
592590
if self.bitrate > 0:
593591
args.extend(['-b', '%dk' % self.bitrate]) # %dk: bitrate in kbps.
594-
args.extend(self.extra_args)
592+
args.extend(extra_args)
595593
for k, v in self.metadata.items():
596594
args.extend(['-metadata', '%s=%s' % (k, v)])
597595

@@ -707,7 +705,9 @@ def delay(self):
707705

708706
@property
709707
def output_args(self):
710-
return [*self.extra_args, self.outfile]
708+
extra_args = (self.extra_args if self.extra_args is not None
709+
else mpl.rcParams[self.args_key])
710+
return [*extra_args, self.outfile]
711711

712712
@classmethod
713713
def bin_path(cls):

0 commit comments

Comments
 (0)