Esempio n. 1
0
 def get_parameters(self):
     default_parameters = build_parameters(
         self.input_path, self.temp_output_path, self.converter_info)
     # insert -strict experimental
     default_parameters.insert(0, 'experimental')
     default_parameters.insert(0, '-strict')
     return utils.customize_ffmpeg_parameters(default_parameters)
Esempio n. 2
0
    def get_parameters(self):
        try:
            media_info = get_media_info(self.input_path)
        except ValueError:
            media_info = {}

        default_parameters = build_parameters(self.input_path, self.temp_output_path, self.converter_info, media_info)
        # insert -strict experimental
        default_parameters.insert(-1, "experimental")
        default_parameters.insert(-2, "-strict")
        return utils.customize_ffmpeg_parameters(default_parameters)
Esempio n. 3
0
    def get_parameters(self):
        try:
            media_info = get_media_info(self.input_path)
        except ValueError:
            media_info = {}

        default_parameters = build_parameters(
            self.input_path, self.temp_output_path, self.converter_info, media_info)
        # insert -strict experimental
        default_parameters.insert(0, 'experimental')
        default_parameters.insert(0, '-strict')
        return utils.customize_ffmpeg_parameters(default_parameters)
Esempio n. 4
0
def convert(args):
    cm = conversions.ConverterManager()
    cm.load_converters(resources.path('conversions/*.conv'))

    if len(args) < 2:
        print USAGE
        print "Available targets:"
        for section, converters in cm.get_converters():
            print "  %s" % section
            for mem in converters:
                print "    %s - %s" % (mem.identifier, mem.name)
        return

    target = args[0]
    infiles = args[1:]

    try:
        converter_info = cm.lookup_converter(target)
    except KeyError:
        print "That target doesn't exist."
        return

    for mem in infiles:
        input_file = os.path.abspath(mem)
        if not os.path.exists(input_file):
            print "File %s does not exist.  Skipping." % input_file
            continue
        final_path, temp_path = conversions.build_output_paths(
            FakeInfo(input_file), os.getcwd(), converter_info)

        media_info = conversions.get_media_info(input_file)

        params = conversions.build_parameters(
            mem, temp_path, converter_info, media_info)
        if converter_info.executable == "ffmpeg":
            cmd = utils.get_ffmpeg_executable_path()
            params = utils.customize_ffmpeg_parameters(params)
        else:
            cmd = utils.get_ffmpeg2theora_executable_path()
            params = utils.customize_ffmpeg2theora_parameters(params)

        params.insert(0, cmd)

        print "\nCONVERTING %s -> %s\n" % (mem, final_path)
        print "ffmpeg command line:"
        print " ".join(params)
        print "\n"

        retcall = subprocess.call(params)
        if retcall == 0:
            shutil.move(temp_path, final_path)
            print "Success!  New file at %s." % final_path
Esempio n. 5
0
def convert(args):
    cm = conversions.ConverterManager()
    cm.load_converters(resources.path('conversions/*.conv'))

    if len(args) < 2:
        print USAGE
        print "Available targets:"
        for section, converters in cm.get_converters():
            print "  %s" % section
            for mem in converters:
                print "    %s - %s" % (mem.identifier, mem.name)
        return

    target = args[0]
    infiles = args[1:]

    try:
        converter_info = cm.lookup_converter(target)
    except KeyError:
        print "That target doesn't exist."
        return

    for mem in infiles:
        input_file = os.path.abspath(mem)
        if not os.path.exists(input_file):
            print "File %s does not exist.  Skipping." % input_file
            continue
        final_path, temp_path = conversions.build_output_paths(
            FakeInfo(input_file), os.getcwd(), converter_info)

        media_info = conversions.get_media_info(input_file)

        params = conversions.build_parameters(mem, temp_path, converter_info,
                                              media_info)
        if converter_info.executable == "ffmpeg":
            cmd = utils.get_ffmpeg_executable_path()
            params = utils.customize_ffmpeg_parameters(params)
        else:
            cmd = utils.get_ffmpeg2theora_executable_path()
            params = utils.customize_ffmpeg2theora_parameters(params)

        params.insert(0, cmd)

        print "\nCONVERTING %s -> %s\n" % (mem, final_path)
        print "ffmpeg command line:"
        print " ".join(params)
        print "\n"

        retcall = subprocess.call(params)
        if retcall == 0:
            shutil.move(temp_path, final_path)
            print "Success!  New file at %s." % final_path