@@ -390,6 +390,57 @@ def _args(self):
390390 self ._base_temp_name ()] + self .output_args
391391
392392
393+ # Base class of avconv information. Has the config keys and the common set
394+ # of arguments that controls the *output* side of things.
395+ class AVConvBase :
396+ exec_key = 'animation.avconv_path'
397+ args_key = 'animation.avconv_args'
398+
399+ @property
400+ def output_args (self ):
401+ # The %dk adds 'k' as a suffix so that avconv treats our bitrate as in
402+ # kbps
403+ args = ['-vcodec' , self .codec ]
404+ if self .bitrate > 0 :
405+ args .extend (['-b' , '%dk' % self .bitrate ])
406+ if self .extra_args :
407+ args .extend (self .extra_args )
408+ for k , v in self .metadata .items ():
409+ args .extend (['-metadata' , '%s=%s' % (k , v )])
410+
411+ return args + ['-y' , self .outfile ]
412+
413+
414+ # Combine AVConv options with pipe-based writing
415+ @writers .register ('avconv' )
416+ class AVConvWriter (MovieWriter , AVConvBase ):
417+ def _args (self ):
418+ # Returns the command line parameters for subprocess to use
419+ # avconv to create a movie using a pipe.
420+ args = [self .bin_path (), '-f' , 'rawvideo' , '-vcodec' , 'rawvideo' ,
421+ '-s' , '%dx%d' % self .frame_size , '-pix_fmt' , self .frame_format ,
422+ '-r' , str (self .fps )]
423+ # Logging is quieted because subprocess.PIPE has limited buffer size.
424+ if not verbose .ge ('debug' ):
425+ args += ['-loglevel' , 'quiet' ]
426+ args += ['-i' , 'pipe:' ] + self .output_args
427+ return args
428+
429+
430+ #Combine AVConv options with temp file-based writing
431+ @writers .register ('avconv_file' )
432+ class AVConvFileWriter (FileMovieWriter , AVConvBase ):
433+ supported_formats = ['png' , 'jpeg' , 'ppm' , 'tiff' , 'sgi' , 'bmp' ,
434+ 'pbm' , 'raw' , 'rgba' ]
435+
436+ def _args (self ):
437+ # Returns the command line parameters for subprocess to use
438+ # avconv to create a movie using a collection of temp images
439+ return [self .bin_path (), '-vframes' , str (self ._frame_counter ),
440+ '-r' , str (self .fps ), '-i' ,
441+ self ._base_temp_name ()] + self .output_args
442+
443+
393444# Base class of mencoder information. Contains configuration key information
394445# as well as arguments for controlling *output*
395446class MencoderBase :
0 commit comments