Can librav1e Multiplex Audio and Video?
This article explains whether librav1e can natively
multiplex audio streams with video or if its functionality is strictly
limited to video processing. You will learn about the design of
librav1e, its limitations regarding audio, and the standard
methods used to combine its AV1 video output with audio tracks into a
final media container.
librav1e is Strictly a Video Encoder
The short answer is no: librav1e cannot natively
multiplex audio streams. In fact, it cannot process, decode, or encode
audio at all.
librav1e is the C-compatible library wrapper for
rav1e, an AV1 video encoder written in Rust. Its sole
responsibility is to take raw, uncompressed video frames (such as YUV
sequences) and compress them into an AV1 elementary video stream.
Because it is designed strictly as a video encoder, it does not contain
any code for handling audio data, nor does it have the built-in
capability to package audio and video together.
The Need for External Multiplexing
Multiplexing (or “muxing”) is the process of interleaving separate audio and video streams into a single container format, such as MP4, MKV, or WebM.
Because librav1e only outputs raw AV1 video packets
(often wrapped in simple IVF or OBU formats), you must use an external
multiplexer or media framework to combine this video with an audio
track.
To create a complete media file with both sound and picture, developers typically use one of the following integration methods:
- FFmpeg: This is the most common solution. FFmpeg
can utilize
librav1e(vialibrav1eintegration in FFmpeg’s libavcodec) to encode the video, encode the audio using an audio codec like Opus or AAC, and then use its container muxers (libavformat) to merge them into a single file. - MKVToolNix / mkvmerge: If you have already encoded
your audio and video into separate files, you can use tools like
mkvmergeto multiplex the raw AV1 video file and the audio file into a Matroska (.mkv) container. - GStreamer: Similar to FFmpeg, this multimedia
framework allows you to build a pipeline that feeds video to the
rav1eencoder element, handles audio separately, and sends both streams to a muxer element (such aswebmmuxormp4mux).