From patchwork Fri Sep 24 00:30:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soft Works X-Patchwork-Id: 30528 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp986869iob; Thu, 23 Sep 2021 17:30:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2y82zpr18XDQFlEM4Pd8pu4+nTtbSSW1uisCTYt6KDBD6gl1sZsD3cGuYFeNb+QXI9nN7 X-Received: by 2002:a17:906:12d8:: with SMTP id l24mr8153310ejb.126.1632443439271; Thu, 23 Sep 2021 17:30:39 -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 jl17si7511577ejc.417.2021.09.23.17.30.38; Thu, 23 Sep 2021 17:30:39 -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=h8zT9o2E; 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 97BA668A375; Fri, 24 Sep 2021 03:30:34 +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-mw2nam10olkn2075.outbound.protection.outlook.com [40.92.42.75]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C3DCB689CA7 for ; Fri, 24 Sep 2021 03:30:27 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cy6QqhbC+3HprUldTNaokmr4bFxesgmx1isjndyKy54G1Aq/fMpEn01R2E2DChzyzqxb8sjoWBBOlm7kBIJcpVVBGevPocYzmrlzrh9R9rOPZyCtAS/HkqZmU+hzHrsh9ux6tcuwi07HnHf68F/iJ82AMOVwvGKgWnZdbCX1+c6YBo6QJ9EY85yUq/y0mxLBTKVJ1EsU0DQaLJgMg510lBE2fJmyen14HuUToTh8SPAhiQBFCqQEwXLUt3eIgalQ2/lEV5M6Ui71Q0yDJi5f2RV5h8UDk9kd1aO4jyC5HuOw1IvMHIw8ne9Xz1kTyoDLjAt+BLyG3TOQ734lBZ8Aag== 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=eUpQ1gzCYqhvVjou2VUjR0BhHnBNWIaVkZysVeyndug=; b=E4cW+XvcubMYlBp++s7RoRlSuvmA806yo6rI9D6OQC6+NJR6Is4jSR3g4YnA6Tj11Z6Hmra6xc9mFEtHycxOXlsUkGmRRxeuJlVRSYwi7Plqa5n0/TLvRZMy0Hr26PvAi/3Ljq8NjSy4J6bmDLK6ANroGvkunrihSFU05pEdqM0XP97thGqyNziGcQJWt9fJ4KGnYOcjKOhJCj8vV5rMUhsUGUyLxSx/MW/pcunVOdAGmu0z/4GfU1J63jO62Uj01haZiF3g6y7GGY2gQnSpwbY1QWLubnfdzVrx0FqW+vcx4n68rda290W30RSVLk6lJW5dL1vMHLX9An5W2CjKRQ== 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=eUpQ1gzCYqhvVjou2VUjR0BhHnBNWIaVkZysVeyndug=; b=h8zT9o2ESb2bCOM/ucZJoIZIYTzp1qYMXUbZBLR3nxbYLG9R92ux5hUHZy633HmQr6DFPFvClBw//1Ok2lR0qLDBW6j/TeA/HD8eYbvt4K3xX2SAxULNKaisGO3gc+cicG3l8/hgPtEcwANzH1Cw7PtXOiRHULC+MgdXT6cHq/AOP7sRIZFLBczh5KU9ja2v+5SWmJe2SOIlJRIjBBPxgJxL9QECZwRnioz1SoytxTo8AKrL6kWb2elMRXA0vD/HaOJY+JJomr1SzB7h3sUSp9bGExnGee353LBczWyF0sJ3J6jri1BUoELfu7hehZAKCDswzEp3FaYCn1tB+s0nGw== Received: from MN2PR04MB5981.namprd04.prod.outlook.com (2603:10b6:208:da::10) by MN2PR04MB6015.namprd04.prod.outlook.com (2603:10b6:208:d8::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.14; Fri, 24 Sep 2021 00:30:24 +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.015; Fri, 24 Sep 2021 00:30:24 +0000 From: Soft Works To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH v9 00/13] Subtitle Filtering Thread-Index: AQIS5bIzmOvjvTnY/eKOHbVtEHdiDg== Date: Fri, 24 Sep 2021 00:30:24 +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: [lOSmGhjnzhF3bKWbpHADUr7dQn7jsjN4] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f9ae72f1-d24a-4853-9251-08d97ef28014 x-ms-traffictypediagnostic: MN2PR04MB6015: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 7tDXC1ht8Qz1T4TTmr9ZajytLD5fqLW4ZInpM9x+Ixbbh9IXJWNl/duNEzXKLL4kM1zFk5op/bLY9uMEAz50pxDZm6WAu033NUUraq7ybpDMqTtDLg4mQpQQRwMzyN8iEK4dLY9YLRIffQukevyGpEgJVE1y73PXq6lzelJzbCEeq1ZC1IFr9Y+XieGcycJwVzZu/nwRsJPxnjrOROF+j6R+k2tYjl3IKw3Z2TUk2iGANodkIh+1/WxaTB8NU6tGcjHqof4drBv1TEoyjz7tVYkcAqTG60rYNDrMDSvgj7ASLmR/zyV9PU+DLFsIeGVoinouCVfrobLD+0+7LKt0NhIhXTzslnhfgpOLQbRUIQWjYYLS/Mu+HYd/eJF1dUq8iGj2kXM8blQcPU/IX7yGZt3/75bSLxM+HcMWBcGJ2cYJ9wuh3yqDWxdgdS/g/uhU x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: vyu8R7kpV3YRDq7Upjl4qDnueZLQoycpX0fEe0TicZn0sCZZNCjCbPWT8nPl3AttwDFynqoARg2oqFVCGgS74kJwjeQWhjDb8Q27xQI98dnd0BZ0gjwgbUt2kyRLH5kfaCC2O63hnK0wYQqnhaNfFg== 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: f9ae72f1-d24a-4853-9251-08d97ef28014 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2021 00:30:24.4863 (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: MN2PR04MB6015 Subject: [FFmpeg-devel] [PATCH v9 00/13] 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: Yr4WHUlARDdu 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 v8 Update: - Added new subtitle filters: graphicsub2text, censor, show_speaker (see below) - Added parameters to load words from file for textmod and censor - Copied copyright owners from vf_overlay to vf_overlay_graphicsubs - Remove "convenience" pointers (data) from AVSubtitleArea (not needed, will avoid migration errors) - Minor fixes -------------------------------------------------------------- This patchset introduces filtering support for subtitles. Besides the ground work, this patchset includes a range of new filters for subtitle processing: - 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 (13): global: Prepare AVFrame for subtitle handling global: Move ass helper functions to avutil 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) configure | 6 +- doc/filters.texi | 502 +++++++++++++++ fftools/ffmpeg.c | 472 +++++++------- fftools/ffmpeg.h | 14 +- fftools/ffmpeg_filter.c | 207 +++++-- fftools/ffmpeg_hw.c | 2 +- fftools/ffmpeg_opt.c | 3 +- fftools/ffplay.c | 102 ++- fftools/ffprobe.c | 48 +- libavcodec/Makefile | 56 +- libavcodec/ass_internal.h | 68 ++ libavcodec/assdec.c | 2 +- libavcodec/assenc.c | 2 +- libavcodec/avcodec.c | 19 - libavcodec/avcodec.h | 75 +-- libavcodec/ccaption_dec.c | 15 +- libavcodec/decode.c | 51 +- libavcodec/jacosubdec.c | 2 +- libavcodec/microdvddec.c | 7 +- libavcodec/movtextdec.c | 3 +- libavcodec/movtextenc.c | 4 +- libavcodec/mpl2dec.c | 2 +- libavcodec/pgssubdec.c | 1 + libavcodec/realtextdec.c | 2 +- libavcodec/samidec.c | 2 +- libavcodec/srtdec.c | 2 +- libavcodec/srtenc.c | 4 +- libavcodec/subviewerdec.c | 2 +- libavcodec/textdec.c | 2 +- libavcodec/ttmlenc.c | 3 +- libavcodec/utils.c | 11 + libavcodec/webvttdec.c | 2 +- libavcodec/webvttenc.c | 4 +- libavfilter/Makefile | 13 + libavfilter/allfilters.c | 12 + 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 | 322 ++++++++++ libavfilter/sf_split_cc.c | 298 +++++++++ libavfilter/sf_stripstyles.c | 211 +++++++ libavfilter/sf_textmod.c | 719 +++++++++++++++++++++ libavfilter/subtitles.c | 63 ++ libavfilter/subtitles.h | 44 ++ libavfilter/version.h | 2 +- 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 | 63 +- {libavcodec => libavutil}/ass.h | 64 +- {libavcodec => libavutil}/ass_split.c | 12 +- {libavcodec => libavutil}/ass_split.h | 8 +- 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, 5390 insertions(+), 882 deletions(-) create mode 100644 libavcodec/ass_internal.h 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_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 (77%) rename {libavcodec => libavutil}/ass.h (71%) rename {libavcodec => libavutil}/ass_split.c (97%) rename {libavcodec => libavutil}/ass_split.h (96%) create mode 100644 libavutil/subfmt.c create mode 100644 libavutil/subfmt.h