Log in

View Full Version : Remuxing MKV (H.264+DTS/AC3) to MP4 (H.264+AAC) under Mac OS X


kapowaz
1st December 2009, 16:55
I'm attempting to remux a number of Matroska-contained videos under Mac OS X. My objectives are that the produced video files be:

• Playable on Mac OS X through QuickTime, iTunes and Front Row (rather than only VLC)
• Playable on a PlayStation 3 (natively, rather than using a streaming server)

For this reason, I would like to use the MP4 container (even though this has some limitations, particularly regarding subtitles; it's still the most pragmatic choice for me).

I've already made several attempts with one video, which have involved the use of tsMuxerGUI to demux the streams and then convert the audio stream from DTS 5.1 to AAC 5.1 using ffmpeg -i source.dts -ab 1536k -ac 6 output.m4a (1536kbps is the reported bitrate of the audio stream according to tsMuxerGUI); I then remuxed using ffmpeg thus: ffmpeg -i source.264 -i output.m4a -vcodec copy -acodec aac final.m4v. There were a couple of warnings in each stage (which I'll show later), but the end result was a playable MP4 video file which suffered stuttering problems (rather than dropped frames it would seem to quickly flicker between a frame and a few frames immediately previous). The audio also didn't seem to be quite right, with odd channel distribution.

The errors I received from ffmpeg were:

• From the audio conversion: [aac @ 0x188e200]This encoder does not yet enforce the restrictions on LFEs. The output will most likely be an illegal bitstream.
• From the remux: Seems stream 0 codec frame rate differs from container frame rate: 47.95 (48000/1001) -> 23.98 (48000/2002)

It's possible that some part of my toolchain has introduced errors, or that the sample video in this case itself is badly encoded, but I'm not even 100% sure at this point if I'm following the correct process for re-encoding (for example) the audio. Since the overwhelming majority of guides and knowledge on doom9 is geared towards Windows users, I'm at something of a dead end without advice. If there are additional command-line tools I need, I'm happy to try compiling them; my ultimate objective is to come up with a reliable workflow for converting MKV contained content to MP4 that can be scripted/batch processed.

So, what suggestions do people have?

roozhou
1st December 2009, 19:01
Official ffmpeg build does not support H264 frame copy from mkv.
I posted this patch (https://roundup.ffmpeg.org/roundup/ffmpeg/file444/matroskadec_dts_fix.patch) on ffmpeg tracker and it should solve this problem.

kapowaz
1st December 2009, 23:08
Does ffmpeg have any problems remuxing using H.264 streams that were demuxed separately from it? Say with mkvextract or (as in my case) tsMuxerGUI?

Mr VacBob
2nd December 2009, 22:10
• From the remux: Seems stream 0 codec frame rate differs from container frame rate: 47.95 (48000/1001) -> 23.98 (48000/2002)

This is just a random message; the error is probably about "non-monotone timestamps". Both of these are from ffmpeg's complicated attempt to find completely correct timestamps from file formats that don't have anything like them - it causes ridiculous problems like not being able to extract mp3 from avi with bad timestamps, when mp3 doesn't have timestamps anyway.

Try QTAmateur (http://mikeash.com/?page=software/qtamateur/) - use Export -> to MPEG-4, then select "MP4" as the format and "passthrough" as the video and audio format.