FFmpeg Convert RGB to YUV422p Using Scale Filter

Converting RGB video to the YUV422p pixel format is a crucial step for ensuring compatibility with professional video editing software, hardware players, and broadcast pipelines. This article provides a direct, step-by-step guide on how to perform this color space conversion using the FFmpeg scale filter, which ensures high-quality resampling and prevents color shift issues during the transition.

The Basic Conversion Command

To convert an RGB video to YUV422p without changing the original resolution, use the scale filter by setting the output format parameter. Run the following command in your terminal:

ffmpeg -i input_rgb.mp4 -vf "scale=format=yuv422p" output_yuv422p.mp4

Command Breakdown

Simultaneous Scaling and Format Conversion

If you need to resize the video dimensions (width and height) while converting the color space, you can define the resolution parameters directly within the same scale filter:

ffmpeg -i input_rgb.mp4 -vf "scale=1920:1080:format=yuv422p" output_yuv422p.mp4

In this command, 1920:1080 resizes the video to Full HD, while format=yuv422p ensures the output is correctly formatted.

Why Use the Scale Filter Instead of -pix_fmt?

While FFmpeg allows color conversion using the simpler -pix_fmt yuv422p flag, utilizing the scale filter is highly recommended for professional workflows. The scale filter:

  1. Prevents Color Shifts: It allows you to define specific scaling algorithms (like lanczos or bicubic) and color matrices (such as BT.709 for HD video) to maintain visual fidelity.
  2. Enables Single-Pass Processing: You can resize, crop, and convert pixel formats in a single, efficient rendering step, saving processing time and avoiding generation loss.