that's a pretty ugly way to approach it imho... you could be there for ages. you have options:
1)
http://acidrip.sf.net (next version i release will support file input)
2) use 3pass encoding to provide you with bitrates from mencoder specifially for cd sized files (see docs)
3) work it out yourself....
assuming you're gonna use a fixed bitrate audio stream, e.g. 128kbit joint stereo, video bitrate for a given film is...
Vbitrate = ( size in kbits / Length in seconds ) - audio bitrate in kbps
e.g a 90 minute film on a 700mb cd with 128 audio:
Vbitrate = ( ( 700 * 1024 * 8 ) / ( 90 * 60 ) ) - 128
Vbitrate = ( 5734400 / 5400 ) - 128
Vbitrate = 1062 - 128 = 934kbps
how easy is that? Personally i use average bitrate, not constant bitrate, which means that you'll save a couple of megs on the audio, meaning that it'll probably end up being 697Mb rather than 700, which gives a generally nicer margin for error