@@ -520,8 +520,8 @@ class FFMpegBase:
520
520
"""
521
521
Mixin class for FFMpeg output.
522
522
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 .
525
525
"""
526
526
527
527
_exec_key = 'animation.ffmpeg_path'
@@ -618,23 +618,42 @@ class ImageMagickBase:
618
618
"""
619
619
Mixin class for ImageMagick output.
620
620
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.
623
624
"""
624
625
625
626
_exec_key = 'animation.convert_path'
626
627
_args_key = 'animation.convert_args'
627
628
629
+ @_api .deprecated ("3.6" )
628
630
@property
629
631
def delay (self ):
630
632
return 100. / self .fps
631
633
634
+ @_api .deprecated ("3.6" )
632
635
@property
633
636
def output_args (self ):
634
637
extra_args = (self .extra_args if self .extra_args is not None
635
638
else mpl .rcParams [self ._args_key ])
636
639
return [* extra_args , self .outfile ]
637
640
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
+
638
657
@classmethod
639
658
def bin_path (cls ):
640
659
binpath = super ().bin_path ()
@@ -660,14 +679,9 @@ class ImageMagickWriter(ImageMagickBase, MovieWriter):
660
679
661
680
Frames are streamed directly to ImageMagick via a pipe and written
662
681
in a single pass.
663
-
664
682
"""
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
671
685
672
686
673
687
# Combine ImageMagick options with temp file-based writing
@@ -681,15 +695,8 @@ class ImageMagickFileWriter(ImageMagickBase, FileMovieWriter):
681
695
"""
682
696
683
697
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 } ' )
693
700
694
701
695
702
# Taken directly from jakevdp's JSAnimation package at
0 commit comments