From: James Bunton Date: Wed, 19 Mar 2008 05:57:16 +0000 (+1100) Subject: Better batch encoder X-Git-Url: https://code.delx.au/transcoding/commitdiff_plain/2a0d436d209917e0b0ac8eefd15e2e8313f33fe9 Better batch encoder --- diff --git a/batchencode.sh b/batchencode.sh deleted file mode 100755 index 2e849df..0000000 --- a/batchencode.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -# inputdesc specification: -# -# general options -# output_file\tinput_file\tspecific_options -# output_file\tinput_file\tspecific_options -# -# Example inputdesc -# --filters pp=ci,crop=704:576:10:0,scale=768:576,denoise3d,harddup -# 1x01.avi dvd://1 --dvd DISC1 -# 1x02.avi dvd://1 --dvd DISC2 - - -encoder="$1" -input="$2" -if [ -z "$input" ]; then - echo "Usage: $0 toh264.py inputdesc" - exit 1 -fi - -# Read the general options -options="$(head -n 1 "$input")" - -# Read each file description -tail -n +2 "$input" | while read line; do - out=$(echo "$line" | cut -d ' ' -f 1) - in=$(echo "$line" | cut -d ' ' -f 2) - specopts=$(echo "$line" | cut -d ' ' -f 3) - nice -n 10 "$encoder" $options $specopts "$in" "$out" -done - diff --git a/batchrun.py b/batchrun.py new file mode 100755 index 0000000..b8596ac --- /dev/null +++ b/batchrun.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +import optparse, shlex, subprocess, sys + +def parseArgs(): + parser = optparse.OptionParser(usage="%prog batchfile1 [batchfile2] ...") + opts, args = parser.parse_args(sys.argv[1:]) + return args + +def run(args): + subprocess.Popen(args).wait() + +def batchProcess(fd): + opts = [[], []] + for line in fd: + args = shlex.split(line) + if line.startswith("\t\t"): + run(opts[0] + opts[1] + args) + elif line.startswith("\t"): + opts[1] = args + else: + opts[0] = args + +def main(): + args = parseArgs() + for name in args: + batchProcess(open(name)) + +if __name__ == "__main__": + main() +