Skip to main content

Overview

Adaptive Bitrate (ABR) streaming dynamically adjusts video quality based on network conditions and device capabilities. Ant Media Server provides comprehensive ABR support through real-time transcoding and intelligent bitrate switching.

How ABR Works

When ABR is enabled, Ant Media Server:
  1. Receives the source stream at original quality
  2. Transcodes to multiple quality levels (renditions)
  3. Packages all renditions for delivery
  4. Adapts playback quality based on client bandwidth

Encoder Settings

ABR is configured through the EncoderSettings class, which defines each quality profile:
EncoderSettings.java:8-24

Key Parameters

  • height: Resolution height in pixels (e.g., 480, 720, 1080)
  • videoBitrate: Video bitrate in bits per second
  • audioBitrate: Audio bitrate in bits per second
  • forceEncode: Whether to encode even if source is lower resolution

Configuration Examples

Via Application Settings

Configure ABR profiles in your application settings:
AppSettings.java:865
If encoderSettingsString is empty, Ant Media Server operates in SFU (Selective Forwarding Unit) mode for WebRTC, forwarding streams without transcoding.

Via REST API

Set encoder settings dynamically:

Encoder Configuration

Encoder Selection

Ant Media Server automatically selects the best encoder:
AppSettings.java:1377
Hardware Encoders (GPU):
  • h264_nvenc - NVIDIA GPU
  • h264_qsv - Intel Quick Sync
  • h264_videotoolbox - Apple VideoToolbox
  • h264_vaapi - Linux VA-API
Software Encoders (CPU):
  • libx264 - H.264 software encoder
  • libopenh264 - Cisco OpenH264
  • libvpx - VP8/VP9 encoder
Leave encoderName empty to auto-detect. The server tries GPU encoders first, falling back to CPU encoders.

Encoder Parameters

Configure encoder-specific parameters:
AppSettings.java:1399-1400
Example configuration:

Encoder Settings

GOP Size

AppSettings.java
GOP (Group of Pictures) size affects:
  • Seeking accuracy: Smaller GOP = more precise seeking
  • Encoding efficiency: Larger GOP = better compression
  • Latency: Smaller GOP = lower latency
For low-latency streaming, use GOP size of 2-3 seconds (60-90 frames at 30fps).

Quality Profiles

Full HD Multi-bitrate

HD Mobile-Optimized

Low-Bandwidth

Advanced Features

Force Encoding

The forceEncode parameter controls whether to transcode when the source resolution is lower than the target:
EncoderSettings.java:15-19
  • true: Always encode to target resolution (may upscale)
  • false: Skip encoding if source is lower resolution

Original Stream in ABR

Include the original quality stream alongside transcoded versions:
AppSettings.java:1011

Hardware Scaling

Use GPU for scaling in addition to encoding:
This offloads scaling to the GPU, reducing CPU usage.

Stats-Based ABR

Ant Media Server includes intelligent bitrate switching based on real-time statistics:
AppSettings.java:733-749

Configuration

How it works:
  • Monitor packet loss, RTT, and jitter
  • Switch to lower quality when packet loss > 10%
  • Switch to higher quality when packet loss < 5% and RTT < 50ms

Performance Considerations

CPU Usage

Each additional quality profile requires encoding resources:
  • 1080p transcoding: ~100-150% CPU per stream (software)
  • 720p transcoding: ~50-75% CPU per stream (software)
  • 480p transcoding: ~25-35% CPU per stream (software)
For high concurrency, use GPU encoding or limit ABR profiles to 2-3 renditions.

GPU Encoding

GPU encoding provides:
  • 10-20x faster than CPU encoding
  • Lower CPU usage for higher concurrency
  • Slightly lower quality at same bitrate

Encoder Selection Preference

Options:
  • gpu_and_cpu: Try GPU first, fallback to CPU
  • only_gpu: Only use GPU (fail if unavailable)

Monitoring ABR

Check encoding status via REST API:
Response includes:

Troubleshooting

Encoding Not Starting

  1. Check encoder availability:
  2. Verify encoder settings are valid JSON
  3. Check CPU/GPU resources

Quality Issues

  1. Increase bitrate for target resolution
  2. Adjust GOP size
  3. Try different encoder preset
  4. Enable hardware encoding

High CPU Usage

  1. Reduce number of ABR profiles
  2. Enable GPU encoding
  3. Increase encoder preset speed (e.g., ultrafast)
  4. Use lower resolutions

Next Steps

Streaming Protocols

Learn about protocol options for ABR delivery

Architecture

Understand how ABR fits into the system