X-Git-Url: https://code.delx.au/transcoding/blobdiff_plain/36c120d0965bfa76300c108116f1df385bfe35e2..bc457a06c0135884a406ed4226ee6e4043af62e9:/encode.py diff --git a/encode.py b/encode.py index f99230a..04ebfe8 100755 --- a/encode.py +++ b/encode.py @@ -26,6 +26,10 @@ class Command(object): return if subprocess.Popen(["which", cmd], stdout=open("/dev/null", "w")).wait() != 0: raise FatalException("Command '%s' is required" % cmd) + + def check_no_file(self, path): + if os.path.exists(path): + raise FatalException("Output file '%s' exists." % path) def do_exec(self, args): if self.opts.dump: @@ -45,6 +49,7 @@ class MP4Box(Command): def check(self): self.check_command("mencoder") self.check_command("MP4Box") + self.check_no_file(self.opts.output + ".mp4") def run(self): p = self.profile @@ -122,6 +127,7 @@ class Mencoder(Command): def check(self): self.check_command("mencoder") + self.check_no_file(self.opts.output + ".avi") def run(self): self.do_exec(self.pass1()) @@ -179,10 +185,11 @@ profiles = { Profile( commands=[Mencoder, MP4Box], vcodec="x264", - vopts="pass=%(vpass)d:bitrate=%(vbitrate)d:vbv_maxrate=1500:vbv_bufsize=2000:nocabac:me=umh:partitions=all:trellis=1:subq=7:bframes=0:direct_pred=auto:level_idc=30:global_header:turbo", + vopts="pass=%(vpass)d:bitrate=%(vbitrate)d:vbv_maxrate=1500:vbv_bufsize=2000:nocabac:me=umh:partitions=all:trellis=1:subq=7:bframes=0:direct_pred=auto:level_idc=30:turbo", acodec="faac", - aopts="br=%(abitrate)d:mpeg=4:object=2:raw", - extra2=["-channels", "2", "-srate", "48000"] + aopts="br=%(abitrate)d:mpeg=4:object=2", + extra=["-vf-add", "scale=480:-10"], + extra2=["-channels", "2", "-srate", "48000"], ), "nokiax264" : @@ -193,11 +200,39 @@ profiles = { "abitrate": 96, }, vcodec="x264", - vopts="pass=%(vpass)d:bitrate=%(vbitrate)d:nocabac:me=umh:partitions=all:trellis=1:subq=7:bframes=0:direct_pred=auto:global_header", + vopts="pass=%(vpass)d:bitrate=%(vbitrate)d:nocabac:me=umh:partitions=all:trellis=1:subq=7:bframes=0:direct_pred=auto", acodec="faac", - aopts="br=%(abitrate)d:mpeg=4:object=2:raw", + aopts="br=%(abitrate)d:mpeg=4:object=2", extra=["-vf-add", "scale=320:-10"], ), + + "n97xvid" : + Profile( + commands=[Mencoder, MP4Box], + default_opts={ + "vbitrate": 1000, + "abitrate": 96, + }, + vcodec="xvid", + vopts="pass=%(vpass)d:bitrate=%(vbitrate)d:vhq=4:autoaspect:max_bframes=0", + acodec="faac", + aopts="br=%(abitrate)d:mpeg=4:object=2", + extra=["-vf-add", "scale=640:-10"], + ), + + "n97x264" : + Profile( + commands=[Mencoder, MP4Box], + default_opts={ + "vbitrate": 1000, + "abitrate": 96, + }, + vcodec="x264", + vopts="pass=%(vpass)d:bitrate=%(vbitrate)d:vbv_maxrate=2000:vbv_bufsize=2000:nocabac:me=umh:partitions=all:trellis=1:subq=7:bframes=0:direct_pred=auto:level_idc=20", + acodec="faac", + aopts="br=%(abitrate)d:mpeg=4:object=2", + extra=["-vf-add", "scale=640:-10"], + ), } @@ -232,6 +267,8 @@ def parse_args(): output = os.path.splitext(os.path.basename(input))[0] elif len(args) == 2: input, output = args + else: + raise ValueError except Exception: parser.print_usage() sys.exit(1)