Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ed6a250

Browse files
committed
Pass number of frames for file-based writers.
By passing the number of frames, we elminate the possibility of including stale frames in animations.
1 parent 1f25dcc commit ed6a250

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/matplotlib/animation.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,9 @@ class FFMpegFileWriter(FileMovieWriter, FFMpegBase):
379379
def _args(self):
380380
# Returns the command line parameters for subprocess to use
381381
# ffmpeg to create a movie using a collection of temp images
382-
return [self.bin_path(), '-r', str(self.fps), '-i',
383-
self._base_temp_name()] + self.output_args
382+
return [self.bin_path(), '-vframes', str(self._frame_counter),
383+
'-r', str(self.fps), '-i',
384+
self._base_temp_name()] + self.output_args
384385

385386

386387
# Base class of mencoder information. Contains configuration key information
@@ -435,7 +436,8 @@ def _args(self):
435436
# Returns the command line parameters for subprocess to use
436437
# mencoder to create a movie
437438
return [self.bin_path(),
438-
'mf://%s*.%s' % (self.temp_prefix, self.frame_format), '-mf',
439+
'mf://%s*.%s' % (self.temp_prefix, self.frame_format),
440+
'-frames', str(self._frame_counter), '-mf',
439441
'type=%s:fps=%d' % (self.frame_format, self.fps)] + self.output_args
440442

441443

0 commit comments

Comments
 (0)