diff options
author | Karthick Jeyapal <kjeyapal@akamai.com> | 2017-12-29 13:47:53 +0800 |
---|---|---|
committer | Steven Liu <lq@chinaffmpeg.org> | 2017-12-29 13:47:53 +0800 |
commit | 5297ae96a13f615431c9a4cc38cac13c4140b07e (patch) | |
tree | 726bfa30bc4a8cd25ce3ec076888441a9752d873 | |
parent | 8fd2bdd07207cc7e055915f470302596bcfebeea (diff) | |
download | ffmpeg-5297ae96a13f615431c9a4cc38cac13c4140b07e.tar.gz |
avformat/dashenc: Addition of #EXT-X-MEDIA tag and AUDIO attribute
This is required for AV playout from master.m3u8.
Otherwise master.m3u8 lists only video-only and/or audio-only streams.
Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
-rw-r--r-- | libavformat/dashenc.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 478a384f55..a3eb522c38 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -737,6 +737,9 @@ static int write_manifest(AVFormatContext *s, int final) if (c->hls_playlist && !c->master_playlist_created) { char filename_hls[1024]; + const char *audio_group = "A1"; + int is_default = 1; + int max_audio_bitrate = 0; if (*c->dirname) snprintf(filename_hls, sizeof(filename_hls), "%s/master.m3u8", c->dirname); @@ -758,9 +761,26 @@ static int write_manifest(AVFormatContext *s, int final) for (i = 0; i < s->nb_streams; i++) { char playlist_file[64]; AVStream *st = s->streams[i]; + if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) + continue; + get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, i); + ff_hls_write_audio_rendition(out, (char *)audio_group, + playlist_file, i, is_default); + max_audio_bitrate = FFMAX(st->codecpar->bit_rate, max_audio_bitrate); + is_default = 0; + } + + for (i = 0; i < s->nb_streams; i++) { + char playlist_file[64]; + AVStream *st = s->streams[i]; + char *agroup = NULL; + int stream_bitrate = st->codecpar->bit_rate; + if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) && max_audio_bitrate) { + agroup = (char *)audio_group; + stream_bitrate += max_audio_bitrate; + } get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, i); - ff_hls_write_stream_info(st, out, st->codecpar->bit_rate, - playlist_file, NULL); + ff_hls_write_stream_info(st, out, stream_bitrate, playlist_file, agroup); } avio_close(out); if (use_rename) |