Convert Canon HD AVCHD camera movies to AVI

Some Canon video cameras use an MTS file format to save the recorded video in - huh?!?!?! Here's a ffmpeg command to convert them to a more useful format:

ffmpeg -i "$inputfile" -vcodec libxvid -b 18000k -acodec libmp3lame -ac 2 -ab 320k -deinterlace -s 1440x1080 "$outputfile"

Adjust picture size (-s), audio bitrate (-ab), video bitrate (-b) to taste.