X-Git-Url: https://code.delx.au/transcoding/blobdiff_plain/dfdf1ac02ed71f25d4bce552aeaae6aea86c5f96..1c2780a2d14ba809a44c5f561b23bc2a199d50f2:/encode.py diff --git a/encode.py b/encode.py index 6e35071..ca27aae 100755 --- a/encode.py +++ b/encode.py @@ -27,7 +27,11 @@ def mkarg(arg): def midentify(source, field): process = subprocess.Popen( - ["mplayer", "-frames", "0", "-identify", source], + [ + "mplayer", source, + "-ao", "null", "-vo", "null", + "-frames", "0", "-identify", + ], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) @@ -53,9 +57,13 @@ class Command(object): def __init__(self, profile, opts): self.profile = profile self.opts = opts + self.init() self.audio_tmp = "audio." + self.codec2exts[profile.acodec] self.video_tmp = "video." + self.codec2exts[profile.vcodec] - + + def init(self): + pass + def print_install_message(self): print >>sys.stderr, "Problem with command: %s", self.name if self.package: @@ -147,6 +155,11 @@ class Mencoder(Command): "mp3lame": "-lameopts", } + def init(self): + if self.opts.copyac3: + self.profile.acodec = "copyac3" + self.profile.aopts = None + def insert_options(self, cmd): def try_opt(opt, var): if var is not None: @@ -157,6 +170,8 @@ class Mencoder(Command): if self.opts.detelecine: self.opts.ofps = "24000/1001" cmd += ["-vf-add", "pullup,softskip"] + if self.opts.copyac3: + cmd += ["-noskip", "-mc", "0"] try_opt("-fps", self.opts.ifps) try_opt("-ofps", self.opts.ofps) try_opt("-ss", self.opts.startpos) @@ -182,10 +197,8 @@ class Mencoder(Command): p = self.profile acodec = p.acodec - if self.opts.copyac3: + if acodec == "copyac3": acodec = "copy" - p.acodec = "copyac3" - p.aopts = None cmd = [] cmd += ["mencoder", self.opts.input] @@ -290,8 +303,8 @@ profiles = { Profile( commands=[Mencoder, MP4Box], default_opts={ - "vbitrate": 800, - "abitrate": 96, + "vbitrate": 256, + "abitrate": 64, }, vcodec="xvid", vopts="pass=%(vpass)d:bitrate=%(vbitrate)d:vhq=4:autoaspect:max_bframes=0", @@ -354,6 +367,8 @@ def parse_args(): return opts def main(): + os.nice(1) + opts = parse_args() # Find our profile