(FFmpeg) How to Remove All Colors Except One From a Video?

FFmpeg has a filter called colorhold with documentation that states:

Remove all color information for all RGB colors except for [a] certain one.

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

Figure 63.0: left original / right cyan color hold

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.

	Indicates the colorhold filter name

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

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

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

Love FFmpeg? Grab a copy of FFmpeg For Beginners on Kindle or Paperback to learn over 120 ways to master FFmpeg!

buy now on amazon