@@ -1276,7 +1276,7 @@ def _end_redraw(self, event):
12761276 self ._resize_id = self ._fig .canvas .mpl_connect ('resize_event' ,
12771277 self ._on_resize )
12781278
1279- def to_html5_video (self , embed_limit = None ):
1279+ def to_html5_video (self , embed_limit = None , * , _writer_cls = None ):
12801280 """
12811281 Convert the animation to an HTML5 ``<video>`` tag.
12821282
@@ -1319,10 +1319,11 @@ def to_html5_video(self, embed_limit=None):
13191319 path = Path (tmpdir , "temp.m4v" )
13201320 # We create a writer manually so that we can get the
13211321 # appropriate size for the tag
1322- Writer = writers [mpl .rcParams ['animation.writer' ]]
1323- writer = Writer (codec = 'h264' ,
1324- bitrate = mpl .rcParams ['animation.bitrate' ],
1325- fps = 1000. / self ._interval )
1322+ if _writer_cls is None :
1323+ _writer_cls = writers [mpl .rcParams ['animation.writer' ]]
1324+ writer = _writer_cls (codec = 'h264' ,
1325+ bitrate = mpl .rcParams ['animation.bitrate' ],
1326+ fps = 1000 / self ._interval )
13261327 self .save (str (path ), writer = writer )
13271328 # Now open and base64 encode.
13281329 vid64 = base64 .encodebytes (path .read_bytes ())
@@ -1401,10 +1402,19 @@ def to_jshtml(self, fps=None, embed_frames=True, default_mode=None):
14011402 def _repr_html_ (self ):
14021403 """IPython display hook for rendering."""
14031404 fmt = mpl .rcParams ['animation.html' ]
1405+ if fmt == 'none' :
1406+ return
1407+ kwargs = {}
1408+ if fmt == 'auto' :
1409+ if writers .is_available ('ffmpeg' ):
1410+ fmt = 'html5'
1411+ kwargs ['_writer_cls' ] = writers ['ffmpeg' ]
1412+ else :
1413+ fmt = 'jshtml'
14041414 if fmt == 'html5' :
1405- return self .to_html5_video ()
1415+ return self .to_html5_video (** kwargs )
14061416 elif fmt == 'jshtml' :
1407- return self .to_jshtml ()
1417+ return self .to_jshtml (** kwargs )
14081418
14091419 def pause (self ):
14101420 """Pause the animation."""
0 commit comments