ffmpegchromakey

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


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 ?


Solution

  • 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