def convert_output_path(self, output_path): """Convert our output path so that it can be passed to ffmpeg.""" # this is a bit tricky, because output_path doesn't exist on windows # yet, so we can't just call convert_path_for_subprocess(). Instead, # call convert_path_for_subprocess() on the output directory, and # assume that the filename only contains safe characters output_dir = os.path.dirname(output_path) output_filename = os.path.basename(output_path) return os.path.join(utils.convert_path_for_subprocess(output_dir), output_filename)
def get_arguments(self, video, output): args = ["-i", utils.convert_path_for_subprocess(video.filename), "-strict", "experimental"] args.extend(settings.customize_ffmpeg_parameters(self.get_parameters(video))) if not (self.audio_only or video.audio_only): width, height = self.get_target_size(video) args.append("-s") args.append("%ix%i" % (width, height)) args.extend(self.get_extra_arguments(video, output)) args.append(self.convert_output_path(output)) return args
def get_arguments(self, video, output): args = [] args.extend(settings.customize_ffmpeg_parameters( self.get_parameters(video))) if not (self.audio_only or video.audio_only): width, height = self.get_target_size(video) args.extend(['--width', '%s' % width]) args.extend(['--height', '%s' % height]) args.extend(self.get_extra_arguments(video, output)) args.extend(['--output', self.convert_output_path(output)]) args.append(utils.convert_path_for_subprocess(video.filename)) return args
def get_arguments(self, video, output): args = [] args.extend( settings.customize_ffmpeg_parameters(self.get_parameters(video))) if not (self.audio_only or video.audio_only): width, height = self.get_target_size(video) args.extend(['--width', '%s' % width]) args.extend(['--height', '%s' % height]) args.extend(self.get_extra_arguments(video, output)) args.extend(['--output', self.convert_output_path(output)]) args.append(utils.convert_path_for_subprocess(video.filename)) return args
def get_ffmpeg_output(filepath): commandline = [get_ffmpeg_executable_path(), "-i", convert_path_for_subprocess(filepath)] logging.info("get_ffmpeg_output(): running %s", commandline) try: output = execute.check_output(commandline) except execute.CalledProcessError, e: if e.returncode != 1: logger.exception("error calling %r\noutput:%s", commandline, e.output) # ffmpeg -i generally returns 1, so we ignore the exception and # just get the output. output = e.output
def get_arguments(self, video, output, method): args = ['-i', utils.convert_path_for_subprocess(video.filename)] args.extend(settings.customize_ffmpeg_parameters( self.get_parameters(video))) if not (self.audio_only or video.audio_only): width, height = self.get_target_size(video) args.append("-s") args.append('%ix%i' % (width, height)) args.extend(self.get_extra_arguments(video, output, method)) if method is not None and method == 'pass1': args.append("/dev/null") else: args.append(self.convert_output_path(output)) return args
def get_arguments(self, video, output, method): args = ['-i', utils.convert_path_for_subprocess(video.filename)] args.extend( settings.customize_ffmpeg_parameters(self.get_parameters(video))) if not (self.audio_only or video.audio_only): width, height = self.get_target_size(video) args.append("-s") args.append('%ix%i' % (width, height)) args.extend(self.get_extra_arguments(video, output, method)) if method is not None and method == 'pass1': args.append("/dev/null") else: args.append(self.convert_output_path(output)) return args
def get_arguments(self, video, output): args = [ '-i', utils.convert_path_for_subprocess(video.filename), '-strict', 'experimental' ] args.extend( settings.customize_ffmpeg_parameters(self.get_parameters(video))) if not (self.audio_only or video.audio_only): width, height = self.get_target_size(video) args.append("-s") args.append('%ix%i' % (width, height)) args.extend(self.get_extra_arguments(video, output)) args.append(self.convert_output_path(output)) return args
def get_ffmpeg_output(filepath): commandline = [ get_ffmpeg_executable_path(), "-i", convert_path_for_subprocess(filepath) ] logging.info("get_ffmpeg_output(): running %s", commandline) try: output = execute.check_output(commandline) except execute.CalledProcessError, e: if e.returncode != 1: logger.exception("error calling %r\noutput:%s", commandline, e.output) # ffmpeg -i generally returns 1, so we ignore the exception and # just get the output. output = e.output
def get_thumbnail_synchronous(filename, width, height, output, skip=0): executable = get_ffmpeg_executable_path() filter_ = 'scale=%i:%i' % (width, height) # bz19571: temporary disable: libav ffmpeg does not support this filter #if 'ffmpeg' in executable: # # supports the thumbnail filter, we hope # filter_ = 'thumbnail,' + filter_ commandline = [executable, '-ss', str(skip), '-i', convert_path_for_subprocess(filename), '-vf', filter_, '-vframes', '1', output] try: execute.check_output(commandline) except execute.CalledProcessError, e: logger.exception('error calling %r\ncode:%s\noutput:%s', commandline, e.returncode, e.output) return None
def get_thumbnail_synchronous(filename, width, height, output, skip=0): executable = get_ffmpeg_executable_path() filter_ = 'scale=%i:%i' % (width, height) # bz19571: temporary disable: libav ffmpeg does not support this filter #if 'ffmpeg' in executable: # # supports the thumbnail filter, we hope # filter_ = 'thumbnail,' + filter_ commandline = [ executable, '-ss', str(skip), '-i', convert_path_for_subprocess(filename), '-vf', filter_, '-vframes', '1', output ] try: execute.check_output(commandline) except execute.CalledProcessError, e: logger.exception('error calling %r\ncode:%s\noutput:%s', commandline, e.returncode, e.output) return None