Generate SMPTE Color Bars Using FFmpeg

This article explains how to generate a standard SMPTE color bars test pattern with custom resolution, frame rate, and duration using FFmpeg. By utilizing FFmpeg’s built-in lavfi (Libavfilter) virtual input device and test source filters, you can render calibration-ready video files directly from the command line without needing external media assets.

Basic Command Syntax

FFmpeg provides the smptebars filter for standard-definition color bars and smptehdbars for high-definition color bars compliant with SMPTE RP 219.

To generate a 10-second MP4 video at 1920x1080 resolution and 30 frames per second, run:

ffmpeg -f lavfi -i smptebars=size=1920x1080:rate=30 -t 10 -c:v libx264 -pix_fmt yuv420p output.mp4

Command Breakdown

  • -f lavfi: Specifies the Libavfilter virtual input framework.
  • -i smptebars=...: Calls the SMPTE color bars source filter.
    • size=WIDTHxHEIGHT (or s=WIDTHxHEIGHT): Sets the video frame dimensions (e.g., 1920x1080, 1280x720, 3840x2160).
    • rate=FPS (or r=FPS): Sets the frame rate. You can use whole numbers (e.g., 30, 60) or fractional standards (e.g., 29.97, 24000/1001).
  • -t 10: Sets the total duration to 10 seconds. Without this parameter, FFmpeg generates an infinite stream.
  • -c:v libx264: Encodes the video using the H.264 video codec.
  • -pix_fmt yuv420p: Sets the pixel format to YUV 4:2:0 to ensure playback compatibility across standard media players.
  • output.mp4: The name of the final rendered file.

Generating HD SMPTE Color Bars (SMPTE RP 219)

For modern HD workflows, use the smptehdbars source filter instead. This filter includes the 0% black, -2% black, and +2% black pluge pulses designed for HD monitoring setup:

ffmpeg -f lavfi -i smptehdbars=size=1920x1080:rate=29.97 -t 15 -c:v libx264 -pix_fmt yuv420p smpte_hd.mp4

Adding a 1 kHz Calibration Tone

To create a full reference file with standard 1 kHz reference audio matching the video duration, combine the color bars source with the sine audio source:

ffmpeg -f lavfi -i smptehdbars=size=1920x1080:rate=25 -f lavfi -i sine=frequency=1000:sample_rate=48000 -t 10 -c:v libx264 -pix_fmt yuv420p -c:a aac output_with_audio.mp4