Nodes/MediaForge/πŸ”₯ Burn Subtitle
ComfyUI Node

πŸ”₯ Burn Subtitle

Permanent, styled subtitles baked into the pixels β€” no player toggle involved

By leon80148Β·Created 4 months agoΒ·Updated 2 months agoΒ· 0
πŸ”₯ Burn Subtitle
  • frames
  • audio
  • final_video_path
β—„video_pathinput/sample.mp4β–Ί
β—„srt_pathinput/sample.srtβ–Ί
β—„filename_prefixMediaForge/subtitledβ–Ί
β—„codech264 NVIDIA GPU (h264_nvenc)β–Ί
β—„crf18β–Ί
β—„presetmediumβ–Ί
β—„font(把 .ttf / .otf / .ttc δΈŸι€² plugin/font/ εΎŒι‡ζ–°ζ•΄η†)β–Ί
β—„font_size24β–Ί
β—„font_color_hex#FFFFFFβ–Ί
β—„boldtrueβ–Ί
β—„italicfalseβ–Ί
β—„letter_spacing0.0β–Ί
β—„outline_color_hex#000000β–Ί
β—„outline_width2β–Ί
β—„shadow_depth1β–Ί
β—„border_style1β–Ί
β—„back_color_hex#000000β–Ί
β—„alignmentbottom_center (2)β–Ί
β—„margin_v20β–Ί
β—„margin_l50β–Ί
β—„margin_r50β–Ί
β—„tensor_fps30.0β–Ί
β—„keep_source_audiotrueβ–Ί
β—„target_fps0.0β–Ί
β—„srt_textβ€”β–Ί

MF_BurnSubtitle hard-burns an SRT subtitle file into a video - the words become part of the image, which is exactly what you want for a YouTube upload or a social clip where you can't trust the viewer's player to render captions. It's a thin FFmpeg wrapper under the hood, but the node's real value is that it gives you full ASS-level subtitle styling without you ever writing an ASS file: font, color, outline, shadow, alignment, margins - all as friendly widgets.

This is the one-shot burner. If you're also adding a watermark or BGM, MF_ComposeBurnSubtitle folds the same job into the Compose single-encode pipeline instead. For "I have a video and an SRT, make it one file," this is the simpler node.

How it works

Feed it a video and an SRT, and it runs FFmpeg's subtitles filter with a generated ASS style (your hex colors get converted to ASS's BGR-with-alpha internally, so don't panic when the numbers look "wrong" in a debug print). The frontend picks up .ttf / .otf / .ttc files from the plugin's font/ directory for the font dropdown, and fontTools reads the actual family name out of each file - so drop msjh.ttc in there and it shows up as its proper name. Output follows the pack's standard pattern: output/<filename_prefix>_NNNNN.mp4 with an auto-counter, so repeated runs never clobber each other.

The inputs that matter

  • video_path and srt_path - the obvious two. SRT should be UTF-8.
  • font_size, font_color_hex, outline_width - the three knobs you'll actually touch. #RRGGBB hex for colors. outline_width=2 with a black outline is the read-on-any-background baseline.
  • alignment - nine named positions in numpad layout. bottom_center (2) is the sane default.
  • border_style - 1 is outline+shadow, 3 is an opaque box behind the text (back_color_hex controls the box). The box style is how you survive badly compressed footage.
  • codec / crf / preset - same encoder family as the rest of the pack. Default is the smart pick: h264_nvenc if ffmpeg sees your NVIDIA card, libx264 otherwise. crf isn't unit-for-unit comparable across codec families - treat it as a starting point, not a law.

The interesting optional inputs are the dual-input ones. Wire frames (IMAGE) + tensor_fps + audio from MF_LoadVideoFrames, VHS, or AnimateDiff and the video_path widget hides - the node stages your tensor to a temp file and burns onto that. Or wire srt_text (a STRING) from MF_WhisperTranscribe / MF_TranslateSubtitle and skip the SRT file entirely. keep_source_audio (default on) amixes an external audio pin with the source's own track instead of replacing it.

Output is final_video_path - a STRING, wire it anywhere the pack's file consumers can use it.

Install

Same as the pack - this isn't a separate package:

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

ComfyUI Manager works too: search "MediaForge". The pack's requirements.txt pulls fontTools and the ffmpeg fallback binaries automatically; system ffmpeg is preferred but not required.

Common issues

Font dropdown empty? You haven't put any fonts in <plugin>/font/. Grab msjh.ttc (the readme's default) or any TTF. Filenames containing [ ] ' , ; or : in the path can break the FFmpeg filter graph - the pack escapes these automatically, but if you hand-craft paths with weird characters and hit a filter syntax error, that's what's going on. And if you get a bare RuntimeError: ffmpeg ... failed, scroll up in the console: the last 30 lines of FFmpeg's stderr are printed before the error, and it's usually a bad path, not a codec problem.

CategoryMediaForge/Subtitle

Inputs (27)

NameTypeDefaultDescription
video_pathSTRINGinput/sample.mp4β€”
srt_pathSTRINGinput/sample.srtβ€”
filename_prefixSTRINGMediaForge/subtitledβ€”
codecCOMBOh264 NVIDIA GPU (h264_nvenc)7 options: h264 (libx264), hevc (libx265), av1 (libsvtav1), prores (prores_ks), h264 NVIDIA GPU (h264_nvenc), hevc NVIDIA GPU (hevc_nvenc), +1
crfINT180–51β€”
presetCOMBOmedium9 options: ultrafast, superfast, veryfast, faster, fast, medium, +3
fontCOMBO(把 .ttf / .otf / .ttc δΈŸι€² plugin/font/ εΎŒι‡ζ–°ζ•΄η†)1 options: (把 .ttf / .otf / .ttc δΈŸι€² plugin/font/ εΎŒι‡ζ–°ζ•΄η†)
font_sizeINT248–150β€”
font_color_hexSTRING#FFFFFFβ€”
boldBOOLEANtrueβ€”
italicBOOLEANfalseβ€”
letter_spacingFLOAT0.00–20β€”
outline_color_hexSTRING#000000β€”
outline_widthINT20–10β€”
shadow_depthINT10–10β€”
border_styleINT11–3β€”
back_color_hexSTRING#000000β€”
alignmentCOMBObottom_center (2)9 options: bottom_left (1), bottom_center (2), bottom_right (3), middle_left (4), middle_center (5), middle_right (6), +3
margin_vINT200–500β€”
margin_lINT500–1000β€”
margin_rINT500–1000β€”
framesoptIMAGEβ€”
tensor_fpsoptFLOAT30.01–240β€”
audiooptAUDIOβ€”
keep_source_audiooptBOOLEANtrueβ€”
target_fpsoptFLOAT0.00–240β€”
srt_textoptSTRINGβ€”

Outputs (1)

NameTypeDescription
final_video_pathSTRINGβ€”