librav1e Metadata for Strict Broadcast Processing

This article explains how librav1e, the C-compatible API wrapper for the rav1e AV1 encoder, manages the strict metadata required for professional broadcasting. It covers how the library translates colorimetry, high dynamic range (HDR) parameters, and frame-accurate timing data from C-based multimedia frameworks into compliant AV1 bitstreams.

The Role of librav1e in Broadcast Pipelines

In professional broadcasting, maintaining metadata integrity across transcoders, multiplexers, and consumer devices is critical to ensuring consistent color and brightness representation. Because rav1e is written in Rust, C-based broadcasting tools like FFmpeg or GStreamer cannot interface with it directly.

librav1e serves as the crucial translation bridge. It provides a C-compatible API that maps external metadata structures directly into the encoder’s configuration and frame properties, ensuring that essential transmission signaling is preserved without loss.

Mapping Colorimetry and Transfer Characteristics

Strict broadcast standards (such as ITU-R BT.709 for HD and BT.2020 for Ultra HD) require exact color signaling. librav1e handles this by mapping external C-style parameters to the internal ColorDescription struct of rav1e.

The wrapper configures the sequence header Open Bitstream Units (OBUs) with precise indicators for: * Color Primaries: Defines the color gamut (e.g., BT.709, BT.2020). * Transfer Characteristics: Specifies the opto-electronic transfer function (e.g., PQ/SMPTE ST 2084, HLG, or BT.1886). * Matrix Coefficients: Instructs the decoder on how to convert YCbCr back to RGB.

By exposing configuration functions like rav1e_config_set_color_description, the wrapper ensures the encoder writes these parameters directly into the AV1 sequence header, preventing downstream hardware decoders from misinterpreting the color space.

Handling HDR Metadata (SMPTE ST 2086 and CEA-861.3)

For High Dynamic Range (HDR) broadcasting, the encoder must signal mastering display properties and content light levels to prevent clipping on consumer televisions. librav1e provides dedicated functions to ingest this metadata on a sequence or frame level:

The wrapper serializes this data into AV1 Metadata OBUs (specifically of type METADATA_TYPE_HDR_CLL and METADATA_TYPE_HDR_MDCV), ensuring they are packaged synchronously with the corresponding coded video sequence.

Maintaining Frame-Accurate Timing and Structs

Strict broadcast distribution requires flawless audio-video synchronization and frame-accurate splicing. librav1e facilitates this by exposing the rav1e_frame_new and rav1e_send_frame API entry points.

During the ingest phase, each incoming video frame carries opaque presentation timestamps (PTS) and duration values. librav1e ensures that these timestamps bypass the internal temporal filtering of the encoder and emerge untouched in the output packet metadata. This preservation of temporal markers allows broadcast multiplexers to accurately rebuild Presentation Time Stamps and Decoding Time Stamps (DTS) in transport streams like MPEG-TS.