From patchwork Mon Oct 11 04:50:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soft Works X-Patchwork-Id: 31041 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2084:0:0:0:0 with SMTP id a4csp3329801ioa; Sun, 10 Oct 2021 21:51:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEVJ6CRtX+XQ4b/ooAs64d4YCiny6dAZTbuMRo1cdHYuVKQz++mAb7XJ8hxDzP3uqlEqEZ X-Received: by 2002:a05:6402:1296:: with SMTP id w22mr15852420edv.390.1633927863995; Sun, 10 Oct 2021 21:51:03 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g1si9403970edk.532.2021.10.10.21.51.03; Sun, 10 Oct 2021 21:51:03 -0700 (PDT) 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=@hotmail.com header.s=selector1 header.b="b2EdihP/"; arc=fail (body hash mismatch); 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=NONE sp=NONE dis=NONE) header.from=hotmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E60B56801CA; Mon, 11 Oct 2021 07:50:58 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10olkn2096.outbound.protection.outlook.com [40.92.42.96]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B937D689CD7 for ; Mon, 11 Oct 2021 07:50:51 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mKrkR2cxQZUdUWpk/eZGM8cdSEvQ8wprI1sOfg8M2EHVY5AkHxOHgXGwWBtf2MwytmpgExA3m+0lDmO6Jhe+LkyQOMy20C4alo3yMLwM9tlQzKfExCnQ8HjWsqwniIJZOvwppyLqcXiCA0WjEqqWwcQAOUWe1uuh6hkHPsmuRfpsJ95trWZikzk6SSLUTGhZ8AuIlWnUkH9/bc7ZK6gCxGQNAG8rAvSVHw9CbAhijUVvvWlacx7C5MQGcULjWqVhjf/ythn9CI/WyF+desKVF76o91Qm4gKy4F1WdchnQ8nNpFzElOyXC6klw6pM7wf5s2La3kwQHxRakruppIH7gw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vzlXRMOFlLV/tJSXuLWoOXia22Dm33gs6galJdguRcA=; b=Tal4pmTjQ8aZxVYhqJbXtdBRP5+9HhKD06vRmJ0Os5Z9RO/g4rQomdXhM72G7FDeP3UZS79BY+ULhokJChp9iv6sO71RSmpX68KND9a7VAsVYsLCcqJSvtWZOKKWIYXt1ML06Xp5oaxrUcZ9G77R2Or2B1Di/HlYkgHKQu+ABnFcnWwbCTjXCplD2SqSO60LPQ5J1isUZij14isIr9MW1nJvRacJ/+N2tG6ebaCB5GM+zipRMb5sACpc+sI091RWHebXFaCuho+vYXMIhVaIyqHvrghly7Dpdw8Omhw/ABTgE2T/VIVrYjUOK6REMsAdpmkhPmxfnqOiHCOuFoUoFQ== 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=vzlXRMOFlLV/tJSXuLWoOXia22Dm33gs6galJdguRcA=; b=b2EdihP/+KLU5or54ObO74TXQDIb+jC7b1WfH1lZ4/FZOxXpw+LAwW32KjxpZEYt47M627C7BomneEmV1UvXt/emGg4s32mcD6PpfFQIvYbTxooZwY3a0G9rsgR3xk7BRIaCUo04YmSeHR7gdYaB2d1UK74PdshXbjfmuR3txRNdPRKbi4kfhrGQY7u76Est99P1N4cbSK+VjxqF3TqFrlT0AZDoz0cOeWBEp/lCNHO1bQbBSluYK0xTiTnkB++OXN6SSzx4EudQg4L+0N7w01tnLskAF6lcFeDSwbzOuykQWyp8pcqKP5MhgvW4eSGpxHFkxmVNVnrB9wj2hF6S1w== Received: from MN2PR04MB5981.namprd04.prod.outlook.com (2603:10b6:208:da::10) by MN2PR04MB6016.namprd04.prod.outlook.com (2603:10b6:208:de::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Mon, 11 Oct 2021 04:50:46 +0000 Received: from MN2PR04MB5981.namprd04.prod.outlook.com ([fe80::ecfe:2528:2012:22cb]) by MN2PR04MB5981.namprd04.prod.outlook.com ([fe80::ecfe:2528:2012:22cb%5]) with mapi id 15.20.4587.026; Mon, 11 Oct 2021 04:50:46 +0000 From: Soft Works To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH v13 00/14] Subtitle Filtering Thread-Index: AQGh51AcJVmE6DhdOtnAJcRtF23w0w== Date: Mon, 11 Oct 2021 04:50:46 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [iywyx97vQhjGtdMO+UfnIBuxt9i0+NYN] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3b1ad4ed-c312-4601-756e-08d98c72b05b x-ms-traffictypediagnostic: MN2PR04MB6016: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: A/RCHPHJhFkcJm1M+le6mv/yhKtNTBHJyjqtMJwNmx3epSt3fbGzop/g0ZbSr5ZXUYxMe+KDl2ozNWZLdvSNnJU0xYWQBKjaUHbG1jXmsgLsQazeN+vHMbkYKx75WvOMYWNtpJ1ytWxlhwQ7A+Au6555KyCuTbZMnDy2uQ62qHHqz1fBvzrAz4zraFynLMBop3sUqWtTpCze7bvkWHlwaDxJ72fjMuC8EUloXLeYQEO6iq+gQz7PR0a2vqpZxEHjclSrgOSXc/2WKP8+DpBzXKvD9i30oEpRWSCU3398M5IB83joYXvCoObQPMW95fj01Xfl0s5E9KS+8EBv309eGKf1UGuHzmjjr2tUblRmMvgObj6VzfBrurpQgO+IW4R/09G879CZ1YLLF+B6hx2MIUX6vYpYQoeFHBR3HrLQ5g4Obeg++f/TY5WBVjP2FVGr x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: ow7LHMpTYmnUo49xNEALICKt6fKhKbmUeaK34ykxCwLyL2VOuIQrmQGMWPiAbA+OUq6++k5nwglS3klm8lSL0Wni0G+RlPGHGX9d6T8ia1yhRygHSlpsvLLPGmHe16xVk99tJy2QDP40R9spxRpyoQ== x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-3174-20-msonline-outlook-529c7.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR04MB5981.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 3b1ad4ed-c312-4601-756e-08d98c72b05b X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Oct 2021 04:50:46.1230 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR04MB6016 Subject: [FFmpeg-devel] [PATCH v13 00/14] Subtitle Filtering X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: mqAXqLvD+V8O v13 Update: - FEATURE-COMPLETE - Adapted patchset to upstream changes regarding AVPacket handling (v12 couldn't be applied anymore) - Some adjustments for cases where hw acceleration is involved v12 Update: - FEATURE-COMPLETE No more features or filters are needed for the introduction of subtitle filtering - Adapted patchset to the changes regarding .query_formats in avfilter - Removed underscores in filter names - Expose all options from cc_dec from the splitcc filter - Added 'render_latest_only' mode to overlaytextsubs and textsubs2video filters (allows rendering closed captions without black background rectangles) v11 Update: - FEATURE-COMPLETE No more features or filters will be added to this patchset - Added subscale filter Provides high-quality scaling and rearranging functionality for graphical subtitles. This has been the last missing bit for making this a useful and versatile toolset for subtitle manipulation - The common ass utility functions remain to reside in avutil, but in this version, they are marked as avpriv_ and no longer public like in the previous version. - A number of detail fixes are included, but there haven't been significant changes to the core implementation in the past few versions. I'm quite confident about the current state. - As a final step I'll be going to create a wiki page presenting a comprehensive collection of usage examples, showing off the whole range of new capabilities and also providing proof that it is working universally in a wide range of use cases. -------------------------------------------------------------- This patchset introduces filtering support for subtitles. Besides the ground work, this patchset includes a range of new filters for subtitle processing: - subscale (S -> S) Provides high-quality scaling and rearranging functionality for graphical subtitles. - graphicsubs2text (S -> S) Convert graphic subtitles to text subtitles via OCR - censor {S -> S) Allows censoring word in subtitles by a configurable word list - showspeaker {S -> S) Prepend the speaker names to text lines (those are often available in ass subs) - splitcc (V -> VS) Splits out Closed-Caption data as a subtitle stream for filtering and encoding - overlaygraphicsubs (VS -> V) Overlay graphic subtitles onto a video stream - graphicsub2video {S -> V) Converts graphic subtitles to (transparent) video frames - overlaytextsubs {VS -> V) Overlay text subtitles onto a video stream. - textsubs2video {S -> V) Converts text subtitles to video frames - textmod {S -> S) Modify subtitle text in a number of ways - stripstyles {S -> S) Remove all inline styles from subtitle events Regards, softworkz softworkz (14): global: Prepare AVFrame for subtitle handling global: Move ass helper functions to avutil as avpriv_ and extend ass dialog parsing fftools/play,probe: Adjust for subtitle changes avfilter/subtitles: Add subtitles.c for subtitle frame allocation avfilter/avfilter: Handle subtitle frames avfilter/sbuffer: Add sbuffersrc and sbuffersink filters avfilter/overlaygraphicsubs: Add overlaygraphicsubs and graphicsub2video filters fftools/ffmpeg: Replace sub2video with subtitle frame filtering avfilter/overlaytextsubs: Add overlaytextsubs and textsubs2video filters avfilter/textmod: Add textmod, censor and show_speaker filters avfilter/stripstyles: Add stripstyles filter avfilter/splitcc: Add splitcc filter for closed caption handling avfilter/graphicsub2text: Add new graphicsub2text filter (OCR) avfilter/subscale: Add filter for scaling and/or re-arranging graphical subtitles configure | 7 +- doc/filters.texi | 747 +++++++++++++++ fftools/ffmpeg.c | 516 ++++++----- fftools/ffmpeg.h | 15 +- fftools/ffmpeg_filter.c | 217 +++-- fftools/ffmpeg_hw.c | 2 +- fftools/ffmpeg_opt.c | 3 +- fftools/ffplay.c | 102 +-- fftools/ffprobe.c | 48 +- libavcodec/Makefile | 56 +- libavcodec/ass.h | 129 +-- libavcodec/assdec.c | 2 +- libavcodec/assenc.c | 2 +- libavcodec/avcodec.c | 19 - libavcodec/avcodec.h | 75 +- libavcodec/ccaption_dec.c | 19 +- libavcodec/decode.c | 53 +- libavcodec/jacosubdec.c | 2 +- libavcodec/libaribb24.c | 2 +- libavcodec/libzvbi-teletextdec.c | 14 +- libavcodec/microdvddec.c | 7 +- libavcodec/movtextdec.c | 3 +- libavcodec/movtextenc.c | 20 +- libavcodec/mpl2dec.c | 2 +- libavcodec/pgssubdec.c | 1 + libavcodec/realtextdec.c | 2 +- libavcodec/samidec.c | 2 +- libavcodec/srtdec.c | 2 +- libavcodec/srtenc.c | 16 +- libavcodec/subviewerdec.c | 2 +- libavcodec/textdec.c | 4 +- libavcodec/ttmlenc.c | 15 +- libavcodec/utils.c | 11 + libavcodec/webvttdec.c | 2 +- libavcodec/webvttenc.c | 16 +- libavfilter/Makefile | 15 + libavfilter/allfilters.c | 13 + libavfilter/avfilter.c | 30 +- libavfilter/avfilter.h | 11 + libavfilter/avfiltergraph.c | 5 + libavfilter/buffersink.c | 63 ++ libavfilter/buffersink.h | 15 + libavfilter/buffersrc.c | 72 ++ libavfilter/buffersrc.h | 1 + libavfilter/formats.c | 22 + libavfilter/formats.h | 3 + libavfilter/internal.h | 19 +- libavfilter/sf_graphicsub2text.c | 323 +++++++ libavfilter/sf_splitcc.c | 315 +++++++ libavfilter/sf_stripstyles.c | 191 ++++ libavfilter/sf_subscale.c | 847 ++++++++++++++++++ libavfilter/sf_textmod.c | 697 ++++++++++++++ libavfilter/subtitles.c | 63 ++ libavfilter/subtitles.h | 44 + libavfilter/vf_overlaygraphicsubs.c | 736 +++++++++++++++ libavfilter/vf_overlaytextsubs.c | 630 +++++++++++++ libavfilter/vf_subtitles.c | 50 +- libavformat/utils.c | 1 + libavutil/Makefile | 4 + {libavcodec => libavutil}/ass.c | 73 +- libavutil/ass_internal.h | 139 +++ {libavcodec => libavutil}/ass_split.c | 30 +- .../ass_split_internal.h | 24 +- libavutil/frame.c | 191 +++- libavutil/frame.h | 93 +- libavutil/subfmt.c | 240 +++++ libavutil/subfmt.h | 185 ++++ tests/ref/fate/filter-overlay-dvdsub-2397 | 181 ++-- tests/ref/fate/sub-dvb | 162 ++-- tests/ref/fate/sub2video | 1 - tests/ref/fate/sub2video_basic | 92 +- tests/ref/fate/sub2video_time_limited | 3 +- 72 files changed, 6702 insertions(+), 1017 deletions(-) create mode 100644 libavfilter/sf_graphicsub2text.c create mode 100644 libavfilter/sf_splitcc.c create mode 100644 libavfilter/sf_stripstyles.c create mode 100644 libavfilter/sf_subscale.c create mode 100644 libavfilter/sf_textmod.c create mode 100644 libavfilter/subtitles.c create mode 100644 libavfilter/subtitles.h create mode 100644 libavfilter/vf_overlaygraphicsubs.c create mode 100644 libavfilter/vf_overlaytextsubs.c rename {libavcodec => libavutil}/ass.c (73%) create mode 100644 libavutil/ass_internal.h rename {libavcodec => libavutil}/ass_split.c (94%) rename libavcodec/ass_split.h => libavutil/ass_split_internal.h (89%) create mode 100644 libavutil/subfmt.c create mode 100644 libavutil/subfmt.h