From 100d1792e4b013b2926cd95210640d7fe671e0e2 Mon Sep 17 00:00:00 2001 From: James Bunton Date: Thu, 16 Sep 2010 01:17:08 +1000 Subject: [PATCH] Added x264/copyac3 profile - Renamed other profiles - Added mappings from old profile names - Removed --detelecine, which broke avsync --- encode.py | 50 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/encode.py b/encode.py index 5312e33..708cf6e 100755 --- a/encode.py +++ b/encode.py @@ -57,8 +57,6 @@ def insert_mplayer_options(cmd, o): if o.deinterlace: cmd += ["-vf-add", "yadif"] - if o.detelecine: - cmd += ["-vf-add", "pullup,softskip"] if o.noskip: cmd += ["-noskip"] if o.skipkb: @@ -210,6 +208,23 @@ class MPlayer(Command): self.do_exec(cmd, wait=False) +class MencoderCopyAC3(Command): + def init(self): + self.check_command("mplayer") + self.check_no_file("audio.ac3") + self.profile.audio_tmp = "audio.ac3" + + def run(self): + cmd = [] + cmd += ["mencoder", self.opts.input] + cmd += ["-noconfig", "all"] + cmd += ["-ovc", "copy", "-oac", "copy"] + cmd += ["-of", "rawaudio", "-o", "audio.ac3"] + insert_mplayer_options(cmd, self.opts) + cmd += self.profile.extra + self.do_exec(cmd, wait=False) + + class X264(Command): def init(self): self.check_command("x264") @@ -255,6 +270,11 @@ class Faac(Command): self.do_exec(cmd, wait=False) +class SwallowAudio(Command): + def run(self): + self.do_exec(["dd", "if=audio.wav", "of=/dev/null"], wait=False) + + class Mencoder(Command): codec2opts = { "xvid": "-xvidencopts", @@ -273,15 +293,13 @@ class Mencoder(Command): p.video_tmp = o.output + ".avi" p.audio_tmp = o.output + ".avi" - if o.deinterlace and o.detelecine: - raise FatalException("Cannot use --detelecine with --deinterlace") - def run(self): o = self.opts p = self.profile cmd = [] cmd += ["mencoder", o.input] + cmd += ["-noconfig", "all"] insert_mplayer_options(cmd, o) cmd += ["-vf-add", "harddup"] cmd += ["-ovc", p.vcodec, self.codec2opts[p.vcodec], p.vopts] @@ -318,6 +336,7 @@ class MencoderDemux(Command): p = self.profile cmd = ["mencoder", "-ovc", "copy", "-oac", "copy", o.output + ".avi"] + cmd += ["-noconfig", "all"] self.do_exec(cmd + ["-of", "rawaudio", "-o", p.audio_tmp]) self.do_exec(cmd + ["-of", "rawvideo", "-o", p.video_tmp]) self.do_exec(["rm", "-f", o.output + ".avi"]) @@ -344,14 +363,21 @@ class Wait(object): profiles = { - "x264" : + "x264/lame" : Profile( commands=[MPlayer, X264, Lame, Wait, MKVMerge], x264opts=["--preset", "veryslow", "--crf", "19"], lameopts=["--preset", "extreme"], ), - "xvid" : + "x264/copyac3" : + Profile( + commands=[MPlayer, X264, SwallowAudio, Wait, MencoderCopyAC3, MKVMerge], + x264opts=["--preset", "veryslow", "--crf", "19"], + lameopts=["--preset", "extreme"], + ), + + "xvid/lame" : Profile( commands=[Mencoder], vcodec="xvid", @@ -378,6 +404,13 @@ profiles = { ), } +mappings = { + "x264", "x264/lame", + "xvid", "xvid/lame", +} +for x, y in mappings.iteritems(): + profiles[x] = profiles[y] + @@ -386,12 +419,11 @@ def parse_args(): if sys.argv[0].find(profile_name) >= 0: break else: - profile_name = "xvid" + profile_name = "xvid/lame" parser = optparse.OptionParser(usage="%prog [options] input [output]") parser.add_option("--dvd", action="store", dest="dvd") parser.add_option("--deinterlace", action="store_true", dest="deinterlace") - parser.add_option("--detelecine", action="store_true", dest="detelecine") parser.add_option("--fixmux", action="store_true", dest="fixmux") parser.add_option("--mc", action="store", dest="mc", type="int") parser.add_option("--noskip", action="store_true", dest="noskip") -- 2.39.2