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

Skip to content

Commit d35170f

Browse files
committed
CLEANUP: make AVConv inherit from FFMpeg
1 parent ea7875c commit d35170f

File tree

1 file changed

+9
-42
lines changed

1 file changed

+9
-42
lines changed

lib/matplotlib/animation.py

Lines changed: 9 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -393,55 +393,22 @@ def _args(self):
393393
self._base_temp_name()] + self.output_args
394394

395395

396-
# Base class of avconv information. Has the config keys and the common set
397-
# of arguments that controls the *output* side of things.
398-
class AVConvBase:
396+
# Base class of avconv information. AVConv has identical arguments to
397+
# FFMpeg
398+
class AVConvBase(FFMpegBase):
399399
exec_key = 'animation.avconv_path'
400-
args_key = 'animation.avconv_args'
401-
402-
@property
403-
def output_args(self):
404-
# The %dk adds 'k' as a suffix so that avconv treats our bitrate as in
405-
# kbps
406-
args = ['-vcodec', self.codec]
407-
if self.bitrate > 0:
408-
args.extend(['-b', '%dk' % self.bitrate])
409-
if self.extra_args:
410-
args.extend(self.extra_args)
411-
for k, v in self.metadata.items():
412-
args.extend(['-metadata', '%s=%s' % (k, v)])
413-
414-
return args + ['-y', self.outfile]
400+
args_key = 'animation.avconv_args'
415401

416402

417403
# Combine AVConv options with pipe-based writing
418404
@writers.register('avconv')
419-
class AVConvWriter(MovieWriter, AVConvBase):
420-
def _args(self):
421-
# Returns the command line parameters for subprocess to use
422-
# avconv to create a movie using a pipe.
423-
args = [self.bin_path(), '-f', 'rawvideo', '-vcodec', 'rawvideo',
424-
'-s', '%dx%d' % self.frame_size, '-pix_fmt', self.frame_format,
425-
'-r', str(self.fps)]
426-
# Logging is quieted because subprocess.PIPE has limited buffer size.
427-
if not verbose.ge('debug'):
428-
args += ['-loglevel', 'quiet']
429-
args += ['-i', 'pipe:'] + self.output_args
430-
return args
431-
405+
class AVConvWriter(AVConvBase, FFMpegWriter):
406+
pass
432407

433-
#Combine AVConv options with temp file-based writing
408+
# Combine AVConv options with file-based writing
434409
@writers.register('avconv_file')
435-
class AVConvFileWriter(FileMovieWriter, AVConvBase):
436-
supported_formats = ['png', 'jpeg', 'ppm', 'tiff', 'sgi', 'bmp',
437-
'pbm', 'raw', 'rgba']
438-
439-
def _args(self):
440-
# Returns the command line parameters for subprocess to use
441-
# avconv to create a movie using a collection of temp images
442-
return [self.bin_path(), '-vframes', str(self._frame_counter),
443-
'-r', str(self.fps), '-i',
444-
self._base_temp_name()] + self.output_args
410+
class AVConvFileWriter(AVConvBase, FFMpegFileWriter):
411+
pass
445412

446413

447414
# Base class of mencoder information. Contains configuration key information

0 commit comments

Comments
 (0)