CMAF (Common Media Application Format) is a standardized packaging format designed to streamline the delivery of media content over HTTP. It is an essential solution for adaptive bitrate streaming and is widely adopted in modern video delivery pipelines.
CMAF is a container format that supports both HLS and DASH protocols, allowing for a unified delivery method across different streaming systems. By using a common format for both live and on-demand content, CMAF reduces redundancy, lowers storage costs, and simplifies the media packaging process.
CMAF Architecture
CMAF uses a segmented, chunked format for video and audio streams. The format supports fragmented MP4 (fMP4) files, which are divided into smaller segments that can be individually requested and streamed. This segment-based approach is compatible with both HLS and DASH, enabling seamless adaptive bitrate streaming.
Fragmented MP4 (fMP4)
CMAF relies on fMP4, which breaks down traditional MP4 files into small, independent segments that are easier to transmit and store. This allows media players to access the content without waiting for the entire file to download. fMP4 segments are ideal for HTTP-based streaming because they allow efficient chunking and are inherently CDN-friendly.
Each fMP4 file contains metadata and a small chunk of the video/audio data, enabling faster seeking and adaptive bitrate switching. By using fMP4, CMAF is able to deliver high-quality video at varying bitrates, improving the overall streaming experience.
Command Example for Creating fMP4 Segments with FFmpeg:
ffmpeg -i input.mp4 -c:v libx264 -c:a aac -f mp4 -movflags +frag_keyframe+empty_moov -segment_time 10 -segment_format fmp4 output%03d.m4sExplanation:
- -movflags +frag_keyframe+empty_moov: Enables fragmentation of MP4 files at keyframes and ensures that the "moov" box is placed at the beginning of each fragment.
- -segment_time 10: Creates 10-second segments for efficient delivery.
- -segment_format fmp4: Specifies the fMP4 format for the segments.
This command generates video segments compatible with CMAF"s requirements for adaptive bitrate streaming.
Packaging for Adaptive Bitrate Streaming (ABR)
For ABR streaming, CMAF supports the dynamic delivery of multiple quality levels by segmenting the video at different bitrates or resolutions. These segments are packaged into multiple streams with corresponding playlists for HLS or DASH.
In adaptive streaming, the client dynamically selects the appropriate segment based on the network bandwidth, ensuring smooth playback without interruption.
Command Example for Multi-Bitrate Packaging:
ffmpeg -i input.mp4 \ -map 0:v -s:v:0 1920x1080 -b:v:0 5000k \ -map 0:v -s:v:1 1280x720 -b:v:1 3000k \ -map 0:v -s:v:2 854x480 -b:v:2 1500k \ -map 0:a -c:a aac -b:a 128k \ -f dash -segment_time 4 -segment_format m4s -dash_segment_filename "segment_%03d.m4s" -master_pl_name "master.mpd" output.mpdExplanation:
- -map 0:v: Maps the video streams to be encoded at multiple resolutions (1080p, 720p, and 480p).
- -b:v:0 5000k: Sets the bitrate for the 1080p stream.
- -segment_time 4: Specifies that each segment will be 4 seconds long.
- -segment_format m4s: Packages the video in fMP4 format for CMAF.
- -f dash: Specifies DASH as the output format.
- -master_pl_name "master.mpd": Creates a master playlist file to manage the streams.
This setup allows a CMAF-based video stream to be delivered in multiple bitrates, providing an optimal experience based on the client"s available bandwidth.
CMAF in Streaming Protocols
CMAF is primarily used in two popular ABR streaming protocols: HLS and DASH. It replaces older segment formats like MPEG-TS, bringing a unified approach to video delivery that supports both VOD (Video on Demand) and live streaming.
CMAF for HLS Streaming
HLS traditionally relied on MPEG-TS for segmenting video content. With CMAF, HLS now supports fragmented MP4 (fMP4) for segmenting, which provides better performance and compatibility across devices.
Example of CMAF Segment Creation for HLS:
ffmpeg -i input.mp4 -c:v libx264 -hls_time 4 -hls_flags single_file -hls_segment_filename "segment_%03d.m4s" -f hls -master_pl_name "master.m3u8" output.m3u8Explanation:
- hls_time 4: Sets segment duration to 4 seconds.
- -hls_flags single_file: Uses a single file for segmenting, aligning with the fMP4 approach.
- -hls_segment_filename: Specifies the naming pattern for segments.
CMAF for DASH Streaming
DASH, like HLS, also supports CMAF, and the fMP4 format enhances its flexibility by reducing the complexity of segmenting video content.
Example of CMAF Segment Creation for DASH:
ffmpeg -i input.mp4 -c:v libx264 -preset fast -g 60 -f dash -dash_segment_filename "segment_%03d.m4s" -master_pl_name "master.mpd" output.mpdExplanation:
- -preset fast: Ensures faster encoding with reasonable compression.
- -g 60: Sets the GOP length to 60, optimizing keyframe placement for better seek functionality.
Low Latency CMAF (LL-CMAF) for Live Streaming
For live streaming applications, CMAF has an extension called LL-CMAF, which reduces latency by supporting smaller segment durations and real-time delivery of video content. This is especially useful for live events or interactive applications where low delay is crucial.
Example Command for LL-CMAF:
ffmpeg -i input.mp4 -c:v libx264 -hls_time 2 -hls_flags delete_segments+program_date_time -f hls -hls_segment_filename "segment_%03d.m4s" output_llhls.m3u8Explanation:
- -hls_time 2: Reduces segment duration to 2 seconds, crucial for low-latency streaming.
- -hls_flags delete_segments+program_date_time: Ensures proper timestamp handling for quick segment switching.

