You may take a look at
this.
Download the direct264 package as well as ffmpeg(here do not use official ffmpeg builds).
Make sure you have mkv splitter and ac3 decoder installed on your system. (e.g. Haali + ffdshow)
Use the following command line to do it in one pass:
Code:
CTAACEncoder -d -b 128000 -o - input.mkv | ffmpeg -i input.mkv -vcodec copy -acodec copy -sn output.mp4 -i - -acodec copy -newaudio
Note that CTAACEncoder will automatically downmix your 5.1 AC3 to stereo.
Well official ffmpeg should also do it in one pass:
Code:
ffmpeg -i input.mkv -vcodec copy -acodec aac -ab 128 -sn output.mp4 -acodec copy -newaudio
However there are two problems:
1) The quality of ffmpeg's built-in aac encoder is bad.
2) If your H264 stream contains b-frames, stream copy will fail due to ffmpeg's lack of dts generation for mkv. It is only fixed in my build.