[FFmpeg-user] How can I convert mpeg2 5.1 audio to ac3?

Moritz Barsnick barsnick at gmx.net
Wed Nov 5 16:19:29 CET 2014

On Tue, Nov 04, 2014 at 20:12:56 +0100, bluesky at caramail.com wrote:

> XBMC WILL play Dolby encoded files correctly if the channels
> are all present and not encoded in some weird format, in fact it is
> very good at that.

That's understood.

> It would be really great if ffmpeg could detect these channels and
> reencode them to a more standard (if that is the way to put it) ac3
> format.

This is the technicality which needs to be understood. If the source is
what Carl Eugen has identified, there is no digital indication that
this is "Dolby Surround". You will identify two channels which can be
played on stereo output, and will sound like a down-mix of surround
material on stereo. Yet in these two channels, there is a mixture of
four or six audio channels. If you know how to "decode" them, you can
separate them. Actually, you should be able to detect this surround
encoding if you analyze the audio waveforms, but this may mean actually
decoding them and checking whether the "extra" channels contain sound.
(My hardware decoder creates pseudo-surround effects from plain stereo
material by the way, due to the way it "tries" to decode 6 from 2
channels and the audio's phases.)

Actually, a lot of digital TV channels broadcast their movies with
surround sound like this, i.e. using two channels, but still containing
surround. Mostly this is the case when they don't have 6 channels
available. This is very common in broadcast, from my experience.

Basically, ffmpeg currently can neither detect nor decode this
encoding. I think decoding it would require something like an audio

> "Carl Eugen Hoyos" <cehoyos at ag.or.at> wrote:
> > I will hopefully open a ticket for PLII decoding,
> > I have no idea how difficult / trivial this is
> > given that we support encoding...

Since it's easy to find algorithms (i.e. matrices) for encoding but not
for decoding, I am guessing that the latter may be a much tougher task.
It's not as easy as inverting the matrix. I'm no smarter than Carl
Eugen concerning this. Here's the only description I have found of the
process, and it looks very DSPish (if not analog):


See figure 5 for a summarizing diagram. No C source code provided
though. ;-)


More information about the ffmpeg-user mailing list