Addendum regarding widescreen movies:
To keep the aspect ratio right but still within a 320x240 window, I've found I need a two-pass approach (though I'd welcome suggestions on how to do it in one). The first thing is to add a suitable border top and bottom to the movie; after that it can be encoded to 320:240. The aspect ratio of movies varies so some experimentation is needed, but the following worked for The Bourne Identity:
----------------------------------------------------------------------------------
mencoder dvd://$1 -chapter 8 -oac copy -ovc lavc -lavcopts vcodec=mpeg2video:vbitrate=4000:vhq -vf expand=0:-160:0:80 -o temp.mpg
mencoder temp.vob -ovc lavc -lavcopts vcodec=mpeg4:vhq:vqmin=2:vqmax=20:vmax_b_frames=2:vbitrate=192:vqcomp=0.6:vpass=1 -vop scale=320:240,eq=6 -ofps 25 -sws 2 -oac mp3lame -lameopts abr:br=64:aq=1:mode=0 -srate 24000 -o "$2".avi
rm -f temp.mpg
----------------------------------------------------------------------------------
In the first command, the DVD is ripped to a high-quality MPEG, with 160 pixels added to its height and the picture offset by 80 pixels to keep it centered. The second command then writes the result to an MPEG4 AVI.