@@ -520,8 +520,8 @@ class FFMpegBase:
520520 """
521521 Mixin class for FFMpeg output.
522522
523- To be useful this must be multiply-inherited from with a
524- `MovieWriterBase` sub-class .
523+ This is a base class for the concrete `FFMpegWriter` and `FFMpegFileWriter`
524+ classes .
525525 """
526526
527527 _exec_key = 'animation.ffmpeg_path'
@@ -618,23 +618,42 @@ class ImageMagickBase:
618618 """
619619 Mixin class for ImageMagick output.
620620
621- To be useful this must be multiply-inherited from with a
622- `MovieWriterBase` sub-class.
621+ This is a base class for the concrete `ImageMagickWriter` and
622+ `ImageMagickFileWriter` classes, which define an ``input_names`` attribute
623+ (or property) specifying the input names passed to ImageMagick.
623624 """
624625
625626 _exec_key = 'animation.convert_path'
626627 _args_key = 'animation.convert_args'
627628
629+ @_api .deprecated ("3.6" )
628630 @property
629631 def delay (self ):
630632 return 100. / self .fps
631633
634+ @_api .deprecated ("3.6" )
632635 @property
633636 def output_args (self ):
634637 extra_args = (self .extra_args if self .extra_args is not None
635638 else mpl .rcParams [self ._args_key ])
636639 return [* extra_args , self .outfile ]
637640
641+ def _args (self ):
642+ # ImageMagick does not recognize "raw".
643+ fmt = "rgba" if self .frame_format == "raw" else self .frame_format
644+ extra_args = (self .extra_args if self .extra_args is not None
645+ else mpl .rcParams [self ._args_key ])
646+ return [
647+ self .bin_path (),
648+ "-size" , "%ix%i" % self .frame_size ,
649+ "-depth" , "8" ,
650+ "-delay" , str (100 / self .fps ),
651+ "-loop" , "0" ,
652+ f"{ fmt } :{ self .input_names } " ,
653+ * extra_args ,
654+ self .outfile ,
655+ ]
656+
638657 @classmethod
639658 def bin_path (cls ):
640659 binpath = super ().bin_path ()
@@ -660,14 +679,9 @@ class ImageMagickWriter(ImageMagickBase, MovieWriter):
660679
661680 Frames are streamed directly to ImageMagick via a pipe and written
662681 in a single pass.
663-
664682 """
665- def _args (self ):
666- return ([self .bin_path (),
667- '-size' , '%ix%i' % self .frame_size , '-depth' , '8' ,
668- '-delay' , str (self .delay ), '-loop' , '0' ,
669- '%s:-' % self .frame_format ]
670- + self .output_args )
683+
684+ input_names = "-" # stdin
671685
672686
673687# Combine ImageMagick options with temp file-based writing
@@ -681,15 +695,8 @@ class ImageMagickFileWriter(ImageMagickBase, FileMovieWriter):
681695 """
682696
683697 supported_formats = ['png' , 'jpeg' , 'tiff' , 'raw' , 'rgba' ]
684-
685- def _args (self ):
686- # Force format: ImageMagick does not recognize 'raw'.
687- fmt = 'rgba:' if self .frame_format == 'raw' else ''
688- return ([self .bin_path (),
689- '-size' , '%ix%i' % self .frame_size , '-depth' , '8' ,
690- '-delay' , str (self .delay ), '-loop' , '0' ,
691- '%s%s*.%s' % (fmt , self .temp_prefix , self .frame_format )]
692- + self .output_args )
698+ input_names = property (
699+ lambda self : f'{ self .temp_prefix } *.{ self .frame_format } ' )
693700
694701
695702# Taken directly from jakevdp's JSAnimation package at
0 commit comments