From patchwork Fri Dec 29 11:32:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dixit, Vishwanath" X-Patchwork-Id: 7013 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.79.195 with SMTP id r64csp10382378jad; Fri, 29 Dec 2017 03:32:50 -0800 (PST) X-Google-Smtp-Source: ACJfBotz5Dpb6CUnH8cnjwu+D7FVGYrGodYBofONPzc1zplAX61CfwjWQbkAsUkpFCS2eRykdp65 X-Received: by 10.223.160.129 with SMTP id m1mr12371776wrm.126.1514547170400; Fri, 29 Dec 2017 03:32:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514547170; cv=none; d=google.com; s=arc-20160816; b=o04V7yGaIEq1Wm6b4Ke+HLZ8R6exC38aBTOVdYG8KErR4pcYjSSI93Ue21cX25c3gk 98R2XgPE73hLRJypgdP9hBq1dGBS5VayZMDHg2hZATouxuPc5gBix+IcGmmUGbLhxuVv geZM7nUItpacxinVjKsEtpgSAk9Vumcd1pMSFQcgQxjBaCjWuZpt9iECaD4EXYDgWPTG 9l3bXC0c3y/PWJmT4eQ7MipVGxxZO8xkzuy4mbN4bwF2mG1ngeS6IU5Wr6fY8VL6OZ5c C1UcIfVAWC9rXkX9vavWNRLvmq4IQMdxuldV76Lr5f71JVc3jJykoaTFg9AGtfzCTWlN 12Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:feedback-id:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to :arc-authentication-results; bh=MCuTmi8uY5ITL09tFabyfYh7y8kl0LzbVfhySogF+YE=; b=E5XZFZS//qcEL8MHjza/zNpPRHhDrcHjk5Jqm7A7xMyiSYUcTHZUBOWe1A2oMVST/M dx1Q9fUO2NE1CzugWjhwUd4oB/HAlZSudBBEEAk8ZS8Wu7re/04StWCjbE6NN5H/w1/e KOzPBXV8G0AF4wbvegviTFHbhOE8xc1FxuFcudk+HY5JBnfFfr/TqyOq8ipRLXLRgI9f h4ynOentMg2jp2+tSzl5qcOyjJGYsCzmxiUFSOPh4O4Iy3meMEiiMrXZd4zyFE7/dO5R gWKoglFW6zEhVL2CHACryMCaMyCqGp8xPwmMnI41LnF3WAmVuqOyOc5Voo0Ug9WbHFDA sPdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@smtpservice.net header.s=m78bu0.a1-4.dyn header.b=i4ThPr7D; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k1si16714421wmi.20.2017.12.29.03.32.49; Fri, 29 Dec 2017 03:32:50 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@smtpservice.net header.s=m78bu0.a1-4.dyn header.b=i4ThPr7D; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EB146689A53; Fri, 29 Dec 2017 13:32:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from a2i831.smtp2go.com (a2i831.smtp2go.com [103.47.207.63]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 17A61689944 for ; Fri, 29 Dec 2017 13:32:27 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=m78bu0.a1-4.dyn; x=1514548067; h=Feedback-ID: X-Smtpcorp-Track:Message-Id:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe; bh=E28MSPrTI0Vuwl/qzlBTDZXTBJwwsmhnpXZ8Ywu61J0=; b=i4ThPr7D tt3g7EfH91EcaHbRYVYF8XWZVgt3TW0OiQvkRRVcbRJnIcV94Cpf6pX48TQflxhl/x2z6jg2Q+QXy 6oh1J9udUG1ND7nygWKXW30Da622ELI3s29yfc065VRp8XoypE/qEXk8xzcc0udRLPp2xydHkOlus 3Mv94ycJMb2NmglNGEwv71Ob4Vm/n9aivhwUO7tst8PwLhZBkpEtvmiq+3QJhiZXGbhJQeaDnxs9e BWjdY/cGjOF2HPqNQbODEjQft5hy6569qlClaOymQT6Qlg9uGMMOu+v0TbRbkdbm/IuGpVqOO7iSY zuTLT8/fCGtXXcGqC0BagJn0ng==; From: vdixit@akamai.com To: ffmpeg-devel@ffmpeg.org Date: Fri, 29 Dec 2017 17:02:31 +0530 Message-Id: <1514547151-4963-1-git-send-email-vdixit@akamai.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1514544278-31294-1-git-send-email-vdixit@akamai.com> References: <1514544278-31294-1-git-send-email-vdixit@akamai.com> X-Smtpcorp-Track: 1-lstxNmF4hX56.RXflZ78Mb Feedback-ID: 337386m:337386asVRLGB:337386svOmvxRJyg:SMTPCORP X-Report-Abuse: Please forward a copy of this message, including all headers, to Subject: [FFmpeg-devel] [PATCH v2 1/1] avformat/hlsenc: closed caption tags in the master playlist X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Vishwanath Dixit MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Vishwanath Dixit --- doc/muxers.texi | 4 ++++ libavformat/dashenc.c | 2 +- libavformat/hlsenc.c | 14 +++++++++++++- libavformat/hlsplaylist.c | 5 ++++- libavformat/hlsplaylist.h | 3 ++- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index 8ce964b..01f7fe4 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -874,6 +874,10 @@ publishing it repeatedly every after 30 segments i.e. every after 60s. @item http_persistent Use persistent HTTP connections. Applicable only for HTTP output. +@item cc_instream_id +Add @code{#EXT-X-MEDIA} tag in the master playlist with the specified instream ID. It +accepts the values in the range 1-4. + @end table @anchor{ico} diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 3345b89..39d0afe 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -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); + ff_hls_write_stream_info(st, out, stream_bitrate, playlist_file, agroup, NULL); } avio_close(out); if (use_rename) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index e6f3241..bff3e6e 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -206,6 +206,7 @@ typedef struct HLSContext { int http_persistent; AVIOContext *m3u8_out; AVIOContext *sub_m3u8_out; + int cc_instream_id; /* closed captions INSTREAM-ID */ } HLSContext; static int mkdir_p(const char *path) { @@ -1116,6 +1117,7 @@ static int create_master_playlist(AVFormatContext *s, unsigned int i, j; int m3u8_name_size, ret, bandwidth; char *m3u8_rel_name; + char cc_group[16] = {0}; input_vs->m3u8_created = 1; if (!hls->master_m3u8_created) { @@ -1142,6 +1144,14 @@ static int create_master_playlist(AVFormatContext *s, ff_hls_write_playlist_version(hls->m3u8_out, hls->version); + if (hls->cc_instream_id) { + av_strlcpy(cc_group, "group_cc", sizeof(cc_group)); + avio_printf(hls->m3u8_out, "#EXT-X-MEDIA:TYPE=CLOSED-CAPTIONS,GROUP-ID=\"%s\"", + cc_group); + avio_printf(hls->m3u8_out, ",NAME=\"captions\",INSTREAM-ID=\"CC%d\"\n", + hls->cc_instream_id); + } + /* For audio only variant streams add #EXT-X-MEDIA tag with attributes*/ for (i = 0; i < hls->nb_varstreams; i++) { vs = &(hls->var_streams[i]); @@ -1227,7 +1237,8 @@ static int create_master_playlist(AVFormatContext *s, bandwidth += bandwidth / 10; ff_hls_write_stream_info(vid_st, hls->m3u8_out, bandwidth, m3u8_rel_name, - aud_st ? vs->agroup : NULL); + aud_st ? vs->agroup : NULL, + vid_st ? cc_group : NULL); av_freep(&m3u8_rel_name); } @@ -2436,6 +2447,7 @@ static const AVOption options[] = { {"master_pl_name", "Create HLS master playlist with this name", OFFSET(master_pl_name), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E}, {"master_pl_publish_rate", "Publish master play list every after this many segment intervals", OFFSET(master_publish_rate), AV_OPT_TYPE_INT, {.i64 = 0}, 0, UINT_MAX, E}, {"http_persistent", "Use persistent HTTP connections", OFFSET(http_persistent), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E }, + {"cc_instream_id", "Closed captions INSTREAM-ID", OFFSET(cc_instream_id), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, E}, { NULL }, }; diff --git a/libavformat/hlsplaylist.c b/libavformat/hlsplaylist.c index 098dc89..1bfcce9 100644 --- a/libavformat/hlsplaylist.c +++ b/libavformat/hlsplaylist.c @@ -46,7 +46,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) { + int bandwidth, char *filename, char *agroup, + char *cc_group) { if (!out || !filename) return; @@ -62,6 +63,8 @@ void ff_hls_write_stream_info(AVStream *st, AVIOContext *out, st->codecpar->height); if (agroup && strlen(agroup) > 0) avio_printf(out, ",AUDIO=\"group_%s\"", agroup); + if (cc_group && strlen(cc_group) > 0) + avio_printf(out, ",CLOSED-CAPTIONS=\"%s\"", cc_group); avio_printf(out, "\n%s\n\n", filename); } diff --git a/libavformat/hlsplaylist.h b/libavformat/hlsplaylist.h index 9969315..0ff99f1 100644 --- a/libavformat/hlsplaylist.h +++ b/libavformat/hlsplaylist.h @@ -40,7 +40,8 @@ void ff_hls_write_playlist_version(AVIOContext *out, int version); 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); + int bandwidth, char *filename, char *agroup, + char *cc_group); void ff_hls_write_playlist_header(AVIOContext *out, int version, int allowcache, int target_duration, int64_t sequence, uint32_t playlist_type);