From patchwork Thu Sep 30 20:07:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soft Works X-Patchwork-Id: 30814 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp1011876iob; Thu, 30 Sep 2021 13:07:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiUlEk3rr48bQwWMOnNDTwUTv0B0r/ittrBKDyEwYREioCwla5qQ9DZDCawEti9fYwGJFe X-Received: by 2002:a17:906:5295:: with SMTP id c21mr1391527ejm.25.1633032441607; Thu, 30 Sep 2021 13:07:21 -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 se8si4755834ejb.39.2021.09.30.13.07.20; Thu, 30 Sep 2021 13:07:21 -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=QlTezPND; 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 0927C68812E; Thu, 30 Sep 2021 23:07:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11olkn2084.outbound.protection.outlook.com [40.92.20.84]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AF9D668812E for ; Thu, 30 Sep 2021 23:07:08 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iOralzwR2q5fNDVK5+QDkhfdg6z8hLAsfe/nJH0mfegwMTxfb8uGvnANiSCj/nnt5DbyslDco+uLIMmtm1+pEPnwmqyM03a8bmXH2iwi6VPji+ZSoFN9q6wd+dL6/p77PzqBRZsmvxcKFe9Y/K5HzKhktcVAT4kbH2qeDbGt7Af+fnnZ/Cc8qV0E9g2A2hSTqV5k4NZuHWDB9g49vy4t+miRvsksUE8qA8RZZ0OG+MGK0CvhAUyYV2jLUA+a6RZ126+xaBbys561s6O9NM4epjJeJqvImDmCuwDxEvI54aK76CpMoW/dBG/6zN1QX4T3EW2MwKvEzgIrf6aJsP62Fw== 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; bh=+4WG2xKG9Ze54zYIf0VJRGmUcT3otJ6pEO3rNn6yB58=; b=Y+vBkGsWCjCgLq0woMYUDjhsO8CxKCVjvXKKIFJwsdnvS82X/qofv1XudtwJDo/jO/07lpX15u9XI3erixc/o91jLL3QmPdiVvFNYlas31lkX8GVkboNjhv2yKa/6gTOxmYK+LHyMZuhHcI6HNy7pBR2Ka/6vlFYRRir8EDZXut1puIsXEPChAS2WXcM5h8R0Ows2SDXjziLumjoQmko2FFs6DAObu9AJXxN4/0vhjxwwr5geeHzwu0UHKCMLemxzTlhKfPzKBcFPSBebX++yMFD0vZejpU8dS8Jm/QlTXANjx8PRsu9CFBj9G73JvuVnyNMp1o/V5j4cY2Fy5dUTA== 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=+4WG2xKG9Ze54zYIf0VJRGmUcT3otJ6pEO3rNn6yB58=; b=QlTezPND5iE3IIo3HUYZ2DjW+kW+X5wgUoP7M6B2RUZkObYpTITKLX7vKyh3UqN0WAo6VHPSDhg6KcWkVBLWLwa+tvV7M/prc6N6LkNJkFeWQa6G97wz6bDuyRZ/D19yjb1nBv2u9EllnduM+LQD7F+4b+6KdU49f2eQ+22V23iMibt74IowxETgLCXIbgRaaY8exKoXg12PYV/+fnkBA0p1bcF90G0szjLV3vyW09A3APlmNCMxgWMqijDDXhNUe8KEe5hMfRY+C6aA4OLfyHJwBTU6gewp0IbDc7KdWiSdquUdxygZacdDDwlz5Uj6v6Hxwj5hpy7f16dhNmO10A== Received: from MN2PR04MB5981.namprd04.prod.outlook.com (2603:10b6:208:da::10) by MN2PR04MB5503.namprd04.prod.outlook.com (2603:10b6:208:e4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Thu, 30 Sep 2021 20:07:05 +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.4544.023; Thu, 30 Sep 2021 20:07:05 +0000 From: Soft Works To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH v11 00/14] Subtitle Filtering Thread-Index: AQIYHFYDF8boFDQmQlEtL6nnnApb1g== Date: Thu, 30 Sep 2021 20:07:05 +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: [xs/X9gbJVu2jvNdP9WxnqR5ENe12Uj5+] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: af6cbd44-a74e-465a-eb46-08d9844de005 x-ms-traffictypediagnostic: MN2PR04MB5503: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: rYlGF8E5kiNU/+ctlM0MoZW/dt/z4Gvy2HHxseh+gx9OxepFGRsPt7YGCKxmVRRjDByYux27z7vTi6BPEXmPFGOVKUHlrRH/blOoa69LTCyGWp8MgUU/nM7HnfSe7WN6MECj7QWA3RWQoXxJwvU0aX5B7OOLqj4RdRYTN74sq9GsnAmJ9PjFDn+/OhzSE2VKoWl8oF6EBD0vO1yex7CFpqY3I7ZpsmDVOFnUiWVOQbAchKDNogGzEizTP0ZkW/q94OIe/c3Fp3sfLUabLhO+m4UrRzhYGUfmqMoHfEvwfkz+URk21MD5n97cCYiHNuZ5RwhOJ3qshjq02SoaRYK0tGCdGOCfIVycwa6bfMbgZ0tD3OLEI7fNNFmP0TKUvn3fFhHh/bv+IhNzhnHwlM9HpTeLJGJb4zNZSANGdlfRqr44uk2YoW+yDWSxVm2DUWy+ x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: sJ81TW2iCMgcjgoQyC+hqKyUA9eE8TAOvqZoGraQqQ7+JYWbU52T2E8jb6iOJ8MfTZqZ/lHRKnxzSp4M5ucW40D+cWxmFIjiCoFsfFGaheJSUTl1tkUCWnkQNGwrqIZMwdd916f2lcFJZ0rMiOiW2g== 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: af6cbd44-a74e-465a-eb46-08d9844de005 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Sep 2021 20:07:05.4928 (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: MN2PR04MB5503 Subject: [FFmpeg-devel] [PATCH v11 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: mWH6e++s+Z+x 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. v10 Update: INVALID - Incorrect patch sequence sent. v9 Update: - Addressed all review comments (thanks Andreas!) - Move ass utility functions to avutil as public API - Handle subtitle decoding via new decode API (removed av_decode_subtitle3) - Change 'subtitle_header' to use refcounted buffers - Allow mapping subtitle streams to filter graph and direct outputs simultaneously - Added explanation and justification for test changes to commit message -------------------------------------------------------------- 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 - show_speaker {S -> S) Prepend the speaker names to text lines (those are often available in ass subs) - split_cc (V -> VS) Splits out Closed-Caption data as a subtitle stream for filtering and encoding - overlay_graphicsubs (VS -> V) Overlay graphic subtitles onto a video stream - graphicsub2video {S -> V) Converts graphic subtitles to (transparent) video frames - overlay_textsubs {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/overlay_graphicsubs: Add overlay_graphicsubs and graphicsub2video filters fftools/ffmpeg: Replace sub2video with subtitle frame filtering avfilter/overlay_textsubs: Add overlay_textsubs and textsubs2video filters avfilter/textmod: Add textmod, censor and show_speaker filters avfilter/stripstyles: Add stripstyles filter avfilter/split_cc: Add split_cc 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 | 662 +++++++++++++ fftools/ffmpeg.c | 507 +++++----- fftools/ffmpeg.h | 14 +- fftools/ffmpeg_filter.c | 209 +++-- 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/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 | 14 + libavfilter/allfilters.c | 13 + libavfilter/avfilter.c | 30 +- libavfilter/avfiltergraph.c | 5 + libavfilter/buffersink.c | 63 ++ libavfilter/buffersink.h | 15 + libavfilter/buffersrc.c | 72 ++ libavfilter/buffersrc.h | 1 + libavfilter/formats.c | 14 + libavfilter/formats.h | 3 + libavfilter/internal.h | 1 + libavfilter/sf_graphicsub2text.c | 323 +++++++ libavfilter/sf_split_cc.c | 298 ++++++ libavfilter/sf_stripstyles.c | 211 +++++ libavfilter/sf_subscale.c | 867 ++++++++++++++++++ libavfilter/sf_textmod.c | 719 +++++++++++++++ libavfilter/subtitles.c | 63 ++ libavfilter/subtitles.h | 44 + libavfilter/vf_overlay_graphicsubs.c | 724 +++++++++++++++ libavfilter/vf_overlay_textsubs.c | 609 ++++++++++++ libavfilter/vf_subtitles.c | 50 +- libavformat/utils.c | 1 + libavutil/Makefile | 6 + {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 | 93 +- tests/ref/fate/sub2video_time_limited | 4 +- 69 files changed, 6571 insertions(+), 1007 deletions(-) create mode 100644 libavfilter/sf_graphicsub2text.c create mode 100644 libavfilter/sf_split_cc.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_overlay_graphicsubs.c create mode 100644 libavfilter/vf_overlay_textsubs.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