Commit 1948b76a authored by Vishwanath Dixit's avatar Vishwanath Dixit Committed by Steven Liu

avformat/hlsenc: closed caption tags in the master playlist

parent 8a4cc0a2
......@@ -901,6 +901,43 @@ and they are mapped to the two video only variant streams with audio group names
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.
Expected string format is like this
"ccgroup:<group name>,instreamid:<INSTREAM-ID>,language:<language code> ....".
'ccgroup' and 'instreamid' are mandatory attributes. 'language' is an optional
attribute.
The closed captions groups configured using this option are mapped to different
variant streams by providing the same 'ccgroup' name in the
@code{var_stream_map} string. If @code{var_stream_map} is not set, then the
first available ccgroup in @code{cc_stream_map} is mapped to the output variant
stream. The examples for these two use cases are given below.
@example
ffmpeg -re -i in.ts -b:v 1000k -b:a 64k -a53cc 1 -f hls \
-cc_stream_map "ccgroup:cc,instreamid:CC1,language:en" \
-master_pl_name master.m3u8 \
http://example.com/live/out.m3u8
@end example
This example adds @code{#EXT-X-MEDIA} tag with @code{TYPE=CLOSED-CAPTIONS} in
the master playlist with group name 'cc', langauge 'en' (english) and
INSTREAM-ID 'CC1'. Also, it adds @code{CLOSED-CAPTIONS} attribute with group
name 'cc' for the output variant stream.
@example
ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
-a53cc:0 1 -a53cc:1 1\
-map 0:v -map 0:a -map 0:v -map 0:a -f hls \
-cc_stream_map "ccgroup:cc,instreamid:CC1,language:en ccgroup:cc,instreamid:CC2,language:sp" \
-var_stream_map "v:0,a:0,ccgroup:cc v:1,a:1,ccgroup:cc" \
-master_pl_name master.m3u8 \
http://example.com/live/out_%v.m3u8
@end example
This example adds two @code{#EXT-X-MEDIA} tags with @code{TYPE=CLOSED-CAPTIONS} in
the master playlist for the INSTREAM-IDs 'CC1' and 'CC2'. Also, it adds
@code{CLOSED-CAPTIONS} attribute with group name 'cc' for the two output variant
streams.
@item master_pl_name
Create HLS master playlist with the given name.
......
......@@ -820,7 +820,7 @@ static int write_manifest(AVFormatContext *s, int final)
stream_bitrate += max_audio_bitrate;
}
get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, i);
ff_hls_write_stream_info(st, out, stream_bitrate, playlist_file, agroup, NULL);
ff_hls_write_stream_info(st, out, stream_bitrate, playlist_file, agroup, NULL, NULL);
}
avio_close(out);
if (use_rename)
......
This diff is collapsed.
......@@ -47,7 +47,8 @@ void ff_hls_write_audio_rendition(AVIOContext *out, char *agroup,
void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,
int bandwidth, char *filename, char *agroup,
char *codecs) {
char *codecs, char *ccgroup) {
if (!out || !filename)
return;
......@@ -65,6 +66,8 @@ void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,
avio_printf(out, ",CODECS=\"%s\"", codecs);
if (agroup && strlen(agroup) > 0)
avio_printf(out, ",AUDIO=\"group_%s\"", agroup);
if (ccgroup && strlen(ccgroup) > 0)
avio_printf(out, ",CLOSED-CAPTIONS=\"%s\"", ccgroup);
avio_printf(out, "\n%s\n\n", filename);
}
......
......@@ -41,7 +41,7 @@ void ff_hls_write_audio_rendition(AVIOContext *out, char *agroup,
char *filename, int name_id, int is_default);
void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,
int bandwidth, char *filename, char *agroup,
char *codecs);
char *codecs, char *ccgroup);
void ff_hls_write_playlist_header(AVIOContext *out, int version, int allowcache,
int target_duration, int64_t sequence,
uint32_t playlist_type);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment