Skip to main content
Glama

add_watermark

Add a watermark to your video file using a specified image, position, and opacity. Input your video and watermark paths, define the output path, and customize placement and transparency for branding or attribution.

Instructions

Add a watermark to a video

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputPathYesPath to the input video file
opacityNoOpacity of watermark (0.0-1.0)
outputPathYesPath for the output video file
positionNoPosition of watermark (topleft, topright, bottomleft, bottomright, center)
watermarkPathYesPath to the watermark image

Implementation Reference

  • The core handler logic for the 'add_watermark' tool. Validates inputs, determines watermark position, constructs and executes an FFmpeg command to overlay the watermark image on the video with specified opacity, and returns the result.
    case "add_watermark": { const inputPath = validatePath(String(args?.inputPath), true); const watermarkPath = validatePath(String(args?.watermarkPath), true); const outputPath = validatePath(String(args?.outputPath)); const position = String(args?.position || "bottomright"); const opacity = Number(args?.opacity || 0.5); await ensureDirectoryExists(outputPath); // Determine overlay position let overlayPosition = ""; switch (position.toLowerCase()) { case "topleft": overlayPosition = "10:10"; break; case "topright": overlayPosition = "W-w-10:10"; break; case "bottomleft": overlayPosition = "10:H-h-10"; break; case "center": overlayPosition = "(W-w)/2:(H-h)/2"; break; case "bottomright": default: overlayPosition = "W-w-10:H-h-10"; break; } // Improved command with better handling of watermark opacity and format const command = `-i "${inputPath}" -i "${watermarkPath}" -filter_complex "[1:v]format=rgba,colorchannelmixer=aa=${opacity}[watermark];[0:v][watermark]overlay=${overlayPosition}:format=auto,format=yuv420p" -codec:a copy "${outputPath}" -y`; const result = await runFFmpegCommand(command); return { content: [{ type: "text", text: `Watermark added: ${inputPath} → ${outputPath}\n\n${result}` }] }; }
  • The input schema and metadata definition for the 'add_watermark' tool, specifying required and optional parameters.
    { name: "add_watermark", description: "Add a watermark to a video", inputSchema: { type: "object", properties: { inputPath: { type: "string", description: "Path to the input video file" }, watermarkPath: { type: "string", description: "Path to the watermark image" }, outputPath: { type: "string", description: "Path for the output video file" }, position: { type: "string", description: "Position of watermark (topleft, topright, bottomleft, bottomright, center)" }, opacity: { type: "number", description: "Opacity of watermark (0.0-1.0)" } }, required: ["inputPath", "watermarkPath", "outputPath"] } },
  • src/index.ts:46-50 (registration)
    Registration of the tools list, which includes the 'add_watermark' tool definition for MCP discovery.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: toolDefinitions }; });
  • src/index.ts:56-68 (registration)
    Registration of the shared tool call handler that dispatches to the specific 'add_watermark' implementation based on tool name.
    server.setRequestHandler(CallToolRequestSchema, async (request) => { try { return await handleToolCall(request.params.name, request.params.arguments); } catch (error: any) { console.error("Tool execution error:", error.message); return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } });

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sworddut/mcp-ffmpeg-helper'

If you have feedback or need assistance with the MCP directory API, please join our Discord server