chromakey=0x1bb247:0.15:0.05 removes the whole backdrop and keeps nearly all of the subject; 0.10 leaves a green fringe, and despill cleans the edges. Keying a 6-second clip on ReelSDK cost under a third of a cent, at $0.02 per compute minute.

Remove a green screen with ffmpeg

chromakey matches in YUV and colorkey in RGB, so colorkey needs about 0.30 where chromakey gets by on 0.15. ReelSDK's API allows both plus despill, and can write a VP9 WebM with real transparency instead of a new background.

GuidesUpdated

chromakey
ffmpeg -i fg.mp4 -i bg.mp4 -filter_complex \
  "[1:v]scale=1280:720,setsar=1[bg];\
   [0:v]chromakey=0x1bb247:0.15:0.05,despill=type=green[fg];\
   [bg][fg]overlay=shortest=1[v]" \
  -map "[v]" -map 1:a -c:v libx264 -crf 20 -c:a aac -shortest keyed.mp4

The background is scaled to the foreground's 1280x720, the green is keyed out and despilled, and the two are laid on top of each other. The audio comes from the background clip.

Variations

The other commands you will need

  1. The same with colorkey

    colorkey compares RGB values. On our clip it needed similarity 0.30 to get close to what chromakey did at 0.15.

    colorkey
    ffmpeg -i fg.mp4 -i bg.mp4 -filter_complex \
      "[1:v]scale=1280:720,setsar=1[bg];\
       [0:v]colorkey=0x1bb247:0.30:0.05,despill=type=green[fg];\
       [bg][fg]overlay=shortest=1[v]" \
      -map "[v]" -map 1:a -c:v libx264 -crf 20 -c:a aac -shortest colorkeyed.mp4
  2. Keep the transparency

    No background: the keyed clip goes into a VP9 WebM with an alpha channel, ready for a browser or an editor.

    alpha webm
    ffmpeg -i fg.mp4 -vf "chromakey=0x1bb247:0.15:0.05,despill=type=green,format=yuva420p" \
      -c:v libvpx-vp9 -b:v 2M -an alpha.webm

The flags

The options in these commands

The options in these commands
FlagWhat it doesUsed here
chromakey=0x1bb247The color to remove, as RGB hex; compared in YUVChromakey, WebM
:0.15Similarity: how far from the key color still counts as keyChromakey, WebM
:0.05Blend: a soft edge instead of a hard cutAll
colorkey=0x1bb247:0.30:0.05The same idea, compared in RGBColorkey
despill=type=greenPulls the green tint out of the subject's edgesAll
scale=1280:720,setsar=1Brings the background to the clip's sizeBackground
overlay=shortest=1Puts the keyed clip on top and ends with the shorter inputBackground
format=yuva420pA pixel format with an alpha channelWebM
-c:v libvpx-vp9VP9 can store that alpha channel in WebM; H.264 cannotWebM

Sources: ffmpeg filters: chromakey, ffmpeg filters: colorkey, ffmpeg filters: despill, checked November 2026.

Pick the key color from the clip

A green screen is never one green. Light falls off across the cloth, so our backdrop ranged from 0x129c3c in the corners to 0x2cc957 in the middle of one frame. Grab a frame with ffmpeg -ss 3 -i fg.mp4 -frames:v 1 frame.png, sample the backdrop in a few places, and key on a value in the middle of the range. We used 0x1bb247.

Finding the similarity

Similarity sets how far from the key color a pixel can be and still be removed: 0.01 matches only the exact color and 1.0 matches everything. We laid each result over magenta and counted the green pixels left in one 1280x720 frame.

At 0.10 with no blend, a few thousand green pixels survived around the edges. At 0.15 with a blend of 0.05, none did, and all but a fraction of a percent of the subject stayed. Going to 0.20 removed nothing more of the green but ate into the subject's edges. Start low and raise it until the green is gone, then stop.

chromakey or colorkey

chromakey works in YUV, the format most video is stored in, and its source code compares only the U and V values of each pixel: the color, not the brightness. That suits a backdrop that is brighter in one place than another. colorkey compares RGB values, where a darker green is further away. On our clip colorkey at 0.15 left about a thousand green pixels; it took 0.30 to get down to a handful.

Edges and spill

Light bouncing off the screen tints the subject's edges green, and the key cannot remove it without removing part of the subject. despill pulls that tint out after keying. The blend value of 0.05 adds a soft edge, so the outline does not look cut out with scissors.

H.264 in MP4 has no alpha channel, so to keep the transparency for later use VP9 in WebM with yuva420p. Our API run of that command wrote a WebM tagged with alpha, with more than nine in ten pixels of a frame transparent.

Without installing ffmpeg

The same command as one API call

Send the same args to POST /v1/ffmpeg with both clip URLs in inputs. chromakey, colorkey and despill are all allowed. Each job runs ffmpeg 8.1 on a fresh machine at $0.02 per compute minute, billed per second; this one finished in about 9 seconds and cost under a third of a cent.

terminalTry it
curl "https://api.reelsdk.com/v1/ffmpeg?wait=60" \
  -H "Authorization: Bearer $REELSDK_KEY" \
  --json '{
    "inputs": {
      "fg.mp4": "https://api.reelsdk.com/f/lib/in/guides/green-screen-monkey.mp4",
      "bg.mp4": "https://api.reelsdk.com/f/lib/demo/landscape.mp4"
    },
    "args": [
      "-i", "fg.mp4", "-i", "bg.mp4", "-filter_complex",
      "[1:v]scale=1280:720,setsar=1[bg];[0:v]chromakey=0x1bb247:0.15:0.05,despill=type=green[fg];[bg][fg]overlay=shortest=1[v]",
      "-map", "[v]", "-map", "1:a", "-c:v", "libx264", "-crf", "20", "-c:a",
      "aac", "-shortest", "keyed.mp4"
    ],
    "outputs": ["keyed.mp4"]
  }'
Our own green-screen render keyed over the Seville clip at 1280x720. The transparent WebM is next to it.Input: green-screen clipalpha.webm (transparent)background clip

FAQ

Questions, answered

How do I remove a green screen with ffmpeg?

Key it and overlay it: ffmpeg -i fg.mp4 -i bg.mp4 -filter_complex "[0:v]chromakey=0x1bb247:0.15:0.05,despill[fg];[1:v][fg]overlay=shortest=1" out.mp4, with your own key color.

Why is there a green outline left?

Raise the similarity a little, add a small blend such as 0.05, and add despill after the key to take the green tint off the edges.

How do I export a video with a transparent background?

Key it, then add format=yuva420p and encode with -c:v libvpx-vp9 into a .webm file. MP4 with H.264 cannot store transparency.

Can I key green screen video with an API?

Yes. POST the same args to https://api.reelsdk.com/v1/ffmpeg with both clip URLs in inputs. It runs ffmpeg 8.1 for $0.02 per compute minute, billed per second.

Ready to build?

Ship video from your app today

Your first $0.50 is free, and one key covers every endpoint.

Moonlit lake with a lit cabin under the mountains