[FFmpeg-cvslog] avformat/dashenc: Addition of #EXT-X-MEDIA tag and AUDIO attribute

Karthick Jeyapal git at videolan.org
Fri Dec 29 08:43:31 EET 2017


ffmpeg | branch: master | Karthick Jeyapal <kjeyapal at akamai.com> | Fri Dec 29 13:47:53 2017 +0800| [5297ae96a13f615431c9a4cc38cac13c4140b07e] | committer: Steven Liu

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 at chinaffmpeg.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5297ae96a13f615431c9a4cc38cac13c4140b07e
---

 libavformat/dashenc.c | 24 ++++++++++++++++++++++--
 1 file 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)



More information about the ffmpeg-cvslog mailing list