FFmpeg: Check and Change Pixel Format to yuv422p

This guide explains how to identify the current pixel format of any video file and convert it to the 8-bit yuv422p format using FFmpeg. You will learn the exact command-line instructions needed to inspect your media metadata and execute the color space conversion efficiently.

How to Check the Pixel Format of a Video

Before modifying a video, you should check its current pixel format. The easiest way to do this is by using ffprobe, a tool that comes bundled with FFmpeg.

Run the following command in your terminal:

ffprobe -v error -select_streams v:0 -show_entries stream=pix_fmt -of default=noprint_wrappers=1:nokey=1 input.mp4

Command Breakdown:

  • -v error: Suppresses unnecessary log outputs, showing only errors and your requested information.
  • -select_streams v:0: Selects the first video stream.
  • -show_entries stream=pix_fmt: Directs the tool to only display the pixel format entry.
  • -of default=noprint_wrappers=1:nokey=1: Formats the output to print only the pixel format name (e.g., yuv420p or yuv444p) without any extra labels.

Alternatively, you can run a basic check using ffmpeg:

ffmpeg -i input.mp4

Look for the line starting with Stream #0:0. It will display details about the video codec, resolution, and pixel format inside parentheses (for example, yuv420p(tv, bt709)).


How to Change the Pixel Format to yuv422p

To convert the pixel format of your video to yuv422p (which is an 8-bit YUV format with 4:2:2 chroma subsampling), use the -pix_fmt flag in FFmpeg.

Run this command:

ffmpeg -i input.mp4 -c:v libx264 -pix_fmt yuv422p -c:a copy output.mp4

Command Breakdown:

  • -i input.mp4: Specifies the input video file.
  • -c:v libx264: Re-encodes the video stream using the H.264 codec (you can change this to another codec like libx265 or mpeg4 if required).
  • -pix_fmt yuv422p: Converts the pixel format to 8-bit YUV 4:2:2.
  • -c:a copy: Copies the audio stream directly without re-encoding to save time and preserve quality.
  • output.mp4: The path and name of the newly generated video file.