Guide
Put a green screen meme over a video with FFmpeg
One FFmpeg command keys a green screen meme over any photo or video: chromakey removes the green, overlay puts the clip on your background, and -map 1:a? keeps the clip's sound. Here it is for a vertical 1080×1920 video:
ffmpeg -loop 1 -i background.jpg -i greenscreen.mp4 -filter_complex \
"[0:v]scale=1080:1920:force_original_aspect_ratio=increase,crop=1080:1920,setsar=1[bg];\
[1:v]chromakey=0x00ff00:0.3:0.08,scale=1080:-2[fg];\
[bg][fg]overlay=(W-w)/2:H-h:shortest=1,format=yuv420p[v]" \
-map "[v]" -map "1:a?" -c:v libx264 -crf 20 -c:a aac meme.mp4The rest of this guide gets you a clip, explains each part, and covers video backgrounds, mixed audio, captions, other key colors and green edges. Everything here was run with FFmpeg 7.1 on a clip from the API.
1Get a green screen clip
Any green screen video works. To search for one, the Green Screen Memes API has over 2,000 reaction meme clips, most with sound; a free Sandbox key covers 50 downloads a month. Search by the feeling or action you want, and list what came back (needs curl and jq):
export GSM_API_KEY=gsm_live_... # free Sandbox key from https://api.greenscreenmemes.app/dashboard
curl -fsS -G -H "Authorization: Bearer $GSM_API_KEY" \
--data-urlencode "q=side eye" --data-urlencode "limit=3" \
https://api.greenscreenmemes.app/v1/memes > results.json
jq -r '.data[] | "\(.id) \(.chromaKeyColor) \(.durationSeconds)s"' results.jsonTung Tung Side Eye green 2s
Dog giving awkward side eye green 6s
Guy giving a sideeye green 6sEach result has a videoUrl, its chromaKeyColor, durationSeconds and a thumbnailUrl to look at before you choose. Download the first one (change 0 to pick another):
# Signed link, good for about 6 hours: keep the file, not the link.
curl -fsSL -o greenscreen.mp4 "$(jq -r '.data[0].videoUrl' results.json)"Links expire after a few hours. For a fresh one, fetch the clip again by id with GET /v1/memes/{id}.
2Key it over a photo
ffmpeg -loop 1 -i background.jpg -i greenscreen.mp4 -filter_complex \
"[0:v]scale=1080:1920:force_original_aspect_ratio=increase,crop=1080:1920,setsar=1[bg];\
[1:v]chromakey=0x00ff00:0.3:0.08,scale=1080:-2[fg];\
[bg][fg]overlay=(W-w)/2:H-h:shortest=1,format=yuv420p[v]" \
-map "[v]" -map "1:a?" -c:v libx264 -crf 20 -c:a aac meme.mp4What each part does:
-loop 1 -i background.jpgturns the photo into an endless video;shortest=1stops at the end of the clip.scale=1080:1920:force_original_aspect_ratio=increase,crop=1080:1920fills a vertical 9:16 frame without stretching the photo.chromakey=0x00ff00:0.3:0.08makes the green transparent.0.3is the similarity (how far from pure green still counts as green) and0.08the blend (how soft the edge is).scale=1080:-2makes the clip full width; use a smaller width for a smaller clip.overlay=(W-w)/2:H-hcenters the clip at the bottom. It's x:y, sooverlay=0:0puts it at the top left.format=yuv420pand-c:v libx264make an MP4 that plays everywhere, phones included.-map "1:a?"keeps the clip's sound, and the?means a silent clip doesn't fail.
3Over a video, with both soundtracks
For a video background, swap -loop 1 for -stream_loop -1 so a short background loops for as long as the clip runs, and mix the background's sound in quietly under the clip's:
ffmpeg -stream_loop -1 -i background.mp4 -i greenscreen.mp4 -filter_complex \
"[0:v]scale=1080:1920:force_original_aspect_ratio=increase,crop=1080:1920,setsar=1[bg];\
[1:v]chromakey=0x00ff00:0.3:0.08,scale=1080:-2[fg];\
[bg][fg]overlay=(W-w)/2:H-h:shortest=1,format=yuv420p[v];\
[0:a]volume=0.35[bga];[1:a][bga]amix=inputs=2:duration=first:normalize=0[a]" \
-map "[v]" -map "[a]" -c:v libx264 -crf 20 -c:a aac meme.mp4volume=0.35sets the background's level; the clip stays at full volume.amix=…:duration=firstends the audio with the clip, likeshortest=1does for the picture.normalize=0needs FFmpeg 5 or later.amixneeds both files to have sound. If the background is silent, drop the audio part of the graph and use-map "[v]" -map "1:a?", as in the photo recipe.
4Add a caption
Add drawtext after format=yuv420p. It doesn't wrap text, so use one drawtext per line, about 100 px apart, and keep each line under about 26 characters:
ffmpeg -loop 1 -i background.jpg -i greenscreen.mp4 -filter_complex \
"[0:v]scale=1080:1920:force_original_aspect_ratio=increase,crop=1080:1920,setsar=1[bg];\
[1:v]chromakey=0x00ff00:0.3:0.08,scale=1080:-2[fg];\
[bg][fg]overlay=(W-w)/2:H-h:shortest=1,format=yuv420p,\
drawtext=text='when the invoice':fontcolor=white:fontsize=64:box=1:boxcolor=black:boxborderw=18:x=(w-text_w)/2:y=200,\
drawtext=text='arrives':fontcolor=white:fontsize=64:box=1:boxcolor=black:boxborderw=18:x=(w-text_w)/2:y=300[v]" \
-map "[v]" -map "1:a?" -c:v libx264 -crf 20 -c:a aac meme.mp4Some FFmpeg builds can't find a default font; add fontfile=/path/to/font.ttf to each drawtext. An apostrophe in the text needs escaping, so it's easier to leave it out or use a typographic one (’).
5Blue and red screens
Most clips are on green, a few on blue or red. The API's chromaKeyColor tells you which, so swap the color in chromakey:
chromaKeyColor | Filter |
|---|---|
green | chromakey=0x00ff00:0.3:0.08 |
blue | chromakey=0x0000ff:0.3:0.08 |
red | chromakey=0xff0000:0.3:0.08 |
none | No key: drop chromakey and use the clip as it is |
6Fixing green edges
- A green fringe stays: raise the similarity a little, from
0.3to0.35. - The subject loses color or gets holes: lower it, to
0.25. - A green tint on hair or edges: add
despillright after the key:
[1:v]chromakey=0x00ff00:0.3:0.08,despill=type=green,scale=1080:-2[fg];\Check the clip's thumbnail before you commit to it: most clips are clean cut-outs, but a few are a framed video on green, or a head-and-shoulders shot that ends partway down the frame.
7Doing it from an AI agent
Over MCP, the get_green_screen tool returns these commands already filled in for the clip: howToComposite.overImage and overVideo, with the right key color, the download command and notes on captions and placement. An agent with a shell (Claude Code, Cursor) can run them as they are.
claude mcp add --transport http green-screen-memes https://api.greenscreenmemes.app/mcp \
--header "Authorization: Bearer $GSM_API_KEY"Before you publish
These are internet memes: Green Screen Memes makes the green screen versions, but the original footage isn't ours and isn't licensed with the clips, so how you use one is up to you. On Starter and up you can publish videos with them, for yourself or clients. Don't put clips of identifiable people in paid ads, sponsored posts or endorsements; animals, objects and cartoons are fine there. The terms have the details.
Shell scripts for all of this (search, download, key over a photo or a video) are in the examples on GitHub. Rendering in React instead? See the Remotion guide.
Get a free key
Sandbox: 50 video downloads and 30,000 calls a month, for building and testing.