Alex Balgavy

Just some stuff about me.

Here's my dotfiles repository.

Check out my blog.

My keys: PGP, SSH

My crypto wallets (BTC, XMR)

ffmpeg how to remove all colors except one from a video

Written by John Riselvato - original link

FFmpeg has a filter called colorhold with documentation that states:

This is incorrect, colorhold does not work this way… well not exactly. It removes colors but it’s completely unpredictable. 

For example, in input.mp4 there are two blue bars on the train. If the exact blue is taken from the video and colorhold is applied, no color is removed. If a pure cyan color is kept with colorhold, the bottom blue bar & red is removed yet the top blue bar is kept and the interior wall colors remain the same. 

Figure 63.0 shows this inconsistency:

  $ ffmpeg -i input.mp4 -vf "colorhold=color=00FFFF:similarity=1" -pix_fmt yuv420p output.mp4

Technically with enough effort and guess work, removing all colors except one is possible with colorhold.

colorhold
    Indicates the colorhold filter name

color
    Indicates the color which isn’t replaced with the color gray

similarity
    Indicates the similar color percentage based on color. The larger the number the larger the similarity (1.0 to 0.1 default 0)

blend
    Indicates the blend percent of gray (1.0 to 0.0 default 0.0)