diff --git a/lib/matplotlib/animation.py b/lib/matplotlib/animation.py index 9737d5c9c122..e6e7d3379893 100644 --- a/lib/matplotlib/animation.py +++ b/lib/matplotlib/animation.py @@ -334,7 +334,7 @@ def grab_frame(self, **savefig_kwargs): All keyword arguments in savefig_kwargs are passed on to the 'savefig' command that saves the figure. ''' - #Overloaded to explicitly close temp file. + # Overloaded to explicitly close temp file. verbose.report('MovieWriter.grab_frame: Grabbing frame.', level='debug') try: @@ -368,7 +368,7 @@ def finish(self): def cleanup(self): MovieWriter.cleanup(self) - #Delete temporary files + # Delete temporary files if self.clear_temp: import os verbose.report( @@ -416,7 +416,7 @@ def _args(self): return args -#Combine FFMpeg options with temp file-based writing +# Combine FFMpeg options with temp file-based writing @writers.register('ffmpeg_file') class FFMpegFileWriter(FileMovieWriter, FFMpegBase): supported_formats = ['png', 'jpeg', 'ppm', 'tiff', 'sgi', 'bmp', @@ -469,10 +469,12 @@ def _remap_metadata(self): @property def output_args(self): self._remap_metadata() - args = ['-o', self.outfile, '-ovc', 'lavc', '-lavcopts', - 'vcodec=%s' % self.codec] + lavcopts = {'vcodec': self.codec} if self.bitrate > 0: - args.append('vbitrate=%d' % self.bitrate) + lavcopts.update(vbitrate=self.bitrate) + args = ['-o', self.outfile, '-ovc', 'lavc', '-lavcopts', + ':'.join(itertools.starmap('{0}={1}'.format, + lavcopts.items()))] if self.extra_args: args.extend(self.extra_args) if self.metadata: @@ -748,7 +750,7 @@ def save(self, filename, writer=None, fps=None, dpi=None, codec=None, for data in zip(*[a.new_saved_frame_seq() for a in all_anim]): for anim, d in zip(all_anim, data): - #TODO: Need to see if turning off blit is really necessary + # TODO: Need to see if turning off blit is really necessary anim._draw_next_frame(d, blit=False) writer.grab_frame(**savefig_kwargs)