]> code.delx.au - transcoding/blobdiff - encode.py
Ensure output files do not exist before starting
[transcoding] / encode.py
index 1bc6c3a3ebf4c6f1b525c2bc4a8edc7af796c249..cdc733cf8bc989a6d8bfaf82cd4dda79b3445a32 100755 (executable)
--- 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())