{
  "id": 19050147,
  "title": "How to Add a Watermark to a Video With FFmpeg (Sized to the Video, Proven With pytest)",
  "url": "https://urgent.news/2026/11/09/how-to-add-a-watermark-to-a-video-with-ffmpeg-sized-to-the-video",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-09T00:21:18.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/voorai/how-to-add-a-watermark-to-a-video-with-ffmpeg-sized-to-the-video-proven-with-pytest-5253"
  },
  "original_language": "en",
  "account": "To embed a watermark in a video using FFmpeg, feed the logo as a second input and scale it relative to the video width. Lower the alpha channel of the logo and position it using overlay expressions. Preserve the original audio by mapping it with -map 0:a and copying it, so only the picture is re-encoded. The Python wrapper provided above probes the video dimensions and calculates the watermark size based on a specified width ratio, opacity, and margin ratio. It then generates the appropriate FFmpeg command line to produce the watermarked video file.",
  "summary": "To add a watermark to a video with FFmpeg, feed the logo as a second input, scale it relative to the video width, lower its alpha with colorchannelmixer , and place it with overlay using main_w / overlay_w expressions. Map the original audio with -map 0:a? and copy it so only the picture is re-encoded. Below is a ~60-line Python wrapper plus four pytest checks that sample real pixels to prove…",
  "key_points": [
    "FFmpeg used to add watermark to video",
    "Logo scaled relative to video width",
    "Original audio preserved in output"
  ],
  "editors_take": "Automating watermark scaling through Python wrappers allows developers to maintain visual consistency across diverse video dimensions without manually calculating complex FFmpeg overlay expressions for every new file.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}