Re: [FFmpeg-devel] [PATCH 3/3] avformat/hlsenc: add var_stream_map LANGUAGE field string parameter

2019-02-11 Thread Carl Eugen Hoyos
2019-01-23 12:24 GMT+01:00, Steven Liu :
> 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

I know this is late but shouldn't the language be taken from the
metadata if != unknown?

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 3/3] avformat/hlsenc: add var_stream_map LANGUAGE field string parameter

2019-01-23 Thread Steven Liu
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 
---
 doc/muxers.texi   | 16 
 libavformat/dashenc.c |  2 +-
 libavformat/hlsenc.c  | 15 +++
 libavformat/hlsplaylist.c |  9 ++---
 libavformat/hlsplaylist.h |  2 +-
 5 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index f5d4f67b7e..66908703ce 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -980,6 +980,22 @@ and they are mapped to the one video only variant streams 
with audio group name
 
 By default, a single hls variant containing all the encoded streams is created.
 
+@example
+ffmpeg -re -i in.ts -b:a:0 32k -b:a:1 64k -b:v:0 1000k \
+  -map 0:a -map 0:a -map 0:v -f hls \
+  -var_stream_map "a:0,agroup:aud_low,default:yes,language=ENG 
a:1,agroup:aud_low,language:CHN v:0,agroup:aud_low" \
+  -master_pl_name master.m3u8 \
+  http://example.com/live/out_%v.m3u8
+@end example
+This example creates two audio only and one video only variant streams. In
+addition to the #EXT-X-STREAM-INF tag for each variant stream in the master
+playlist, #EXT-X-MEDIA tag is also added for the two audio only variant streams
+and they are mapped to the one video only variant streams with audio group name
+'aud_low', and the audio group have default stat is NO or YES, and one audio
+have and language is named ENG, the other audio language is named CHN.
+
+By default, a single hls variant containing all the encoded streams is created.
+
 @item cc_stream_map
 Map string which specifies different closed captions groups and their
 attributes. The closed captions stream groups are separated by space.
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index cfd0f601d4..6912156b0a 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -989,7 +989,7 @@ static int write_manifest(AVFormatContext *s, int final)
 continue;
 get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, 
i);
 ff_hls_write_audio_rendition(c->m3u8_out, (char *)audio_group,
- playlist_file, i, is_default);
+ playlist_file, NULL, i, is_default);
 max_audio_bitrate = FFMAX(st->codecpar->bit_rate +
   os->muxer_overhead, max_audio_bitrate);
 if (!av_strnstr(audio_codec_str, os->codec_str, 
sizeof(audio_codec_str))) {
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(_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 =