This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 0b37a6d836441118b2c5a9ac403cdb5ef2a33fc7 Author: Michael Niedermayer <[email protected]> AuthorDate: Sun Sep 20 18:04:14 2026 +0200 Commit: michaelni <[email protected]> CommitDate: Sat Sep 26 11:36:30 2026 +0000 avfilter/vf_subtitles: let the ass filter take its script from an option The new "script" option holds the ASS script inline, as an alternative to reading it from "filename", so an application can render text it generated itself without writing a temporary file first. Assisted-by: Claude --- doc/filters.texi | 6 +++++- libavfilter/vf_subtitles.c | 27 +++++++++++++++++---------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 0407c46917..7257668544 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -8629,9 +8629,13 @@ Substation Alpha) subtitles files. This filter accepts @option{filename}/@option{f}, @option{original_size}, @option{fontsdir}, and @option{alpha} from the @ref{subtitles} filter, plus the -following option: +following options: @table @option +@item script +The ASS script to render, given inline. Exactly one of @option{filename} and +@option{script} must be set. + @item shaping Set the shaping engine. diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c index 72c621a807..be4118ab53 100644 --- a/libavfilter/vf_subtitles.c +++ b/libavfilter/vf_subtitles.c @@ -53,6 +53,7 @@ typedef struct AssContext { ASS_Renderer *renderer; ASS_Track *track; char *filename; + char *script; char *fontsdir; char *charenc; char *force_style; @@ -142,11 +143,6 @@ static av_cold int init(AVFilterContext *ctx) { AssContext *ass = ctx->priv; - if (!ass->filename) { - av_log(ctx, AV_LOG_ERROR, "No filename provided!\n"); - return AVERROR(EINVAL); - } - ass->library = ass_library_init(); if (!ass->library) { av_log(ctx, AV_LOG_ERROR, "Could not initialize libass.\n"); @@ -269,6 +265,7 @@ 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 }, {NULL}, }; @@ -277,19 +274,24 @@ AVFILTER_DEFINE_CLASS(ass); static av_cold int init_ass(AVFilterContext *ctx) { AssContext *ass = ctx->priv; - int ret = init(ctx); + int ret; + if (!ass->filename == !ass->script) { + av_log(ctx, AV_LOG_ERROR, "Exactly one of filename and script must be set\n"); + return AVERROR(EINVAL); + } + ret = init(ctx); if (ret < 0) return ret; /* Initialize fonts */ ass_set_fonts(ass->renderer, NULL, NULL, 1, NULL, 1); - ass->track = ass_read_file(ass->library, ass->filename, NULL); + 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 when reading file '%s'\n", - ass->filename); + 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; @@ -368,6 +370,11 @@ static av_cold int init_subtitles(AVFilterContext *ctx) AVPacket pkt; AssContext *ass = ctx->priv; + if (!ass->filename) { + av_log(ctx, AV_LOG_ERROR, "No filename provided!\n"); + return AVERROR(EINVAL); + } + /* Init libass */ ret = init(ctx); if (ret < 0) -- 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]
