This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit c828644f3b9c5cc64370db9500fe63dfdcb1e678
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Sun Sep 20 18:04:56 2026 +0200
Commit:     michaelni <[email protected]>
CommitDate: Sat Sep 26 11:36:30 2026 +0000

    avfilter/vf_subtitles: replace the ass filter's script at runtime
    
    The "script" option becomes a command, so an application can update the
    rendered text while the graph keeps running instead of rebuilding it,
    which would reload the fonts every time.
    
    Assisted-by: Claude
---
 doc/filters.texi           |  5 +++++
 libavfilter/vf_subtitles.c | 39 ++++++++++++++++++++++++++++++---------
 2 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 7257668544..1a9bbeff7e 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -8654,6 +8654,11 @@ and Thai. Requires libass to be built with HarfBuzz.
 The default is @code{auto}.
 @end table
 
+@subsection Commands
+
+This filter supports the @option{script} option as @ref{commands}; the new
+script replaces the one being rendered.
+
 @section atadenoise
 Apply an Adaptive Temporal Averaging Denoiser to the video input.
 
diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c
index be4118ab53..f90ac40e22 100644
--- a/libavfilter/vf_subtitles.c
+++ b/libavfilter/vf_subtitles.c
@@ -265,12 +265,29 @@ static const AVFilterPad ass_inputs[] = {
 static const AVOption ass_options[] = {
     COMMON_OPTIONS
     SHAPING_OPTIONS
-    {"script", "set the ASS script to render instead of reading a file", 
OFFSET(script), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
+    {"script", "set the ASS script to render instead of reading a file", 
OFFSET(script), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS | 
AV_OPT_FLAG_RUNTIME_PARAM },
     {NULL},
 };
 
 AVFILTER_DEFINE_CLASS(ass);
 
+static int read_track(AVFilterContext *ctx)
+{
+    AssContext *ass = ctx->priv;
+    ASS_Track *track = ass->script ? ass_read_memory(ass->library, 
ass->script, strlen(ass->script), NULL)
+                                   : ass_read_file(ass->library, 
ass->filename, NULL);
+
+    if (!track) {
+        av_log(ctx, AV_LOG_ERROR, "Could not create a libass track from %s\n",
+               ass->filename ? ass->filename : "the script");
+        return AVERROR(EINVAL);
+    }
+    if (ass->track)
+        ass_free_track(ass->track);
+    ass->track = track;
+    return 0;
+}
+
 static av_cold int init_ass(AVFilterContext *ctx)
 {
     AssContext *ass = ctx->priv;
@@ -287,14 +304,17 @@ static av_cold int init_ass(AVFilterContext *ctx)
     /* Initialize fonts */
     ass_set_fonts(ass->renderer, NULL, NULL, 1, NULL, 1);
 
-    ass->track = ass->script ? ass_read_memory(ass->library, ass->script, 
strlen(ass->script), NULL)
-                             : ass_read_file(ass->library, ass->filename, 
NULL);
-    if (!ass->track) {
-        av_log(ctx, AV_LOG_ERROR, "Could not create a libass track from %s\n",
-               ass->filename ? ass->filename : "the script");
-        return AVERROR(EINVAL);
-    }
-    return 0;
+    return read_track(ctx);
+}
+
+static int process_command(AVFilterContext *ctx, const char *cmd, const char 
*arg,
+                           char *res, int res_len, int flags)
+{
+    int ret = ff_filter_process_command(ctx, cmd, arg, res, res_len, flags);
+
+    if (ret < 0 || (ret = read_track(ctx)) < 0)
+        return ret;
+    return config_input(ctx->inputs[0]);
 }
 
 const FFFilter ff_vf_ass = {
@@ -307,6 +327,7 @@ const FFFilter ff_vf_ass = {
     FILTER_INPUTS(ass_inputs),
     FILTER_OUTPUTS(ff_video_default_filterpad),
     FILTER_QUERY_FUNC2(query_formats),
+    .process_command = process_command,
 };
 #endif
 

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to