ComfyUI > Nodes > ComfyUI_AudioTools > Add Subtitles To Video

ComfyUI Node: Add Subtitles To Video

Class Name

AddSubtitlesToVideo

Category
🎤MW/MW-Audio-Tools
Author
mw (Account age: 2258days)
Extension
ComfyUI_AudioTools
Latest Updated
2025-05-11
Github Stars
0.03K

How to Install ComfyUI_AudioTools

Install this extension via the ComfyUI Manager by searching for ComfyUI_AudioTools
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI_AudioTools in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Add Subtitles To Video Description

Overlay subtitles onto video frames for enhanced content with precise control over text appearance and synchronization.

Add Subtitles To Video:

The AddSubtitlesToVideo node is designed to enhance video content by overlaying subtitles directly onto video frames. This node is particularly useful for creators who want to add textual information to their videos, such as translations, captions, or annotations, without needing to use external video editing software. By integrating subtitles into the video frames, this node ensures that the text is synchronized with the video content, providing a seamless viewing experience. The node processes video frames stored as tensors and applies subtitles based on specified timestamps, allowing for precise control over when and where the text appears. This functionality is essential for creating accessible content, improving viewer engagement, and enhancing the overall storytelling of video projects.

Add Subtitles To Video Input Parameters:

images

This parameter expects a tensor representing the video frames to which subtitles will be added. The images must be in a format compatible with PyTorch tensors, and the node will process each frame individually to overlay the subtitles. If the input is not a tensor, the node will not execute properly.

subtitles

A string representing a list of dictionaries, where each dictionary contains subtitle text and its corresponding timestamp. The subtitles must be formatted correctly as a list of dictionaries, with each dictionary specifying the text and the start and end times for the subtitle display. This parameter is crucial for ensuring that subtitles appear at the correct time during video playback.

language

This parameter specifies the language of the subtitles, with options such as "类中文字符" and "English_word". The language setting helps the node determine how to wrap text and handle different character sets, ensuring that subtitles are displayed correctly and legibly.

max_words_per_line

An integer that defines the maximum number of words allowed per line in the subtitles. The default value is 12, with a minimum of 1 and a maximum of 30. This parameter helps control the readability of the subtitles by preventing lines from becoming too long.

font_path

A string indicating the file path to the font used for rendering the subtitles. The default is "simhei.ttf". This parameter allows you to customize the appearance of the subtitles by selecting a font that matches the style of your video.

font_size

An integer specifying the size of the font used for the subtitles. The default size is 30, with a range from 1 to 200. Adjusting the font size can help ensure that subtitles are legible and appropriately sized for the video resolution.

font_color

A string representing the color of the subtitle text. The default color is "black". This parameter allows you to choose a font color that contrasts well with the video background, enhancing subtitle visibility.

subtitle_background_color

A string that defines the background color for the subtitles. The default is "#B8860B", and setting it to "None" will result in no background color. This parameter can improve subtitle readability by providing a contrasting background.

y_offset

An integer that adjusts the vertical position of the subtitles on the video frame. The default is 0, with a range from -1000 to 1000. This parameter allows you to position the subtitles higher or lower on the screen as needed.

x_offset

An integer that adjusts the horizontal position of the subtitles on the video frame. The default is 0, with a range from -1000 to 1000. This parameter allows you to shift the subtitles left or right to achieve the desired alignment.

width

An integer representing the width of the video frames. The default is 1024. This parameter is used to calculate the positioning of the subtitles and ensure they are centered correctly.

height

An integer representing the height of the video frames. The default is 1024. This parameter, along with the width, helps determine the placement of the subtitles on the video.

fps

A float indicating the frames per second of the video. The default is 20, with a range from 1 to 240. This parameter is essential for synchronizing the subtitles with the video playback, ensuring they appear at the correct times.

Add Subtitles To Video Output Parameters:

image

The output is a tensor representing the video frames with the added subtitles. This tensor can be used for further processing or saved as a video file. The output ensures that the subtitles are integrated into the video frames, providing a cohesive viewing experience.

Add Subtitles To Video Usage Tips:

  • Ensure that the subtitles are correctly formatted as a list of dictionaries with accurate timestamps to avoid synchronization issues.
  • Choose a font and font size that are legible and appropriate for the video resolution to enhance readability.
  • Use contrasting font and background colors to improve subtitle visibility against the video content.

Add Subtitles To Video Common Errors and Solutions:

Error parsing subtitles: <error_message>

  • Explanation: This error occurs when the subtitles string cannot be parsed into a list of dictionaries, possibly due to incorrect formatting.
  • Solution: Verify that the subtitles are formatted as a valid list of dictionaries, with each dictionary containing the necessary keys for text and timestamps.

Images must be a torch tensor

  • Explanation: This error indicates that the input images are not in the expected tensor format.
  • Solution: Ensure that the video frames are converted to a PyTorch tensor before passing them to the node.

Font file not found

  • Explanation: This error occurs when the specified font file cannot be located at the given path.
  • Solution: Check the font_path parameter to ensure it points to a valid font file accessible by the node.

Add Subtitles To Video Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI_AudioTools
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Playground, enabling artists to harness the latest AI tools to create incredible art.