Skip to content

Instantly share code, notes, and snippets.

@kerbeh
Created September 25, 2018 00:17
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kerbeh/fbe0cd0d89c424708c119e0a0d00ca88 to your computer and use it in GitHub Desktop.
Save kerbeh/fbe0cd0d89c424708c119e0a0d00ca88 to your computer and use it in GitHub Desktop.
Greenscreen chroma key with FFmpeg

##FFmpeg greenscreen process

ffmpeg -hwaccel videotoolbox -i background.jpg -i out.mp4 -filter_complex "[1:v]colorkey=0x34d454:0.3:0.15[ckout];[0:v][ckout]overlay[despill];[despill] despill=green[colorspace];[colorspace]format=yuv420p[out]" -map "[out]" output.mp4

###Explanation

*hwaccel enable hardware accelartion profile videotoolbok is avlaiable on my mac for this codec *-i is the input, the greenscreen video is second and the background image is first *-filter_complex chains up the filters in a string *colorkey provides the color of the green screen in hex, the threshold to match (higher is more) and the blend (higher is more) *overlay overlays the video on the second input *despill removes green artifacts left form the colorkey *format=yuv420p sets a specific color space for dumb players like quicktime *-map puts all the filters together

@dosealas
Copy link

I'm very new to Gitthub, how is the quality? It looks like there aren't many parameters (I have no knowledge of coding etc.) I was wondering from a visual artists point of view. cheers.

@bhuvansam
Copy link

This works fine however am able to see blue patch for first few milliseconds. how to get rid of this?
Screenshot 2019-06-18 at 9 18 59 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment