[FFmpeg-devel] [PATCH 3/5] mpegts: add channel specific languages into metadata
Anssi Hannula
anssi.hannula
Tue Feb 15 07:32:10 CET 2011
On 15.02.2011 01:11, M?ns Rullg?rd wrote:
> Anssi Hannula <anssi.hannula at iki.fi> writes:
>
>> ---
>> libavformat/mpegts.c | 27 +++++++++++++++++++++++++++
>> 1 files changed, 27 insertions(+), 0 deletions(-)
>>
>> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
>> index 8b67db4..fafd9f9 100644
>> --- a/libavformat/mpegts.c
>> +++ b/libavformat/mpegts.c
>> @@ -949,6 +949,32 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
>> av_metadata_set2(&st->metadata, "language", language, 0);
>> break;
>> case 0x0a: /* ISO 639 language descriptor */
>> + if (desc_len >= 8 && desc_len % 4 == 0) {
>> + /* channel-specific language tags */
>> + int ch;
>> + int tag_count = FFMIN(desc_len / 4, 10);
>> + char *combined_lang = av_malloc(tag_count * 4);
>> + if (!combined_lang)
>> + break;
>> + for (ch = 0; ch < tag_count; ch++) {
>> + char *language_key = av_strdup("channelX/language");
>
> What does channel refer to here?
To a single audio channel of a dual-mono audio stream.
>> + if (!language_key)
>> + break;
>> + language_key[7] = '0' + ch;
>> + language[0] = combined_lang[ch * 4 + 0] = get8(pp, desc_end);
>> + language[1] = combined_lang[ch * 4 + 1] = get8(pp, desc_end);
>> + language[2] = combined_lang[ch * 4 + 2] = get8(pp, desc_end);
>> + language[3] = 0;
>> + combined_lang[ch * 4 + 3] = '+';
>> + av_metadata_set2(&st->metadata, language_key, language,
>> + AV_METADATA_DONT_STRDUP_KEY);
>> + if (get8(pp, desc_end))
>> + av_log_ask_for_sample(fc, "Multiple languages and non-zero audio_type.");
>> + }
>> + combined_lang[tag_count * 4 - 1] = 0;
>> + av_metadata_set2(&st->metadata, "language", combined_lang,
>> + AV_METADATA_DONT_STRDUP_VAL);
>
> I don't understand the idea behind this. The descriptor applies to one
> program element (AVStream). If it contains several language codes, this
> simply means the stream contains multiple languages. The MPEG spec
> doesn't specify any further interpretation. Does DVB use this to
> indicate multiple mono streams coded as one elementary stream? I don't
> have those specs at hand.
Looked up:
ETSI TS 102 154 V1.2.1 (2004-05) [1] section 4.1.8.8:
For an audio stream coded as dual-mono (e.g. MPEG dual-channel, or AC-3
1+1 mode), the descriptor should contain two language codes describing
the two audio channels contained in the dual-mono stream. The sequence
of codes identifies the language for each audio channel as follows: the
first code signals the language of the left channel, channel 1, of the
dual-mono stream, and the second code signals the language of the right
channel, channel 2.
[1] This is the DVB spec for "Contribution and Primary Distribution
Applications". Interestingly, this passage is missing from the TS 101
154, the spec for "Broadcasting Applications".
Nevertheless, this dual-mono coding was used until recently on DVB-C
here (I just looked at Eurosport and the 4 languages seem to be all
transmitted as full stereo now).
As Janne said, though, this seems to be deprecated in DVB, so I guess it
would make sense to just do the language=xxx+yyy thing, and drop the
more complex channelN/language=xxx stuff? It would also be more generic
in case some TS streams do not use them to indicate channel languages.
--
Anssi Hannula
More information about the ffmpeg-devel
mailing list