diff options
author | Steven Liu <lq@chinaffmpeg.org> | 2019-01-23 19:19:49 +0800 |
---|---|---|
committer | Steven Liu <lq@chinaffmpeg.org> | 2019-01-31 16:17:11 +0800 |
commit | 1e03d600542d7e6ccd3ee94062174ae29383bef7 (patch) | |
tree | 6fa95ad3a435c14e9ab73bc595d6ca8c8889a3ec /libavformat/hlsenc.c | |
parent | 6a25bb5aa42285441dbe7d3372f598bb7ac7c4bf (diff) | |
download | ffmpeg-1e03d600542d7e6ccd3ee94062174ae29383bef7.tar.gz |
avformat/hlsenc: add var_stream_map LANGUAGE field string parameter
use a:0,agroup:aud_low,default:Yes,language:CHN a:1,agroup:aud_low,language:ENG
a:2,agroup:aud_high,default:YesYes,language:CHN a:3,agroup:aud_high,language:ENG
v:0,agroup:aud_low v:1,agroup:aud_high
create master m3u8 list.
result:
EXTM3U
EXT-X-VERSION:3
EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_aud_low",NAME="audio_0",DEFAULT=YES,LANGUAGE="CHN",URI="out_0.m3u8"
EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_aud_low",NAME="audio_1",DEFAULT=NO,LANGUAGE="ENG",URI="out_1.m3u8"
EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_aud_high",NAME="audio_2",DEFAULT=YES,LANGUAGE="CHN",URI="out_2.m3u8"
EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_aud_high",NAME="audio_3",DEFAULT=NO,LANGUAGE="ENG",URI="out_3.m3u8"
EXT-X-STREAM-INF:BANDWIDTH=1170400,RESOLUTION=640x480,CODECS="avc1.64001e,mp4a.40.2",AUDIO="group_aud_low"
out_4.m3u8
EXT-X-STREAM-INF:BANDWIDTH=3440800,RESOLUTION=640x480,CODECS="avc1.64001e,mp4a.40.2",AUDIO="group_aud_high"
out_5.m3u8
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Diffstat (limited to 'libavformat/hlsenc.c')
-rw-r--r-- | libavformat/hlsenc.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index e6628145f8..d91960d752 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -154,6 +154,7 @@ typedef struct VariantStream { unsigned int nb_streams; int m3u8_created; /* status of media play-list creation */ int is_default; /* default status of audio group */ + char *language; /* audio lauguage name */ char *agroup; /* audio group name */ char *ccgroup; /* closed caption group name */ char *baseurl; @@ -1261,7 +1262,7 @@ static int create_master_playlist(AVFormatContext *s, goto fail; } - ff_hls_write_audio_rendition(hls->m3u8_out, vs->agroup, m3u8_rel_name, i, hls->has_default_key ? vs->is_default : 1); + ff_hls_write_audio_rendition(hls->m3u8_out, vs->agroup, m3u8_rel_name, vs->language, i, hls->has_default_key ? vs->is_default : 1); av_freep(&m3u8_rel_name); } @@ -1829,7 +1830,7 @@ static int parse_variant_stream_mapstring(AVFormatContext *s) /** * Expected format for var_stream_map string is as below: * "a:0,v:0 a:1,v:1" - * "a:0,agroup:a0,default:1 a:1,agroup:a1,defalut:0 v:0,agroup:a0 v:1,agroup:a1" + * "a:0,agroup:a0,default:1,language:ENG a:1,agroup:a1,defalut:0 v:0,agroup:a0 v:1,agroup:a1" * This string specifies how to group the audio, video and subtitle streams * into different variant streams. The variant stream groups are separated * by space. @@ -1879,8 +1880,12 @@ static int parse_variant_stream_mapstring(AVFormatContext *s) nb_streams = 0; while (keyval = av_strtok(varstr, ",", &saveptr2)) { varstr = NULL; - - if (av_strstart(keyval, "default:", &val)) { + if (av_strstart(keyval, "language:", &val)) { + vs->language = av_strdup(val); + if (!vs->language) + return AVERROR(ENOMEM); + continue; + } else if (av_strstart(keyval, "default:", &val)) { vs->is_default = (!av_strncasecmp(val, "YES", strlen("YES")) || (!av_strncasecmp(val, "1", strlen("1")))); hls->has_default_key = 1; @@ -2392,6 +2397,7 @@ static void hls_free_variant_streams(struct HLSContext *hls) av_freep(&vs->m3u8_name); av_freep(&vs->streams); av_freep(&vs->agroup); + av_freep(&vs->language); av_freep(&vs->ccgroup); av_freep(&vs->baseurl); } @@ -2843,6 +2849,7 @@ fail: av_freep(&vs->m3u8_name); av_freep(&vs->vtt_m3u8_name); av_freep(&vs->streams); + av_freep(&vs->language); av_freep(&vs->agroup); av_freep(&vs->ccgroup); av_freep(&vs->baseurl); |