Back to KB
Difficulty
Intermediate
Read Time
9 min

Build a per-title bitrate ladder in 80 lines of FFmpeg + VMAF

By Codcompass TeamΒ·Β·9 min read

Content-Aware Encoding: Building Per-Title Bitrate Ladders with VMAF and FFmpeg

Current Situation Analysis

Static bitrate ladders have been the industry standard for over a decade. They assign identical resolution and bitrate rungs to every asset in a catalog, regardless of motion complexity, texture density, or scene transition frequency. This approach simplifies CDN configuration and packaging pipelines, but it introduces a fundamental inefficiency: bandwidth allocation is decoupled from perceptual quality requirements.

Low-motion content (interviews, corporate training, static UI demos) receives excessive bits at higher resolutions, while high-motion content (sports, action sequences, fast-paced gaming) suffers from macroblocking and banding at the same rungs. The problem is rarely addressed because the compute overhead of a probe pass was historically prohibitive, and the perceived ROI was difficult to quantify without perceptual metrics.

Modern tooling has shifted this calculus. FFmpeg 7.0 ("Dijkstra") introduced fully parallelized transcoding components, reducing probe pass duration by 40-60% on multi-core systems. Simultaneously, VMAF (Video Multi-Method Assessment Fusion) provides a standardized, 0-100 perceptual quality score that correlates strongly with human opinion. When combined, these technologies enable data-driven ladder construction. Production deployments consistently report 30-40% egress reduction for static or low-motion catalogs, with zero measurable degradation in viewer experience. The barrier is no longer technical feasibility; it's pipeline integration and operational discipline.

WOW Moment: Key Findings

The core insight of per-title encoding is that not all bitrate increments yield proportional quality gains. By mapping encoded renditions against their VMAF scores, you can identify the exact point where additional bandwidth produces diminishing returns. Dropping those rungs shifts CDN spend from wasted bits to actual quality preservation.

ApproachPeak BitrateAvg VMAF (Top Rung)Egress Cost (per 1M min)Compute Overhead
Static 2019 Ladder6,000 kbps95.8$420Baseline
Per-Title (Low-Motion)3,500 kbps95.1$245+12% probe time
Per-Title (High-Motion)5,800 kbps94.7$395+15% probe time

The data reveals a critical operational truth: per-title encoding is not a universal cost-cutter. It is a precision instrument. For uniform, low-complexity catalogs, the bandwidth delta is substantial. For high-complexity assets, the ladder naturally converges toward static configurations, preserving quality where it matters. The real value emerges when you treat ladder construction as a continuous measurement problem rather than a static configuration file.

Core Solution

Building a per-title ladder requires four distinct phases: probe grid definition, parallel transcoding, perceptual scoring, and mathematical optimization. The following implementation uses Python 3.11+ with libvmaf and FFmpeg 7.0. It is structured for production extensibility, not just demonstration.

1. Environment Preparation

Ensure your FFmpeg build includes libvmaf. Verify with:

ffmpeg -version | grep -i vmaf
ffmpeg -filters | grep libvmaf

Install Python dependencies:

pip install click ffmpeg-python rich

2. Probe Grid Definition

Instead of hardcoding values, we define a structured matrix that separates resolution constraints from bitrate targets. This allows future expansion to AV1/HEVC profiles without rewriting core logic.

from dataclasses import dataclass
from typing import List

@dataclass(frozen=True)
class EncodingCandidate:
    resolution_w: int
    resolution_h: int
    target_bitrate_kbps: int

    @property
    def identifier(self) -> str:
        return f"{self.resolution_h}p_{self.target_bitrate_kbps}k"

PROBE_MATRIX: List[EncodingCandidate] = [
  

πŸŽ‰ Mid-Year Sale β€” Unlock Full Article

Base plan from just $4.99/mo or $49/yr

Sign in to read the full article and unlock all 635+ tutorials.

Sign In / Register β€” Start Free Trial

7-day free trial Β· Cancel anytime Β· 30-day money-back