[MPlayer-dev-eng] [patch] matroska demuxer reports incorrect AC-3 bitrate

Trent Piepho xyzzy at speakeasy.org
Wed Apr 25 02:38:45 CEST 2007

When a Matroska file contains an AC-3 stream, the mkv demuxer fills in the
audio stream header structure field ->wh->nAvgBytesPerSec with a constant
value of 16000.  Of course this is wrong unless the AC-3 stream happens to
be 128 kbit/sec.

This messes up mencoder when using -oac copy.  Mencoder always thinks ac3
in mkv is 128 kbits and outputs the audio at this rate, then tries to sync
the video to match.

This patch fixes the problem by stopping the mkv demuxer from creating a
wave extension field for the audio stream header for AC-3 streams, since
the mkv demuxer has nothing correct to put in this field.  mencoder will
get the correct ac3 bit rate the same way it does for other demuxers, which
also don't create wave extension fields for ac3 streams.

--- libmpdemux/demux_mkv.c      (revision 23107)
+++ libmpdemux/demux_mkv.c      (working copy)
@@ -2098,8 +2098,8 @@
   else if ((track->a_formattag == 0x2000) || /* AC3 */
            (track->a_formattag == 0x2001)) /* DTS */
-      sh_a->wf->nAvgBytesPerSec = 16000;
-      sh_a->wf->nBlockAlign = 1536;
+      free(sh_a->wf);
+      sh_a->wf = NULL;
   else if (track->a_formattag == 0x0001)  /* PCM || PCM_BE */

More information about the MPlayer-dev-eng mailing list