From patchwork Wed Oct 6 09:12:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soft Works X-Patchwork-Id: 30934 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp174448iob; Wed, 6 Oct 2021 02:13:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxW8ACRS4hnKXaZj1xkpE0VTdWDcYZgmdcud+tnttfsUC8vBJGt0Gt146MAxoy4p7CWKJDq X-Received: by 2002:aa7:cf06:: with SMTP id a6mr32835826edy.108.1633511588443; Wed, 06 Oct 2021 02:13:08 -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 v5si1775470edi.595.2021.10.06.02.12.44; Wed, 06 Oct 2021 02:13:08 -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=NF2fwFTb; 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 46CCD68AA63; Wed, 6 Oct 2021 12:12:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10olkn2081.outbound.protection.outlook.com [40.92.40.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3E4A768A776 for ; Wed, 6 Oct 2021 12:12:33 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nE6CXGFHtnJkMXMgiSdOavIcGP75ERSoe9HznBbMVaghRDZOIeRwWCtyaZUM8aRZohgGPhp9vOmPJ0Wlos2/mfuGSdOyIYYNSeEhglJP357p4NPThtS+/9R1jxFW79Fubj0BoVuH/XlF5GGEjezJTEfE87dJ7eAriJc/20qdTwBBaTsXDfY+2QfNjBzGRF4Bm/9uWq61gvOFZVfD6ftqOwO6XOf7BI6w/O8HTclThrynlisr8Hk5hKYuqQFJUhCLY4K1xxr9/07/MdpisYUbOxbW2YjajrmSOzeiDVFbR3SbHws2Zdo4/lOJosCRH6/wzAzvzEd4bx2hNy4jr4TEWw== 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=leMjPW/jInFMddYvRxku38KUs8/UqCnyzuxZl9XXSYU=; b=U8LGYu92Ulufx1ujdFbXlW+lNbMqhvhXoCql5oi0YQmEVWu2mc09EWEhtTs6STfP92aAKkxYH82FWNYCDTQlzE6Ed8TNZxcd2yuyu1+ws7pN2wjTvXu2Zhe43MTx7DBZiyO0Gxs8Vf/dR9z+U6ok4G1wBmnez7TqAbidqwrKLlFdvpyI/9gMobQKR+M+Xxe518mqzpWu4NvaZhN3nX331oEAso9iodLYuVrRX1q8R1Z6lI6w7Zmt0jiQYFxdldYNW4lv+sj7tcKcYTHnw0HejzTTcBdpU7Mrub6VFm/tL4G5J3CVBiVCbfZ7mEELe3FxksnmouZgycv2ptSO+e8tfg== 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=leMjPW/jInFMddYvRxku38KUs8/UqCnyzuxZl9XXSYU=; b=NF2fwFTbWrllXELmuKPnWf2xNITDzdIFgudjQAcVGILfPLZqE4Z6efhcI1MjFTgLNkV7tFEQ/27GeB13CWFmXRowmWZR71SvTuh5LL9yeWKhjBmt4na6XB2uXQyoU1td5psnJ822dBw7Bol9YP7E21y01Skjn0UKQ8yv8yFPREvYLpkQotMpoO4iGND7+Iw5InzRx2mohcnNLuGDjdniAd+RVda7iugRvvP1h3emfSHQDzodD1+YUGZMAOhvLGLcsh6gXi+UmytRmjFtJXsdo3ECLCTEu70GIJY3z3VP5XD4+Qk3ppOZjhbLC8j16/dw40FS5+bpJnGuwEQlIoJR1g== Received: from MN2PR04MB5981.namprd04.prod.outlook.com (2603:10b6:208:da::10) by MN2PR04MB5902.namprd04.prod.outlook.com (2603:10b6:208:3f::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.15; Wed, 6 Oct 2021 09:12:30 +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.4566.022; Wed, 6 Oct 2021 09:12:30 +0000 From: Soft Works To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH v12 00/14] Subtitle Filtering Thread-Index: AQJLUaXLkDeHiXrHxBpWYVGFJUKucQ== Date: Wed, 6 Oct 2021 09:12:30 +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: [Aqbz0K+MdDlUQK1rmPLJGkx9j/GxVQPV] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: cb37729b-4706-4dbc-ffac-08d988a96c9a x-ms-traffictypediagnostic: MN2PR04MB5902: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: HDmLiW54+N7wy1qfsezGerNKs5oPKRSMefHk0xXUr0231+NRYSfWBxGzNcZnHF5WsGIr6axKp1zWpaEyH+NGkBYcXlxZyt+lhQfI40UGpISqMpQkTU202cyL2UK+ueafuPC+ar9FVJF8zLtX8Jvr9uqXMm8o4K4lV51L19Iv7NGsMPu0fZdYwRFfYEY7hJodX0woKDE1aetX9/ChfvzHn7cGpwJRiE7vwtO1ZYzOw4mY8nurZpomTTuXYEX6e6ZsAOESuEleS9WyLFgwjHIzGDLwegoxyUVeYR9ComQ/8xHRzIsMUSGsxUz7VKwfo1OBDMomkbrhHvzhfPCh1PbLegcy8axEKMpgtt0qWACmohIF8sRHebujJF6gnZN0J01pyhlowL6ZwhdHf+ibw9LCRuPA/BCd72d2AncQ3hqXtC7hMhWMUlrHqDlo8TkPXqdb x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: kbfXiZLoTZ62Q9muidwMT/84hPZ9txDKjAC/rRhQAQ3YPXFpN5GtOZpB7iTBYgUU7lM0u/cpOiLlbAZ40LJzRUCyjc7dACU5ftBCuKI+XvsuqgdMXlKnlel8JngGBHynuWg1AM8R+pIJc21xNPrmwg== 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: cb37729b-4706-4dbc-ffac-08d988a96c9a X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Oct 2021 09:12:30.1244 (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: MN2PR04MB5902 Subject: [FFmpeg-devel] [PATCH v12 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: xCD5NmaibHUE 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 | 509 +++++------ 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/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 | 14 + 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 | 724 +++++++++++++++ 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 | 93 +- tests/ref/fate/sub2video_time_limited | 4 +- 72 files changed, 6665 insertions(+), 1020 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