From patchwork Fri Dec 29 10:44:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dixit, Vishwanath" X-Patchwork-Id: 7010 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.79.195 with SMTP id r64csp10339357jad; Fri, 29 Dec 2017 02:44:54 -0800 (PST) X-Google-Smtp-Source: ACJfBov/0dJlTxy8OnG5M+3oRABZ6StLJpD3sPsBy65g4Cqjkol+HuvEJ/6pbyNipgTttjv5bwr5 X-Received: by 10.28.181.209 with SMTP id e200mr27259476wmf.68.1514544294827; Fri, 29 Dec 2017 02:44:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514544294; cv=none; d=google.com; s=arc-20160816; b=0HvIdosdeehPWALi5ahlrUr2e+ngCnAwdiKGK65KoQSifmOmDhGaGpwIlGUJmHX4DQ AX0B2swGjK9IkOFzIy1XNXY1bdU+hCYdS0J7/U8IuwEeuFGWi+EzI3Wo6qKnYZfGo4No Y9nfOtaoeE7DBy5v+BgdBLvxPLjv8bvPnVbzPOmm1qsnB6gm1z9YZGJnxe/jhN+RHcvB qGDPlyT+VOVpfnEMZ+hyLIW/TD5RtOXFCBEyJBUM3Czn6Ps3hcXRpjDjqu7WXE0CWnBo KTR9CPJThxy8hGTfhEjXWDoWOTd26BS3NnaYrNAcSIQKbR/WHRG7uJen9Sh+7p1Ava94 q+BA== 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:message-id:date:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=kej0xr1fP1JEKd/E8t+Op8hCJ+m4R9NDbCdKwQe8+T0=; b=pibikNwoclunhWM5oG67lgStBGk/bWng+R3n/ZQKfhz1rDjVCcDbkoDhsWofjwdYQn IMuYu8Tnm/jwPmsUjDLpPRo1Vg56W8y6XZEOKDv1kWUbyeXazRf7tFdk0bLDqyf3OI1t rwwhN60HnDactB05YHhF+0fKToxhCcDP1BUy6NoaS9C48J2+5npRAAvwSFf4d1YQtKo9 D5mpF1oAU5wFM1/2R7Z/shvQ8043f7vbczmMtt30pTK371V7lnUXmOEF+Fgod8JBHjhE j0IFI/Hy6h0uaG9n98/mEZX5Qe6Qjnh7su+Wj5ONDXzs5XurJM4AHAG0ChHt5K+XkumB E1bg== 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=KbeOw1YA; 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 n4si16030183wmd.220.2017.12.29.02.44.54; Fri, 29 Dec 2017 02:44:54 -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=KbeOw1YA; 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 7948A689A38; Fri, 29 Dec 2017 12:44:38 +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 269D8689A21 for ; Fri, 29 Dec 2017 12:44:32 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=m78bu0.a1-4.dyn; x=1514545192; h=Feedback-ID: X-Smtpcorp-Track:Message-Id:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe; bh=uNUCAcpCxT2P8mKn+XrHY82rVku+mcONvOWnQ0GuCdQ=; b=KbeOw1YA 1pwpxeO/Hf1/T0XOtlA6vUiCC1ywLaMkY6w12F5Po2NgEfgAzcL1s0eE2F9RAAm+w2U+Sz5Pm58bO Flhtfw4tKjO1nXHupV+S/We+FD8VkIRGUmR940krFpO/FF/G2xvQfJAHtNR/XJGjDSysijCNJL0/e Z+4EWhMQkE7KJrc/HPbWFkrxmodAkkyegMiIe0MQo+uQJZUfiyqwnBGgFv4QKTIRmfupVS/npvrLA lq9I72E7AZCopk1zueQOzcu/8iZQIvytJ5D3Ztea02TxUY5RNxlkrnBwupDUbcrtkc535RXFlifu4 MlLVi+FTeao2DiNzglUiPX3Jaw==; From: vdixit@akamai.com To: ffmpeg-devel@ffmpeg.org Date: Fri, 29 Dec 2017 16:14:38 +0530 Message-Id: <1514544278-31294-1-git-send-email-vdixit@akamai.com> X-Mailer: git-send-email 1.9.1 X-Smtpcorp-Track: 1-ls9a4baC9ilD.R_yPVLjzJ Feedback-ID: 337386m:337386asVRLGB:337386sJL0NnUawS:SMTPCORP X-Report-Abuse: Please forward a copy of this message, including all headers, to Subject: [FFmpeg-devel] [PATCH 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 93db549..8229202 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -872,6 +872,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 478a384..8797959 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -760,7 +760,7 @@ static int write_manifest(AVFormatContext *s, int final) AVStream *st = s->streams[i]; 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); + playlist_file, NULL, NULL); } avio_close(out); if (use_rename) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 74f66ce..e5176a8 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) { @@ -1122,6 +1123,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) { @@ -1148,6 +1150,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]); @@ -1235,7 +1245,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); } @@ -2444,6 +2455,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 42f059a..8619436 100644 --- a/libavformat/hlsplaylist.c +++ b/libavformat/hlsplaylist.c @@ -36,7 +36,8 @@ void ff_hls_write_playlist_version(AVIOContext *out, int version) { } 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; @@ -52,6 +53,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 ac03550..71ccee7 100644 --- a/libavformat/hlsplaylist.h +++ b/libavformat/hlsplaylist.h @@ -38,7 +38,8 @@ typedef enum { void ff_hls_write_playlist_version(AVIOContext *out, int version); 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);