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

Karthick J kjeyapal at akamai.com
Tue Dec 26 13:11:40 EET 2017


From: Karthick Jeyapal <kjeyapal at akamai.com>

This is required for AV playout from master.m3u8.
Otherwise master.m3u8 lists only video-only and/or audio-only streams.
---
 libavformat/dashenc.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 478a384..a3eb522 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)
-- 
1.9.1



More information about the ffmpeg-devel mailing list