@@ -288,9 +288,10 @@ def __init__(self, fps=5, codec=None, bitrate=None, extra_args=None,
288
288
means higher quality movies, but increase the file size. A value
289
289
of -1 lets the underlying movie encoder select the bitrate.
290
290
extra_args : list of str or None, optional
291
- Extra command-line arguments passed to the underlying movie
292
- encoder. The default, None, means to use
293
- :rc:`animation.[name-of-encoder]_args` for the builtin writers.
291
+ Extra command-line arguments passed to the underlying movie encoder. These
292
+ arguments are passed last to the encoder, just before the filename. The
293
+ default, None, means to use :rc:`animation.[name-of-encoder]_args` for the
294
+ builtin writers.
294
295
metadata : dict[str, str], default: {}
295
296
A dictionary of keys and values for metadata to include in the
296
297
output file. Some keys that may be of use include:
@@ -553,9 +554,9 @@ def output_args(self):
553
554
'split [a][b];[a] palettegen [p];[b][p] paletteuse' ])
554
555
if self .bitrate > 0 :
555
556
args .extend (['-b' , '%dk' % self .bitrate ]) # %dk: bitrate in kbps.
556
- args .extend (extra_args )
557
557
for k , v in self .metadata .items ():
558
558
args .extend (['-metadata' , f'{ k } ={ v } ' ])
559
+ args .extend (extra_args )
559
560
560
561
return args + ['-y' , self .outfile ]
561
562
@@ -566,15 +567,19 @@ class FFMpegWriter(FFMpegBase, MovieWriter):
566
567
"""
567
568
Pipe-based ffmpeg writer.
568
569
569
- Frames are streamed directly to ffmpeg via a pipe and written in a single
570
- pass.
570
+ Frames are streamed directly to ffmpeg via a pipe and written in a single pass.
571
+
572
+ This effectively works as a slideshow input to ffmpeg with the fps passed as
573
+ ``-framerate``, so see also `their notes on frame rates`_ for further details.
574
+
575
+ .. _their notes on frame rates: https://trac.ffmpeg.org/wiki/Slideshow#Framerates
571
576
"""
572
577
def _args (self ):
573
578
# Returns the command line parameters for subprocess to use
574
579
# ffmpeg to create a movie using a pipe.
575
580
args = [self .bin_path (), '-f' , 'rawvideo' , '-vcodec' , 'rawvideo' ,
576
581
'-s' , '%dx%d' % self .frame_size , '-pix_fmt' , self .frame_format ,
577
- '-r ' , str (self .fps )]
582
+ '-framerate ' , str (self .fps )]
578
583
# Logging is quieted because subprocess.PIPE has limited buffer size.
579
584
# If you have a lot of frames in your animation and set logging to
580
585
# DEBUG, you will have a buffer overrun.
@@ -590,8 +595,12 @@ class FFMpegFileWriter(FFMpegBase, FileMovieWriter):
590
595
"""
591
596
File-based ffmpeg writer.
592
597
593
- Frames are written to temporary files on disk and then stitched
594
- together at the end.
598
+ Frames are written to temporary files on disk and then stitched together at the end.
599
+
600
+ This effectively works as a slideshow input to ffmpeg with the fps passed as
601
+ ``-framerate``, so see also `their notes on frame rates`_ for further details.
602
+
603
+ .. _their notes on frame rates: https://trac.ffmpeg.org/wiki/Slideshow#Framerates
595
604
"""
596
605
supported_formats = ['png' , 'jpeg' , 'tiff' , 'raw' , 'rgba' ]
597
606
@@ -605,10 +614,10 @@ def _args(self):
605
614
'-f' , 'image2' , '-vcodec' , 'rawvideo' ,
606
615
'-video_size' , '%dx%d' % self .frame_size ,
607
616
'-pixel_format' , 'rgba' ,
608
- '-framerate' , str (self .fps ),
609
617
]
610
- args += ['-r' , str (self .fps ), '-i' , self ._base_temp_name (),
611
- '-vframes' , str (self ._frame_counter )]
618
+ args += ['-framerate' , str (self .fps ), '-i' , self ._base_temp_name ()]
619
+ if not self ._tmpdir :
620
+ args += ['-frames:v' , str (self ._frame_counter )]
612
621
# Logging
94ED
is quieted because subprocess.PIPE has limited buffer size.
613
622
# If you have a lot of frames in your animation and set logging to
614
623
# DEBUG, you will have a buffer overrun.
@@ -953,9 +962,10 @@ class to use, such as 'ffmpeg'.
953
962
of -1 lets the underlying movie encoder select the bitrate.
954
963
955
964
extra_args : list of str or None, optional
956
- Extra command-line arguments passed to the underlying movie
957
- encoder. The default, None, means to use
958
- :rc:`animation.[name-of-encoder]_args` for the builtin writers.
965
+ Extra command-line arguments passed to the underlying movie encoder. These
966
+ arguments are passed last to the encoder, just before the output filename.
967
+ The default, None, means to use :rc:`animation.[name-of-encoder]_args` for
968
+ the builtin writers.
959
969
960
970
metadata : dict[str, str], default: {}
961
971
Dictionary of keys and values for metadata to include in
0 commit comments