Q:

Convert a bunch of MKV files to MP4 to read them in iTunes

I have a bunch of mkv files that are encoded as MPEG-4 video and AC-3 audio. I usually use Subler to convert the mov into mp4 to read them in iTunes, but the AC-3 audio is unreadable by Subler or iTunes. 
So, I want to convert them into mp4 files with AAC audio, without re-encoding the video part which is just fine as MPEG-4. 
How can I do that? 

A:

Install ffmpeg by running brew install ffmpeg or sudo port install ffmpeg or by downloading a binary from http://ffmpegmac.net. Then run a command like:
for f in *.mkv;do ffmpeg -i "$f" -c:v copy -c:a aac -b:a 256k -strict -2 "${f%mkv}mp4";done

Or if you don't need to re-encode audio:
for f in *.mkv;do ffmpeg -i "$f" -c copy "${f%mkv}mp4";done

