From patchwork Tue Sep 17 01:25:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soft Works X-Patchwork-Id: 15110 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id BFFE2448BB4 for ; Tue, 17 Sep 2019 04:25:57 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A7E5C68819A; Tue, 17 Sep 2019 04:25:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM06-BL2-obe.outbound.protection.outlook.com (mail-bl2nam06olkn0170.outbound.protection.outlook.com [104.47.53.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4AF9E688039 for ; Tue, 17 Sep 2019 04:25:51 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jcv4IIUoo4GsO1lf7l+WLnASluArGOhuqO9HVuLlIYedCQd60KL0R4MHWKRyWsE3CMhje/2CHWbQYvKEnQ92Tyh0yd6/fuzCJdt8tZjSUzg8AHjH914xZclkYSPhlegsYAgsWMJHx1cMHTQIcxMuC3q+V3eEKwXWvPxNyjPFQeJ0Bs4rQDzmtKPNBJS0gMUVUlFrDHS/L352SatdjRtz7+oxVP9uW7GOseN9PHVCCECCUUMQTjlfp/gYquOtSBuEI5ss4zuKnJoNbm5iQQjLgZ31OOdrEQEcTGwumfu2ikem9p6fUj/OmWXoaPc3ufRHN/rhAtcRdkSmtBbJ7I9xng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DizUc+5aPtP/XB073aAkkANZ6FZrkVJHCWIhLVRLdvw=; b=Mo3qPTLcK0KQPdaa3QnGEPoe1XBuGneL51CDLoH82Dt+6fZtm5d4t0FB8Gbhc5o9sKJY9ExbNUcZ/0Njlytp/gm4r5mr9DJZuWophtCK/5S38sJ79kOJPEihIVjrtZBLB/auqiQrlKeXskZcQs8S2wnVMfoqyDiRQUFA85vx+TZtDMIgYuxiyfA2tTj0Eq2t5CU2wNnC5cGKOExIQv+lSEfpLg5Eh7p191gWRBfoIYsrMlHagrm8pAChW3VNfD+03htVIfT8Xe//gx1EXKU/KFpO7qiBuu6eWNPJZfFzkeCLDDeRFTpmtpIq/eaPygYyW744VaB5jBe350ETmIF5gw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DizUc+5aPtP/XB073aAkkANZ6FZrkVJHCWIhLVRLdvw=; b=mSBChZEzCFh2ZQgm+31lO17soZv+H6L4wQeYZcDqmO0QER45OcKqxVnWswqhZVep28MyCJ7jLKE1hOLTyzsPjMKQHiIDWlNDefxoZpYUYP+Eu9noWzLfIU++jYARioZa8shub6uIhPoE4mK3xGps4j6hOkpkhS6WBnIYDgwsx7Vrh6aUN+S8gEO/dQjaUmF18cPb++tex3aFmFQnpmwZR7D6VRdBJ/m1SaalW2dscymP1mqYRVfLA/k7u4dMaxHC1X/Y5XbubqR7JrcHQO/3FEFWJPAG4/FzpoM+gFO/QIUvZKNT651oP6WBG01i1OoT3ceSh1DfCCBcaMyp0VTDiw== Received: from DM3NAM06FT016.Eop-nam06.prod.protection.outlook.com (10.152.108.59) by DM3NAM06HT013.Eop-nam06.prod.protection.outlook.com (10.152.108.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2315.0; Tue, 17 Sep 2019 01:25:49 +0000 Received: from MN2PR13MB2752.namprd13.prod.outlook.com (10.152.108.59) by DM3NAM06FT016.mail.protection.outlook.com (10.152.109.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2315.0 via Frontend Transport; Tue, 17 Sep 2019 01:25:49 +0000 Received: from MN2PR13MB2752.namprd13.prod.outlook.com ([fe80::9c2c:8444:38e1:5d6]) by MN2PR13MB2752.namprd13.prod.outlook.com ([fe80::9c2c:8444:38e1:5d6%7]) with mapi id 15.20.2284.009; Tue, 17 Sep 2019 01:25:49 +0000 From: Soft Works To: FFmpeg development discussions and patches Thread-Topic: [PATCH v2] libavformat/webvttenc: Allow (but discard) additional streams Thread-Index: AdVs9sIf3GQPZbXSQq2DwRo7o+YVHg== Date: Tue, 17 Sep 2019 01:25:49 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:B864180D73AC217B34F899A25E99A49228E3A230D2EEDE17EF11598ADAEC2349; UpperCasedChecksum:EB2BAA9E26D3B1700D20691B6168A53A8D3A5067AD5221954E43DBA556F142AA; SizeAsReceived:6608; Count:40 x-tmn: [pdUp2+oAFV/Is5JdV30wHOebZz0JAdZk] x-ms-publictraffictype: Email x-incomingheadercount: 40 x-eopattributedmessage: 0 x-ms-traffictypediagnostic: DM3NAM06HT013: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: kc/wg3V7HwCmiMp4ACgUQLNmJxOEotzKcdo5grwSDsS3G5INEkdiZYuo282YPqekF81V4C8rTgGs84rkmU1zLerYmStuOBMXSmcbNKYmN2D9h3lv7k/QUeHeYqxMIEyHicH0sdTrkaXJUfi8QtJAaQwTjNFsZinisorL4aRdY/yilgyMFbGdmuTgv9ZoPN/T x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: cfac6ab8-3383-47f1-d188-08d73b0df8d6 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2019 01:25:49.0856 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3NAM06HT013 Subject: [FFmpeg-devel] [PATCH v2] libavformat/webvttenc: Allow (but discard) additional streams 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This allows mapping a video stream as reference stream for creating vtt segments when using the segment muxer. Example: ffmpeg -i INPUT -map 0:3 -c:0 webvtt -map 0:0 -c:v:0 copy -f segment -segment_format webvtt -segment_time 6 -write_empty_segments 1 -y "sub_segment3%d.vtt" The mpegts segments are being created in a constant and regular way. But not necessearily in the case of subtitles: When hitting a time range without any subtitle event, the segmenter stops generating subtitle segments, even when write_empty_segments is configured. It's not that write_empty_segments would not be working, though: As soon as a new subtitle event reaches the muxer, it catches up by creating the missed empty segments all at once. This might be OK for precreating content for HLS/VOD scenarios but it's a behavioral bug when you rely on having accurate results while the process is running. This is happening because When there are no subtitle events, there are no packets arriving at the segment muxer (for vtt). This patch allows a video stream as input to the WebVTT muxer which is discarded - but will allow the segment muxer to use it as reference stream. Signed-off-by: softworkz --- libavformat/webvttenc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/webvttenc.c b/libavformat/webvttenc.c index 61b7f54622..be85c03130 100644 --- a/libavformat/webvttenc.c +++ b/libavformat/webvttenc.c @@ -49,8 +49,8 @@ static int webvtt_write_header(AVFormatContext *ctx) AVCodecParameters *par = ctx->streams[0]->codecpar; AVIOContext *pb = ctx->pb; - if (ctx->nb_streams != 1 || par->codec_id != AV_CODEC_ID_WEBVTT) { - av_log(ctx, AV_LOG_ERROR, "Exactly one WebVTT stream is needed.\n"); + if (par->codec_id != AV_CODEC_ID_WEBVTT) { + av_log(ctx, AV_LOG_ERROR, "First stream must be WebVTT.\n"); return AVERROR(EINVAL); } @@ -68,6 +68,9 @@ static int webvtt_write_packet(AVFormatContext *ctx, AVPacket *pkt) int id_size, settings_size; uint8_t *id, *settings; + if (pkt->stream_index != 0) + return 0; + avio_printf(pb, "\n"); id = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_IDENTIFIER,