Skip to content

Support additional image file extensions for gr.Video watermark (e.g. WebP, GIF, BMP) #12964

@dataCenter430

Description

@dataCenter430
  • I have searched to see if a similar issue already exists.

Is your feature request related to a problem? Please describe.
Yes. The gr.Video component’s watermark option only allows a hardcoded set of image extensions. In gradio/components/video.py (around lines 207–219), validation is:

# TODO: Check other image extensions to see if they work.
valid_watermark_extensions = [".png", ".jpg", ".jpeg"]
if self.watermark.watermark is not None:
    ...
    if Path(self.watermark.watermark).suffix not in valid_watermark_extensions:
        raise ValueError(
            f"Watermark file does not have a supported extension. "
            f"Expected one of {','.join(valid_watermark_extensions)}. "
            f"Received: {Path(self.watermark.watermark).suffix}."
        )

Problems this causes:

  1. Unnecessary restriction — FFmpeg (used for the overlay) supports many image formats (e.g. WebP, GIF, BMP, TIFF). Users with WebP or other common formats get a clear error instead of the watermark working.
  2. Inconsistent with docs — The docstring says “Valid formats for the image are: jpeg, png.” Expanding support would require updating the docs, but the real issue is the code restrictiveness.
  3. Poor UX — Rejecting valid image files by extension alone forces users to convert to PNG/JPEG even when the pipeline could accept more formats.

So the limitation is mostly from the current allowlist and the TODO, not from a known technical constraint.


Describe the solution you'd like
Test which image formats FFmpeg’s overlay filter accepts for the watermark (e.g. WebP, GIF, BMP, TIFF, and any others that are safe and common). Add those extensions to valid_watermark_extensions (or a shared constant) so they are accepted by the Python validation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions