diff mbox

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

Message ID 1514286700-21147-3-git-send-email-kjeyapal@akamai.com
State Accepted
Commit 5297ae96a13f615431c9a4cc38cac13c4140b07e
Headers show

Commit Message

Jeyapal, Karthick Dec. 26, 2017, 11:11 a.m. UTC
From: Karthick Jeyapal <kjeyapal@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(-)

Comments

Steven Liu Dec. 27, 2017, 7:26 a.m. UTC | #1
2017-12-26 19:11 GMT+08:00 Karthick J <kjeyapal@akamai.com>:
> From: Karthick Jeyapal <kjeyapal@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
>

Patchset LGTM


Thanks

Steven
Liu Steven Dec. 29, 2017, 6:43 a.m. UTC | #2
> On 27 Dec 2017, at 15:26, Steven Liu <lingjiujianke@gmail.com> wrote:
> 
> 2017-12-26 19:11 GMT+08:00 Karthick J <kjeyapal@akamai.com>:
>> From: Karthick Jeyapal <kjeyapal@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
>> 
> 
> Patchset LGTM

Pushed

Thanks

Steven
> 
> 
> Thanks
> 
> Steven
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Jeyapal, Karthick Dec. 29, 2017, 6:50 a.m. UTC | #3
On 12/29/17 12:13 PM, 刘歧 wrote:
>

>> On 27 Dec 2017, at 15:26, Steven Liu <lingjiujianke@gmail.com> wrote:

>>

>> 2017-12-26 19:11 GMT+08:00 Karthick J <kjeyapal@akamai.com>:

>>> From: Karthick Jeyapal <kjeyapal@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

>>>

>>

>> Patchset LGTM

>

> Pushed

Thanks.

Regards,
Karthick
>

> Thanks

>

> Steven

>>

>>

>> Thanks

>>

>> Steven

>> _______________________________________________

>> ffmpeg-devel mailing list

>> ffmpeg-devel@ffmpeg.org

>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

>

>

>
diff mbox

Patch

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)