Extract Luma Plane from YUV Video Using FFmpeg
This article provides a quick guide on how to isolate and extract the
luma (Y) plane from a YUV-encoded video using FFmpeg’s
extractplanes filter. You will learn the exact command-line
syntax required to separate the brightness information from color
channels and save the result as a grayscale video.
Understanding the extractplanes Filter
In YUV color spaces, the video signal is split into luma (Y),
representing brightness, and chroma (U and V), representing color. The
extractplanes filter in FFmpeg allows you to extract one or
more of these component planes.
To extract only the luma plane, you use the y
parameter.
The Basic Command
Use the following command to extract the luma plane from your input video:
ffmpeg -i input.mp4 -vf "extractplanes=y" output_luma.mp4Command Breakdown
-i input.mp4: Specifies the path to your input video file.-vf "extractplanes=y": Applies the video filter. Theyargument tells FFmpeg to extract only the luma plane. (Similarly, you could useuorvto extract the chroma planes, ory+u+vto extract all three into separate streams).output_luma.mp4: The resulting output file, which will appear as a grayscale video because it contains only brightness information without color.
Ensuring Correct Pixel Format
By default, extracting the luma plane outputs a video with a
grayscale pixel format (such as gray or
gray8). If your playback destination or editing software
requires a standard YUV format (like yuv420p) even for
grayscale video, you can chain the format filter to the
command:
ffmpeg -i input.mp4 -vf "extractplanes=y,format=yuv420p" output_luma_yuv.mp4This command extracts the luma plane and then encodes it back into a standard YUV420p container, resulting in a black-and-white video compatible with almost all media players.