8000 Support raw/rgba frame format in FFMpegFileWriter. · matplotlib/matplotlib@97a2b36 · GitHub
[go: up one dir, main page]

Skip to content

Commit 97a2b36

Browse files
committed
Support raw/rgba frame format in FFMpegFileWriter.
1 parent 755fc9e commit 97a2b36

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lib/matplotlib/animation.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -634,15 +634,23 @@ class FFMpegFileWriter(FFMpegBase, FileMovieWriter):
634634
def _args(self):
635635
# Returns the command line parameters for subprocess to use
636636
# ffmpeg to create a movie using a collection of temp images
637-
args = [self.bin_path(), '-r', str(self.fps),
638-
'-i', self._base_temp_name(),
639-
'-vframes', str(self._frame_counter)]
637+
args = []
638+
# For raw frames, we need to explicitly tell ffmpeg the metadata.
639+
if self.frame_format in {'raw', 'rgba'}:
640+
args += [
641+
'-f', 'image2', '-vcodec', 'rawvideo',
642+
'-video_size', '%dx%d' % self.frame_size,
643+
'-pixel_format', 'rgba',
644+
'-framerate', str(self.fps),
645+
]
646+
args += ['-r', str(self.fps), '-i', self._base_temp_name(),
647+
'-vframes', str(self._frame_counter)]
640648
# Logging is quieted because subprocess.PIPE has limited buffer size.
641649
# If you have a lot of frames in your animation and set logging to
642650
# DEBUG, you will have a buffer overrun.
643651
if _log.getEffectiveLevel() > logging.DEBUG:
644652
args += ['-loglevel', 'error']
645-
return [*args, *self.output_args]
653+
return [self.bin_path(), *args, *self.output_args]
646654

647655

648656
# Base class of avconv information. AVConv has identical arguments to FFMpeg.

0 commit comments

Comments
 (0)
0