diff options
author | Marton Balint <cus@passwd.hu> | 2016-02-05 23:46:25 +0100 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2016-02-21 23:24:09 +0100 |
commit | 3a4232a1a0251e2ad595a544996fcc4465baf684 (patch) | |
tree | be55d36be13dfa08dd62152ce17b2fcd40cca443 /libavformat/asfenc.c | |
parent | 2ac5a1a28ece31cbe33ff2688aad6bfba0edcf73 (diff) | |
download | ffmpeg-3a4232a1a0251e2ad595a544996fcc4465baf684.tar.gz |
avformat/asfenc: write group_mutual_exclusion_objects for audio on multiple languages
Improves streaming compatibility with Windows Media Services. Also tested for
compatilbility in Windows Media Player, Windows Media ASF Viewer and VLC.
This version of the patch only writes exclusion among audio streams, therefore
choosing a subtitle language should be possible independently of audio language.
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavformat/asfenc.c')
-rw-r--r-- | libavformat/asfenc.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c index 14f92e258f..66551ea373 100644 --- a/libavformat/asfenc.c +++ b/libavformat/asfenc.c @@ -396,6 +396,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t header_offset, cur_pos, hpos; int bit_rate; int64_t duration; + int audio_language_counts[128] = { 0 }; ff_metadata_conv(&s->metadata, ff_asf_metadata_conv, NULL); @@ -444,6 +445,8 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, asf->streams[n].stream_language_index = asf->nb_languages; asf->nb_languages++; } + if (enc->codec_type == AVMEDIA_TYPE_AUDIO) + audio_language_counts[asf->streams[n].stream_language_index]++; } } else { asf->streams[n].stream_language_index = 128; @@ -484,6 +487,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, if (asf->nb_languages) { int64_t hpos2; int i; + int nb_audio_languages = 0; hpos2 = put_header(pb, &ff_asf_language_guid); avio_wl16(pb, asf->nb_languages); @@ -493,6 +497,25 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, } end_header(pb, hpos2); + for (i = 0; i < asf->nb_languages; i++) + if (audio_language_counts[i]) + nb_audio_languages++; + + if (nb_audio_languages > 1) { + hpos2 = put_header(pb, &ff_asf_group_mutual_exclusion_object); + ff_put_guid(pb, &ff_asf_mutex_language); + avio_wl16(pb, nb_audio_languages); + for (i = 0; i < asf->nb_languages; i++) { + if (audio_language_counts[i]) { + avio_wl16(pb, audio_language_counts[i]); + for (n = 0; n < s->nb_streams; n++) + if (asf->streams[n].stream_language_index == i && s->streams[n]->codec->codec_type == AVMEDIA_TYPE_AUDIO) + avio_wl16(pb, n + 1); + } + } + end_header(pb, hpos2); + } + for (n = 0; n < s->nb_streams; n++) { int64_t es_pos; if (asf->streams[n].stream_language_index > 127) |