From 567cc75993289bb5cd86d852b841e85875baf584 Mon Sep 17 00:00:00 2001 From: Camille Date: Fri, 4 Sep 2026 23:27:07 +0200 Subject: [PATCH] feat(effects): Add keyword in dynamictext Having a frame number starting at 1 is useful in some animation workflows to have a more natural numbering of frames. --- src/modules/plus/filter_dynamictext.c | 10 ++++++---- src/modules/plus/filter_dynamictext.yml | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/modules/plus/filter_dynamictext.c b/src/modules/plus/filter_dynamictext.c index a8482e50c..287ef5039 100644 --- a/src/modules/plus/filter_dynamictext.c +++ b/src/modules/plus/filter_dynamictext.c @@ -88,11 +88,11 @@ static void get_timecode_str(mlt_filter filter, strncat(text, s, MAX_TEXT_LEN - strlen(text) - 1); } -static void get_frame_str(mlt_filter filter, mlt_frame frame, char *text) +static void get_frame_str(mlt_filter filter, mlt_frame frame, char *text, int offset) { - int pos = mlt_frame_get_position(frame); + int pos = mlt_frame_get_position(frame) + offset; char s[12]; - snprintf(s, sizeof(s) - 1, "%d", pos); + snprintf(s, sizeof(s), "%d", pos); strncat(text, s, MAX_TEXT_LEN - strlen(text) - 1); } @@ -221,7 +221,9 @@ static void substitute_keywords(mlt_filter filter, char *result, char *value, ml } else if (!strcmp(keyword, "smpte_ndf")) { get_timecode_str(filter, frame, result, mlt_time_smpte_ndf); } else if (!strcmp(keyword, "frame")) { - get_frame_str(filter, frame, result); + get_frame_str(filter, frame, result, 0); + } else if (!strcmp(keyword, "frame+1")) { + get_frame_str(filter, frame, result, 1); } else if (!strncmp(keyword, "filedate", 8)) { get_filedate_str(keyword, filter, frame, result); } else if (!strncmp(keyword, "localfiledate", 13)) { diff --git a/src/modules/plus/filter_dynamictext.yml b/src/modules/plus/filter_dynamictext.yml index 0e0150322..69e03cf09 100644 --- a/src/modules/plus/filter_dynamictext.yml +++ b/src/modules/plus/filter_dynamictext.yml @@ -2,7 +2,7 @@ schema_version: 7.2 type: filter identifier: dynamictext title: Dynamic text -version: 5 +version: 6 copyright: Meltytech, LLC license: LGPLv2.1 language: en @@ -27,6 +27,7 @@ parameters: * #smpte_ndf# - SMPTE non-drop-frame timecode of the frame * #timecode# - same as #smpte_df# * #frame# - frame number of the frame + * #frame+1# - frame number of the frame, starting at 1, not 0 * #filedate# - modification date of the file (GMT) * #localfiledate# - modification date of the file (local) * #localtime# - current system date and time