Hello,
it's probably not a great idea to do the conversion in only one pass if you want to keep a good quality...
You could for example have a look at :
http://magma.epfl.ch/greg/scripts/MENCODER
BUT, I have learn something about sed with your script, thank you for it !!!