You can use ffmpegX if you like GUI's, or script it with ffmpeg;
This is what I used in the past:
ffmpeg -i <name>.avi -acodec aac -ab 96 -vcodec h264 -b 733kb -mbd 0 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 480x360 -padtop 4 -padbottom 4 -title <title> <name>.mp4
These options are what I've been using, but there are probably better ones around - on my CD 2Ghz. it takes around 20-30 minutes to convert a tv show.
And then if you have mp4tools you can use mp4track to set the information so that iTunes will recognize it automatically.
Casper
Most of my media is in H264 format (from DVD using HandBrake). Some of my earlier rips are in Xvid format. I have just bought an Apple TV and I was wondering if it is possible to convert Xvid to H264 format so I can watch it on the Apple TV? Does it result in a marked decrease in quality? How do I go about it? I'm (of course) on a Mac.
Thanks,
MadDoc