FFmpeg Removelogo: Remove Logos with a Bitmap Mask

This guide explains how to effectively use the removelogo filter in FFmpeg to erase static on-screen watermarks, channel bugs, and logos using a grayscale bitmap mask. You will learn the requirements for creating an accurate mask image, the exact FFmpeg command syntax needed to apply the filter, and best practices to ensure seamless video output without re-encoding audio unnecessarily.

1. How the removelogo Filter Works

The removelogo video filter removes logos by interpolating the pixels covered by a mask with the surrounding image data. Unlike the delogo filter—which only supports basic rectangular coordinates—removelogo accepts an external image mask, allowing you to target complex, irregularly shaped logos.

The mask dictates which pixels FFmpeg will replace:

  • Pure Black (#000000 / RGB 0,0,0): Video pixels that remain untouched.
  • Non-Black / White (#FFFFFF / RGB 255,255,255): Logo pixels that FFmpeg will suppress and interpolate from surrounding pixel data.

2. Creating the Bitmap Mask

To achieve clean results, the mask must meet two strict criteria:

  1. It must have the exact same resolution (width and height) as the source video.
  2. It should be a standard image format such as BMP, PNG, or PBM.

Step to create the mask:

  1. Export a reference frame containing the logo:

    ffmpeg -ss 00:01:00 -i input.mp4 -frames:v 1 reference.png
  2. Open reference.png in an image editor (such as GIMP or Photoshop).

  3. Fill the entire canvas with pure black.

  4. Paint over the logo shape using solid white.

  5. Save the output file as a 24-bit or 8-bit bitmap (e.g., logo_mask.bmp).

3. Applying the removelogo Command

Once the mask is saved in your working directory, apply the filter using the -vf flag:

ffmpeg -i input.mp4 -vf "removelogo=logo_mask.bmp" -c:v libx264 -crf 18 -c:a copy output.mp4

Breakdown of the Parameters:

  • -i input.mp4: Specifies the input video file.
  • -vf "removelogo=logo_mask.bmp": Invokes the removelogo filter and points to your prepared mask file.
  • -c:v libx264: Sets the video codec to H.264 for encoding the modified video stream.
  • -crf 18: Sets a visually lossless Constant Rate Factor to maintain high video quality.
  • -c:a copy: Copies the audio stream directly without re-encoding to save processing time and preserve audio fidelity.
  • output.mp4: The resulting output file name.

4. Tips for Best Results

  • Mask Precision: Make the white mask area only as large as the logo itself. If the white area extends too far into the background, the interpolation effect will produce unnecessary blurriness.
  • Aspect Ratios: If your source video has non-square pixels (Sample Aspect Ratio is not 1:1), make sure your exported frame and mask maintain the exact pixel storage resolution rather than the display aspect ratio.