Warm tip: This article is reproduced from stackoverflow.com, please click
ffmpeg chromakey

Chromakey filter to display transparent keyboard while recording game screen using ffmpeg

发布于 2020-03-29 20:59:28

I'm trying to display a transparent keyboard like this one (he is using OBS studio): https://www.youtube.com/watch?v=6RCXyh2aICY

So I'm setting all "NohBoard v1.2.2" colors to green (0x00FF00), except the letters, then:

ffmpeg -y -f gdigrab -framerate 30 -draw_mouse 0 -i title="NohBoard v1.2.2" keyboard.mp4
ffmpeg -y -i keyboard.mp4 -c: png -vf "chromakey=0x00FF00:similarity=.200" keyboard1.mp4
ffmpeg -y -i gameplay.avi -i keyboard1.mp4 -filter_complex "[1:v] scale=560x180 [kb]; [0:v][kb] overlay=x=W-w-520:y=H-h-0 [done]" -shortest -map [done] test.mkv

Everything works great so far, but can I use 1 command for this ?

Questioner
captain_majid
Viewed
76
Gyan 2020-01-31 19:14

Simply use the gdi cap as the first input and run colorkey* before scaling.

ffmpeg -y -i gameplay.avi -f gdigrab -framerate 30 -draw_mouse 0 -i title="NohBoard v1.2.2" -filter_complex "[1:v]colorkey=0x00FF00:similarity=.200,scale=560x180 [kb]; [0:v][kb] overlay=x=W-w-520:y=H-h-0 [done]" -shortest -map [done] test.mkv

  • gdigrab sends RGB frames, so colorkey will be quicker than chromakey which will require conversion to YUV pixels before keying.