[FFmpeg-user] extract one color channel frames

Moritz Barsnick barsnick at gmx.net
Tue Jan 26 08:57:02 CET 2016


Hi Rik,

On Wed, Jan 20, 2016 at 10:32:43 +0000, Rik Verdonck wrote:
> Now, I actually only need the red channel of my images for downstream
> analysis, and I want the images to be as small as possible without
> losing resolution (for downstream analysis speed). This is where my
> knowledge about image and movie formats becomes a bit wobbly. Is
> there a way I can let ffmpeg output files that are essentially just a
> matrix of red values in 8 bit encoding? I guess the answer lies in
> some kind of color-to-greyscale conversion where the single channel
> in grayscale is just a copy of the red channel of the original frame.
> Any suggestions for ffmpeg code that would do this at once?

I think you are looking for the extractplanes filter:
https://ffmpeg.org/ffmpeg-filters.html#extractplanes

So something like
  [...] -filter_complex 'extractplanes=r[r]' -map '[r]'

If your input is not RGB, but YUV (YCbCr) instead, you may need to
insert the format filter first for conversion. But strictly speaking,
you are then not "extracting" the red plane if you need to create it
first.

Moritz


More information about the ffmpeg-user mailing list