PR #23307 opened by Jun Zhao (mypopydev) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23307 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23307.patch
>From 44ed7dd14729cc2a7cb7362ba11acebf0685485a Mon Sep 17 00:00:00 2001 From: Jun Zhao <[email protected]> Date: Fri, 29 May 2026 00:28:16 +0800 Subject: [PATCH 1/2] lavfi/vf_subtitles: expose shaping option The ass filter exposes libass' shaping mode selection so callers can request complex shaping for scripts such as Arabic. The subtitles filter uses the same renderer path but did not expose the option. This left the zero-initialized shaping field to select ASS_SHAPING_SIMPLE implicitly. Expose the same shaping option for subtitles and default it to auto, matching the ass filter. This allows subtitles=...:shaping=complex to render Arabic lam-alef correctly when libass is built with HarfBuzz support. Signed-off-by: Jun Zhao <[email protected]> --- libavfilter/vf_subtitles.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c index dde45357ce..9586a904f1 100644 --- a/libavfilter/vf_subtitles.c +++ b/libavfilter/vf_subtitles.c @@ -76,6 +76,12 @@ typedef struct AssContext { {"fontsdir", "set the directory containing the fonts to read", OFFSET(fontsdir), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS }, \ {"alpha", "enable processing of alpha channel", OFFSET(alpha), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, FLAGS }, \ +#define SHAPING_OPTIONS \ + {"shaping", "set shaping engine", OFFSET(shaping), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, FLAGS, .unit = "shaping_mode"}, \ + {"auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, INT_MIN, INT_MAX, FLAGS, .unit = "shaping_mode"}, \ + {"simple", "simple shaping", 0, AV_OPT_TYPE_CONST, {.i64 = ASS_SHAPING_SIMPLE}, INT_MIN, INT_MAX, FLAGS, .unit = "shaping_mode"}, \ + {"complex", "complex shaping", 0, AV_OPT_TYPE_CONST, {.i64 = ASS_SHAPING_COMPLEX}, INT_MIN, INT_MAX, FLAGS, .unit = "shaping_mode"}, \ + /* libass supports a log level ranging from 0 to 7 */ static const int ass_libavfilter_log_level_map[] = { [0] = AV_LOG_FATAL, /* MSGL_FATAL */ @@ -262,10 +268,7 @@ static const AVFilterPad ass_inputs[] = { static const AVOption ass_options[] = { COMMON_OPTIONS - {"shaping", "set shaping engine", OFFSET(shaping), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, FLAGS, .unit = "shaping_mode"}, - {"auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, INT_MIN, INT_MAX, FLAGS, .unit = "shaping_mode"}, - {"simple", "simple shaping", 0, AV_OPT_TYPE_CONST, {.i64 = ASS_SHAPING_SIMPLE}, INT_MIN, INT_MAX, FLAGS, .unit = "shaping_mode"}, - {"complex", "complex shaping", 0, AV_OPT_TYPE_CONST, {.i64 = ASS_SHAPING_COMPLEX}, INT_MIN, INT_MAX, FLAGS, .unit = "shaping_mode"}, + SHAPING_OPTIONS {NULL}, }; @@ -309,6 +312,7 @@ const FFFilter ff_vf_ass = { static const AVOption subtitles_options[] = { COMMON_OPTIONS + SHAPING_OPTIONS {"charenc", "set input character encoding", OFFSET(charenc), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS}, {"stream_index", "set stream index", OFFSET(stream_index), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS}, {"si", "set stream index", OFFSET(stream_index), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS}, -- 2.52.0 >From c8de8c2de6d1e5843d1395d597f4cced277131b0 Mon Sep 17 00:00:00 2001 From: Jun Zhao <[email protected]> Date: Mon, 1 Jun 2026 16:28:54 +0800 Subject: [PATCH 2/2] doc/filters: document subtitles filter's shaping option The shaping option is now exposed by both the ass and subtitles filters. Document it under subtitles, update the ass filter description to refer to the shared option set, and note that complex shaping is required for Arabic, Hebrew, Devanagari and Thai and depends on a HarfBuzz-enabled libass build. Signed-off-by: Jun Zhao <[email protected]> --- doc/filters.texi | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 2cae41c7c5..bb55cc70af 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -8611,21 +8611,22 @@ Same as the @ref{subtitles} filter, except that it doesn't require libavcodec and libavformat to work. On the other hand, it is limited to ASS (Advanced Substation Alpha) subtitles files. -This filter accepts the following option in addition to the common options from -the @ref{subtitles} filter: +This filter accepts the same options as the @ref{subtitles} filter: @table @option @item shaping -Set the shaping engine +Set the shaping engine. Available values are: @table @samp @item auto The default libass shaping engine, which is the best available. @item simple -Fast, font-agnostic shaper that can do only substitutions +Fast, font-agnostic shaper that can do only substitutions. @item complex -Slower shaper using OpenType for substitutions and positioning +Slower shaper using OpenType for substitutions and positioning. Required +for correct rendering of complex scripts such as Arabic, Hebrew, Devanagari +and Thai. Requires libass to be built with HarfBuzz. @end table The default is @code{auto}. @@ -23351,6 +23352,23 @@ at least libass release 0.17.0 (or LIBASS_VERSION 0x01600010), @emph{and} libass have been built with libunibreak. The option is enabled by default except for native ASS. + +@item shaping +Set the shaping engine. + +Available values are: +@table @samp +@item auto +The default libass shaping engine, which is the best available. +@item simple +Fast, font-agnostic shaper that can do only substitutions. +@item complex +Slower shaper using OpenType for substitutions and positioning. Required +for correct rendering of complex scripts such as Arabic, Hebrew, Devanagari +and Thai. Requires libass to be built with HarfBuzz. +@end table + +The default is @code{auto}. @end table If the first key is not specified, it is assumed that the first value -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
