use the handbreak source code of commandline and ask a coder to build a script around it... should be an easy job