[FFmpeg-user] Remove everything but a single color (range)

Hans Carlson forbyta at gmx.com
Sun Mar 15 02:58:25 EET 2020


Is it possible to "remove" everything in a video except a specific color 
(or maybe a range... ie close to a specific color)?

By "remove" I mean covert every that is NOT the color(s) I want to black 
or transparent.

I have a video that contains a yellowish box that moves about the screen. 
I want to isolate ONLY the yellowish box.  Everything else should become 
black or transparent.  The specific color is "fbed54" according to the 
color picker in Gimp.

FYI. My knowledge of "colors" in general is extremely limited... let's put 
it this way, I'm pretty sure RGB stands for Red Green Blue... that's about 
the extent of it.   So, a specific example would be very helpful.

$ ffmpeg -i sample.mkv
ffmpeg version N-96974-g425b6a9a2c Copyright (c) 2000-2020 the FFmpeg developers
   built with gcc 9 (GCC)
   configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-static --disable-shared --disable-debug --enable-libass --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-openssl --enable-libbluray --enable-libcdio
   libavutil      56. 42.100 / 56. 42.100
   libavcodec     58. 75.100 / 58. 75.100
   libavformat    58. 41.100 / 58. 41.100
   libavdevice    58.  9.103 / 58.  9.103
   libavfilter     7. 77.100 /  7. 77.100
   libswscale      5.  6.101 /  5.  6.101
   libswresample   3.  6.100 /  3.  6.100
   libpostproc    55.  6.100 / 55.  6.100
Input #0, matroska,webm, from 'sample.mkv':
   Metadata:
     ENCODER         : Lavf58.29.100
   Duration: 00:01:28.33, start: -0.051000, bitrate: 3242 kb/s
     Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1600x900 [SAR 1:1 DAR 16:9], 30.30 fps, 30.30 tbr, 1k tbn, 60 tbc (default)
     Metadata:
       DURATION        : 00:01:28.333000000
     Stream #0:1: Audio: vorbis, 48000 Hz, stereo, fltp (default)
     Metadata:
       DURATION        : 00:01:28.249000000
At least one output file must be specified


More information about the ffmpeg-user mailing list