Today I needed to write a script that would use RV’s frameburn overlay script to add Frame numbers to a bunch of existing quicktimes. Initially I was going to use shell script, but on further research I found Python’s optparse module.

This handy module makes it easy to create Usage and Option documentation for a shell-like script.

More information on optparse can be found here.

I did not end up using any extra options, but utilised its ability to process the argument string.

#!/usr/bin/env python
import os
import optparse
import shutil
import glob
import sys
from subprocess import call
def findMovs():
    currentPath = os.getcwd()
    movList = glob.glob('*.mov')
    for mov in movList:
def convertMov(mov):
    print "Burning " + mov + "'s Frames..."
    destPath = arguments[0] + os.sep + mov
    print "Dest Path: " + destPath
        retcode = call([rvBinPath, str(mov) ,'-o' , destPath, '-overlay',
                               'frameburn', '0.5', '0.5', '200.0'], shell=False)
        if retcode < 0:
            print >>sys.stderr, "Child was terminated by signal", -retcode
            print >>sys.stderr, "Child returned code: ", retcode
    except OSError, e:
        print >>sys.stderr, "Execution failed:", e
if __name__ == "__main__":
    usage ="usage: %prog [options] destinationPath"
    parser = optparse.OptionParser(usage=usage,
                    description="Adds Frame Burn ins to .movs",
                    version="%prog 0.1")
    options, arguments = parser.parse_args()
    if len(arguments) == 1:

« »