Nodes/MediaForge/✏️ Compose Overlay Text
ComfyUI Node

✏️ Compose Overlay Text

Lower-thirds, titles, and marquees — with position math that animates

By leon80148·Created 4 months ago·Updated 2 months ago· 0
✏️ Compose Overlay Text
  • overlays
  • overlays
textHello MediaForge
x_expr(w-text_w)/2
y_exprh-text_h-40
font(把 .ttf / .otf / .ttc 丟進 plugin/font/ 後重新整理)
fontsize36
fontcolorwhite
borderw2
bordercolorblack
effectnone
effect_duration1.5
start_sec0.0
end_sec0.0

MF_ComposeOverlayText puts text on top of a video inside MediaForge's Compose chain - titles, lower-thirds, episode markers, animated reveals. It's the drawtext node, but the design hides most of FFmpeg's sharp edges behind defaults that are actually good: the default position expression is "horizontally centered, 40px above the bottom edge," which is a ready-made lower-third.

The clever bit is that x_expr and y_expr are strings evaluated per-frame at encode time. That's what makes this node more than a text stamp. Position can be a function of t (timestamp), n (frame number), w/h (frame size), or text_w/text_h (the rendered text's own size - so centering stays correct when you change fontsize). A vertical bob, a fly-in, a marquee scroll - those are all just expressions. For the common cases there's an effect dropdown (slide_in_left|right|top|bottom, marquee_horizontal) that wraps the motion for you and treats your x_expr/y_expr as the resting anchor.

How it works

It appends a drawtext op to the MF_COMPOSE_OPS chain. Text is passed via textfile= internally, which is why apostrophes, %, and newlines don't blow up your filter graph. MF_ComposeVideo compiles the chain into the single-encode graph.

The inputs that matter

  • text - the words. Multiline is fine.
  • x_expr / y_expr - position math. The defaults are (w-text_w)/2 and h-text_h-40. Want top-left with padding? 30 / 30. Center of screen? (w-text_w)/2 / (h-text_h)/2.
  • effect - none uses your expressions verbatim; slide_in_* and marquee_horizontal add motion. effect_duration is the slide-in time (or seconds per marquee cycle).
  • fontsize, fontcolor, borderw - size, color (FFmpeg name or #RRGGBB hex), outline.
  • start_sec / end_sec - visibility window; both 0 = always visible.

Optional overlays chains upstream; output overlays feeds the next overlay or MF_ComposeVideo.

Install

Part of MediaForge:

cd ComfyUI/custom_nodes
git clone https://github.com/leon80148/comfyui_MediaForge.git
# restart ComfyUI

Or ComfyUI Manager → "MediaForge". Fonts come from the plugin's font/ folder; if it's empty, ComposeVideo falls back to a system font.

Common issues

The one real trap is expression syntax: an unclosed paren or a variable that doesn't exist fails at encode time, not when you type it. Start from the working defaults and make small edits. And remember text_w/text_h only exist once the filter runs - you can't preview them in a text box. If text overlaps UI you care about, the h-text_h-40 default accounts for the text's own height; changing fontsize keeps centering correct but may change the bottom offset visually. Emoji in text is a coin flip depending on font - use a font that has the glyphs, or it renders as tofu boxes.

CategoryMediaForge/Compose

Inputs (13)

NameTypeDefaultDescription
textSTRINGHello MediaForge
x_exprSTRING(w-text_w)/2
y_exprSTRINGh-text_h-40
fontCOMBO(把 .ttf / .otf / .ttc 丟進 plugin/font/ 後重新整理)1 options: (把 .ttf / .otf / .ttc 丟進 plugin/font/ 後重新整理)
fontsizeINT368–300
fontcolorSTRINGwhite
borderwINT20–20
bordercolorSTRINGblack
effectCOMBOnone6 options: none, slide_in_left, slide_in_right, slide_in_top, slide_in_bottom, marquee_horizontal
effect_durationFLOAT1.50.1–60
start_secFLOAT0.00–36000
end_secFLOAT0.00–36000
overlaysoptMF_COMPOSE_OPS

Outputs (1)

NameTypeDescription
overlaysMF_COMPOSE_OPS