[FFmpeg-devel] [PATCH v5 00/25] Subtitle Filtering 2022
Soft Works
softworkz at hotmail.com
Sat Jul 2 22:03:07 EEST 2022
From: Paul B Mahol <onemda at gmail.com>
Sent: Saturday, July 2, 2022 6:39 PM
To: FFmpeg development discussions and patches <ffmpeg-devel at ffmpeg.org>
Cc: Michael Niedermayer <michael at niedermayer.cc>; softworkz <softworkz at hotmail.com>; Andriy Gelman <andriy.gelman at gmail.com>; Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
Subject: Re: [FFmpeg-devel] [PATCH v5 00/25] Subtitle Filtering 2022
On Sat, Jun 25, 2022 at 11:58 AM ffmpegagent <ffmpegagent at gmail.com<mailto:ffmpegagent at gmail.com>> wrote:
Subtitle Filtering 2022
=======================
This is a substantial update to the earlier subtitle filtering patch series.
A primary goal has been to address others' concerns as much as possible on
one side and to provide more clarity and control over the way things are
working. Clarity is is specifically important to allow for a better
understanding of the need for a subtitle start pts value that can be
different from the frame's pts value. This is done by refactoring the
subtitle timing fields in AVFrame, adding a frame field to indicate repeated
subtitle frames, and finally the full removal of the heartbeat
functionality, replaced by a new 'subfeed' filter that provides different
modes for arbitrating subtitle frames in a filter graph. Finally, each
subtitle filter's documentation has been amended by a section describing the
filter's timeline behavior (in v3 update).
Subtitle Filtering Demos
========================
I published a demonstration of subtitle filtering capabilities with OCR,
text and bitmap subtitle manipulation involved: Demo 1: Text-Manipulation
with Bitmap Subtitles
[https://github.com/softworkz/SubtitleFilteringDemos/tree/master/Demo1]
v5 - Conversion to Graphic Subtitles, and other enhancements
============================================================
* I'm glad to announce that Traian (@tcoza) has joined the project and
contributed a new 'text2graphicsub' filter to convert text subtitles to
graphic subtitles, which can in turn be encoded as dvd, dvb or x-subs
(and any other encoder for graphic subs that might be added in the
future). This filter closes the last open "gap" in subtitle processing.
* stripstyles filter: now allows very fine-grained control over which ASS
style codes should be preserved or stripped
* stripstyles: do not drop dialog margin values
* subfeed filter: eliminates duplicate frames with duplicate start times
when 'fix_overlap' is specified
* textmod: do not drop effect values
* graphicsub2text: reduce font size jitter
* ass_split: add function to selectively preserve elements when splitting
* add strim, snull and ssink and further unify subtitle frame handling with
audio and video
* ffmpeg_filter: get simple filter notation working for subtitles
v4 - Quality Improvements
=========================
* finally an updated version
* includes many improvements from internal testing
* all FATE tests passed
* all example commands from the docs verified to work
* can't list all the detail changes..
* I have left out the extra commits which can be handled separately, just
in case somebody wonders why these are missing:
* avcodec/webvttenc: Don't encode drawing codes and empty lines
* avcodec/webvttenc: convert hard-space tags to
* avutil/ass_split: Add parsing of hard-space tags (\h)
* avutil/ass_split: Treat all content in curly braces as hidden
* avutil/ass_split: Fix ass parsing of style codes with comments
v3 - Rebase
===========
due to merge conflicts - apologies.
Changes in v2
=============
* added .gitattributes file to enforce binary diffs for the test refs that
cannot be applied when being sent via e-mail
* perform filter graph re-init due to subtitle "frame size" change only
when the size was unknown before and not set via -canvas_size
* overlaytextsubs: Make sure to request frames on the subtitle input
* avfilter/splitcc: Start parsing cc data on key frames only
* avcodec/webvttenc: Don't encode ass drawing codes and empty lines
* stripstyles: fix mem leak
* gs2t: improve color detection
* gs2t: empty frames must not be skipped
* subfeed: fix name
* textmod: preserve margins
* added .gitattributes file to enforce binary diffs for the test refs that
cannot be applied when being sent via e-mail
* perform filter graph re-init due to subtitle "frame size" change only
when the size was unknown before and not set via -canvas_size
* avcodec/dvbsubdec: Fix conditions for fallback to default resolution
* Made changes suggested by Andreas
* Fixed failing command line reported by Michael
Changes from previous version v24:
AVFrame
=======
* Removed sub_start_time The start time is now added to the subtitle
start_pts during decoding The sub_end_time field is adjusted accordingly
* Renamed sub_end_time to duration which it is effectively after removing
the start_time
* Added a sub-struct 'subtitle_timing' to av frame Contains subtitle_pts
renamed to 'subtitle_timing.start_pts' and 'subtitle_timing.duration'
* Change both fields to (fixed) time_base AV_TIMEBASE
* add repeat_sub field provides a clear indication whether a subtitle frame
is an actual subtitle event or a repeated subtitle frame in a filter
graph
Heartbeat Removal
=================
* completely removed the earlier heartbeat implementation
* filtering arbitration is now implemented in a new filter: 'subfeed'
* subfeed will be auto-inserted for compatiblity with sub2video command
lines
* the new behavior is not exactly identical to the earlier behavior, but it
basically allows to achieve the same results
* there's a small remainder, now named subtitle kickoff which serves to get
things (in the filter graph) going right from the start
New 'subfeed' Filter
====================
* a versatile filter for solving all kinds of problems with subtile frame
flow in filter graphs
* Can be inserted at any position in a graph
* Auto-inserted for sub2video command lines (in repeat-mode)
* Allows duration fixup delay input frames with unknown duration and infer
duration from start of subsequent frame
* Provides multiple modes of operation:
* repeat mode (default) Queues input frames Outputs frames at a fixed
(configurable) rate Either sends a matching input frame (repeatedly) or
empty frames otherwise
* scatter mode similar to repeat mode, but splits input frames by
duration into small segments with same content
* forward mode No fixed output rate Useful in combination with duration
fixup or overlap fixup
ffmpeg Tool Changes
===================
* delay subtitle output stream initialization (like for audio and video)
This is needed for example when a format header depends on having
received an initial frame to derive certain header values from
* decoding: set subtitle frame size from decoding context
* re-init graph when subtitle size changes
* always insert subscale filter for sub2video command lines (to ensure
correct scaling)
Subtitle Encoding
=================
* ignore repeated frames for encoding based on repeat_sub field in AVFrame
* support multi-area encoding for text subtitles Subtitle OCR can create
multiple areas at different positions. Previously, the texts were always
squashed into a single area ('subtitle rect'), which was not ideal.
Multiple text areas are now generally supported:
* ASS Encoder Changed to use the 'receive_packet' encoding API A single
frame with multiple text areas will create multiple packets now
* All other text subtitle encoders A newline is inserted between the text
from multiple areas
graphicsub2text (OCR)
=====================
* enhanced preprocessing
* using elbg algorithm for color quantization
* detection and removal of text outlines
* map-based identification of colors per word (text, outline, background)
* add option for duration fixup
* add option to dump preprocessing bitmaps
* Recognize formatting and apply as ASS inline styles
* per word(!)
* paragraph alignment
* positioning
* font names
* font size
* font style (italic, underline, bold)
* text color, outline color
Other Filter Changes
====================
* all: Make sure to forward all link properties (time base, frame rate, w,
h) where appropriate
* overlaytextsubs: request frames on the subtitle input
* overlaytextsubs: disable read-order checking
* overlaytextsubs: improve implementation of render_latest_only
* overlaytextsubs: ensure equal in/out video formats
* splitcc: derive framerate from realtime_latency
* graphicsub2video: implement caching of converted frames
* graphicsub2video: use 1x1 output frame size as long as subtitle size is
unknown (0x0)
Plus a dozen of things I forgot..
softworkz (24):
avcodec,avutil: Move enum AVSubtitleType to avutil, add new and
deprecate old values
avutil/frame: Prepare AVFrame for subtitle handling
avcodec/subtitles: Introduce new frame-based subtitle decoding API
avcodec/libzvbi: set subtitle type
avfilter/subtitles: Update vf_subtitles to use new decoding api
avcodec,avutil: Move ass helper functions to avutil as avpriv_ and
extend ass dialog parsing
avcodec/subtitles: Replace deprecated enum values
fftools/play,probe: Adjust for subtitle changes
avfilter/subtitles: Add subtitles.c for subtitle frame allocation
avfilter/avfilter: Handle subtitle frames
avfilter/avfilter: Fix hardcoded input index
avfilter/sbuffer: Add sbuffersrc and sbuffersink filters
avfilter/overlaygraphicsubs: Add overlaygraphicsubs and
graphicsub2video filters
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
avfilter/subfeed: add subtitle feed filter
avfilter/snull,strim: Add snull and strim filters
avcodec/subtitles: Migrate subtitle encoders to frame-based API
fftools/ffmpeg: Introduce subtitle filtering and new frame-based
subtitle encoding
avcodec/dvbsubdec: Fix conditions for fallback to default resolution
Can this be properly finally be fully reviewed and accepted?
Otherwise if its kept mainly ignored than it should be regarded as spam.
Current status quo is bad.
Do you think the patchset is bad or the situation is bad?
In the latter case I agree.
I would ask everybody to voice their concerns and objections so we
can get those addressed.
Thanks,
softworkz
More information about the ffmpeg-devel
mailing list