[FFmpeg-devel] Handling dual language mono audio encoded as stereo

Anssi Hannula anssi.hannula
Mon Feb 15 23:35:02 CET 2010


On maanantai 15 helmikuu 2010 03:32:17 Michael Niedermayer wrote:
> On Sun, Feb 14, 2010 at 07:32:08PM +0200, Anssi Hannula wrote:
> > Hi all!
> > 
> > Some nordic DVB channels encode e.g. four mono tracks with different
> > languages into two stereo tracks (mpeg layer 2). The ISO639 language
> > descriptor then has both language codes, separated by a null byte. This
> > is probably a remnant from pre-DVB era, but we should somehow handle it
> > nevertheless.
> > 
> > How should we handle this, what do you think?
> 
> i can think of many ways, i like none though
> 
> > Attached is a patch which simply sets language tag to e.g. "nor+fin" for
> > dual- language stereo tracks. Seems to show up correctly in ffplay
> > (though of course there doesn't seem to be a way to choose a single
> > channel from stereo track in ffplay).
> > 
> >  mpegts.c |   12 ++++++++++--
> >  1 file changed, 10 insertions(+), 2 deletions(-)
> > 
> > 412b28b45b3015d83d776f95a4c2abdaca9b5c88 
> > mpegts-dual-language-stereo-tracks.patch Index: libavformat/mpegts.c
> > ===================================================================
> > --- libavformat/mpegts.c	(revision 21821)
> > +++ libavformat/mpegts.c	(working copy)
> > @@ -848,7 +848,7 @@
> > 
> >      int program_info_length, pcr_pid, pid, stream_type;
> >      int desc_list_len, desc_len, desc_tag;
> >      int comp_page, anc_page;
> > 
> > -    char language[4];
> > +    char language[8];
> > 
> >      uint32_t prog_reg_desc = 0; /* registration descriptor */
> >  
> >  #ifdef DEBUG
> > 
> > @@ -977,7 +977,15 @@
> > 
> >                  language[0] = get8(&p, desc_end);
> >                  language[1] = get8(&p, desc_end);
> >                  language[2] = get8(&p, desc_end);
> > 
> > -                language[3] = 0;
> > +                if (desc_len >= 8) {
> > 
> > +                    p++;
> 
> if this is some kind of code then it should be checked

It you mean the 'p++', it is the audio type code of the first track, which is 
always present but is ignored by ffmpeg even without this patch. There's 
another audio type code for the second channel after the second ISO639 
language code.

The possible values are:
00 Undefined
01 Clean effects
02 Hearing impaired
03 Visual impaired commentary
04-FF Reserved

I guess we should somehow add this in metadata. Then of course there's also 
the case where audio type differs between channels :)

> also we need some way for ffmpeg/ffplay to select the source channel for
> converting to mono unles we already support this somehow.
> 
> [...]

-- 
Anssi Hannula



More information about the ffmpeg-devel mailing list