← Latest articles

AROUND / EDITORIAL

Building a Practical Video QC Pipeline with FFmpeg and ffprobe

Building a Practical Video QC Pipeline with FFmpeg and ffprobe

In media production, manual Quality Control (QC) is a significant bottleneck. Automating this process using FFmpeg and ffprobe allows engineering teams to catch technical issues, such as codec mismatches, black frames, or audio silence, before assets reach the Media Asset Management (MAM) system.

1. Metadata Inspection with ffprobe

The first step in any QC pipeline is verifying the container and stream technical specifications. Extracting data into JSON allows for programmatic validation against your expected delivery standards.

ffprobe -v error -show_entries stream=codec_name,width,height,avg_frame_rate,duration -of json input.mp4 > metadata.json

By comparing the resulting JSON object against a schema (using tools like jq or a Python script), you can enforce rules like minimum resolution or mandatory H.264/HEVC codec usage.

2. Detecting Technical Faults

Beyond metadata, you must analyze the pixel and audio data. FFmpeg’s filter graph is powerful for this purpose.

Black Frame Detection

Use the blackdetect filter to identify frames below a specific luminance threshold.

ffmpeg -i input.mp4 -vf blackdetect=d=0.5:pic_th=0.98 -f null -

Silence Detection

Similar to black detection, the silencedetect filter monitors audio levels.

ffmpeg -i input.mp4 -af silencedetect=n=-30dB:d=0.5 -f null -

3. Decode Errors and Freezes

Detecting corrupted files often requires attempting a full decode. Using the -f null output flag allows you to "process" the video without writing a file, which is much faster.

ffmpeg -v error -i input.mp4 -f null - 2> errors.log

If the errors.log file is not empty, the stream likely contains corruption that will break downstream transcoders.

4. Trade-offs and Limitations

While powerful, FFmpeg-based QC has limitations. It cannot perform high-level subjective QC (e.g., editorial errors, color grading mistakes, or visual artifact detection like blocking). Furthermore, full-decode analysis is CPU-intensive. For large high-bitrate files, consider sampling frames rather than decoding the entire stream if real-time performance is a requirement.

Integration with MAM

A practical pipeline concludes by wrapping these commands in a worker service (e.g., Python/Celery or Go). Upon successful validation, the service should update the MAM database with technical tags, or move the file to a 'quarantine' folder if QC fails, preventing corrupted assets from propagating through the pipeline.