Visit ComfyUI Online for ready-to-use ComfyUI environment
Powerful video processing node for background removal in ComfyUI, leveraging single-frame mask for seamless editing.
MatAnyoneVideoMatting is a powerful node designed for video processing within the ComfyUI framework, specifically aimed at removing backgrounds from videos. This node leverages a single-frame mask to effectively isolate and retain the foreground across all frames of a video, providing a seamless and efficient method for background removal. By utilizing advanced video matting techniques, it ensures that the subject remains clear and distinct, while the background is either removed or replaced with a specified color. This capability is particularly beneficial for AI artists and video editors who need to create professional-quality content without the need for complex manual editing. The node's ability to process videos as batches of images allows for high flexibility and integration into various workflows, making it an essential tool for creative projects that require precise and automated background removal.
This parameter represents the video input as a batch of images, formatted as a tensor with the shape [B, C, H, W], where B is the batch size, C is the number of color channels, H is the height, and W is the width. The values should be in the range [0, 1]. This input is crucial as it provides the raw video data that the node will process to remove the background.
The mask is a tensor that defines the area of interest in the first frame of the video, with a shape of [H, W] or [1, H, W]. The values range from [0, 1], where 1 indicates the foreground and 0 indicates the background. This mask is essential for guiding the node in distinguishing between the subject and the background throughout the video.
This integer parameter specifies the number of initial frames used for warmup iterations, with a default value of 10. It helps the model stabilize its predictions by processing the first frame multiple times, ensuring more accurate background removal in subsequent frames.
The erosion kernel size is an integer that determines the extent of erosion applied to the input mask, with a default value of 10. Erosion helps refine the mask by shrinking the foreground area, which can be useful for removing small artifacts or noise from the mask.
This parameter sets the dilation kernel size, also an integer with a default value of 10. Dilation expands the foreground area in the mask, which can help in ensuring that the entire subject is included in the foreground, especially if the initial mask is too tight.
The red component of the background color, ranging from 0 to 255, with a default value of 120. This parameter allows you to specify the red intensity of the background color that will replace the removed background.
The green component of the background color, ranging from 0 to 255, with a default value of 255. This parameter allows you to specify the green intensity of the background color that will replace the removed background.
The blue component of the background color, ranging from 0 to 255, with a default value of 155. This parameter allows you to specify the blue intensity of the background color that will replace the removed background.
This output is a tensor of shape [B, C, H, W] in the range [0, 1], representing the video frames with the background removed. It contains the isolated subject from each frame, allowing for further processing or integration into new scenes.
The alpha_frames output is a tensor of shape [B, 1, H, W] in the range [0, 1], providing the alpha matte for each frame. This matte indicates the transparency level of each pixel, which is crucial for compositing the foreground onto different backgrounds seamlessly.
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.