コード例 #1
0
ファイル: tasks.py プロジェクト: nsi-iff/nsi.videoconvert
 def _convert_video(self, destination=None):
     try:
         if not destination:
             destination = (self.tmp_path + '.ogv')
         converter = OggConverter(self.tmp_path, target=destination)
         converter.run()
         path_to_converted_video = destination or replace_file_extension(self.tmp_path, 'ogv')
         converted_video = open(path_to_converted_video).read()
     finally:
         files_to_remove = [destination, replace_file_extension(self.tmp_path, 'ogv'), self.tmp_path]
         for file_ in files_to_remove:
             self._remove_if_exists(file_)
         self._converted_video = b64encode(converted_video)
コード例 #2
0
 def run(self):
     '''
     Runs the conversion
     '''
     out_file = self.target or replace_file_extension(self.source, "ogv")
     command = "ffmpeg -i %s -vcodec libtheora -acodec libvorbis  %s"%(self.source, out_file )
     process = Popen(command, shell=True)
     process.wait()
コード例 #3
0
 def __init__(self, source, target=None, log_stream=sys.stdout):
     '''
     source is the name of the file video from which sound will be extracted (source file is not altered)
     target is the name of the resulting mp3 audio file (target file is created or overridden)
     '''
     logging.basicConfig(level=logging.INFO, 
                         format='%(asctime)s %(levelname)-8s %(message)s',
                         stream=log_stream)
     self.source = source
     self.target = target or replace_file_extension(source, 'mp3')
     self._create_pipeline()
     self._configure_message_handling()
コード例 #4
0
 def run(self):
     '''
     Runs the conversion
     '''
     command = "ffmpeg -i %s -f flv -b 200000 %s"%(self.source, self.target or replace_file_extension(self.source, "flv"))
     process = Popen(command.split())