[MPlayer-users] encoding ac3

Kresimir Kukulj madmax at iskon.hr
Fri May 31 22:33:01 CEST 2002


Quoting anders at gnulinux.dk (anders at gnulinux.dk):
> Hi
> 
> I'm playing around with some dvd's and mencoder and the following question
> popped up: Is it possible to encode ac3 audio with mencoder? The Docs
> states that mencoder supports the following codecs: copy, pcm and mp3.
> What I don't really understand is: "is ac3 a codec?" Or can I encode ac3
> audio with the mp3 codec? Will the copy "codec" just copy and raw and keep
> the ac3 "uncompressed"? 

As far as I know, there are no solutions for linux to encode AC3 (5+1).

But mencoder can passthrough AC3 soundtrack.

mencoder ... -oac copy -aid 128 -o bla.avi

It will copy AC3 stream unmodified from a DVD source. Use -aid to specify
appropriate audio track.

Resulting file will be unplayable (jittery) in windows players. Interleaving
video with audio affects playback greatly (using S/PDIF).
Since mencoder has no interface to specify how much/often audio will be
interleaved with video, use attached patch (idea from this mlist).
Tweak the number if needed. This works for me.

-----CUT HERE----
diff -ruN main-cvs20020527/mencoder.c main/mencoder.c
--- main-cvs20020527/mencoder.c	Sun May 26 00:24:08 2002
+++ main/mencoder.c	Mon May 27 22:02:32 2002
@@ -826,7 +826,7 @@
 	    // CBR - copy 0.5 sec of audio
 	    switch(mux_a->codec){
 	    case ACODEC_COPY: // copy
-		len=mux_a->wf->nAvgBytesPerSec/2;
+		len=mux_a->wf->nAvgBytesPerSec/10;
 		len/=mux_a->h.dwSampleSize;if(len<1) len=1;
 		len*=mux_a->h.dwSampleSize;
 		len=demux_read_data(sh_audio->ds,mux_a->buffer,len);
-----CUT HERE----

I'm not sure, but using ­oac copy for AC3 soundtrack, produces file with
wrong AV sync.  Transcode tool 'tcprobe' shows for a DVD vob file
PTS=0.2873 (Presentation Time Stamp?). If I adjust audio (using Nandub) by
+287msec I get better AV sync.
Need to test this with more different samples to be sure.

I also found, that windows players have less problems with files produced
with Nandub. (Maybe all win players are developed with samples made by that
tool so ti works better with Nandub's interleaving?).

> This is what mencoder tells me about the audio:
> AC3: 5.1 (3f+2r+lfe)  48000 Hz  384.0 kbit/s
> 
> Which is a quite high bitrate ;-)

Not as high as you may think. AC3 contains 5 independent audio streams + 1
LFE stream.  384 kbit/s are divided between them using some algorithm.

-- 
Kresimir Kukulj                      madmax at iskon.hr
+--------------------------------------------------+
Old PC's never die. They just become Unix terminals.




More information about the MPlayer-users mailing list