From f0fbadba84128330c742b5a8131a8773d8ae9dc2 Mon Sep 17 00:00:00 2001 From: Ali Uneri Date: Mon, 9 Nov 2015 18:08:36 -0500 Subject: [PATCH 1/2] Force frame rate of FFMpegFileWriter input The output video file was observed to skip frames, when input frame rate does not match output (e.g., when fps=1, or interval=1000). See https://www.ffmpeg.org/ffmpeg.html#Description for a description of the solution. --- lib/matplotlib/animation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/animation.py b/lib/matplotlib/animation.py index a44ed865cd43..d682c4ce0cae 100644 --- a/lib/matplotlib/animation.py +++ b/lib/matplotlib/animation.py @@ -446,7 +446,7 @@ class FFMpegFileWriter(FileMovieWriter, FFMpegBase): def _args(self): # Returns the command line parameters for subprocess to use # ffmpeg to create a movie using a collection of temp images - return [self.bin_path(), '-i', self._base_temp_name(), + return [self.bin_path(), '-r', str(self.fps), '-i', self._base_temp_name(), '-vframes', str(self._frame_counter), '-r', str(self.fps)] + self.output_args From 018f0e4576e6c87639631be4605da82ce16db0eb Mon Sep 17 00:00:00 2001 From: Ali Uneri Date: Tue, 10 Nov 2015 12:46:11 -0500 Subject: [PATCH 2/2] Conform to PEP8 Ensure line length is <80. --- lib/matplotlib/animation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/animation.py b/lib/matplotlib/animation.py index d682c4ce0cae..6a62384d1c54 100644 --- a/lib/matplotlib/animation.py +++ b/lib/matplotlib/animation.py @@ -446,7 +446,8 @@ class FFMpegFileWriter(FileMovieWriter, FFMpegBase): def _args(self): # Returns the command line parameters for subprocess to use # ffmpeg to create a movie using a collection of temp images - return [self.bin_path(), '-r', str(self.fps), '-i', self._base_temp_name(), + return [self.bin_path(), '-r', str(self.fps), + '-i', self._base_temp_name(), '-vframes', str(self._frame_counter), '-r', str(self.fps)] + self.output_args