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:- Receives the source stream at original quality
- Transcodes to multiple quality levels (renditions)
- Packages all renditions for delivery
- Adapts playback quality based on client bandwidth
Encoder Settings
ABR is configured through theEncoderSettings 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
h264_nvenc- NVIDIA GPUh264_qsv- Intel Quick Synch264_videotoolbox- Apple VideoToolboxh264_vaapi- Linux VA-API
libx264- H.264 software encoderlibopenh264- Cisco OpenH264libvpx- VP8/VP9 encoder
Encoder Parameters
Configure encoder-specific parameters:AppSettings.java:1399-1400
Encoder Settings
GOP Size
AppSettings.java
- Seeking accuracy: Smaller GOP = more precise seeking
- Encoding efficiency: Larger GOP = better compression
- Latency: Smaller GOP = lower latency
Quality Profiles
Recommended Profiles
Full HD Multi-bitrate
HD Mobile-Optimized
Low-Bandwidth
Advanced Features
Force Encoding
TheforceEncode 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:Stats-Based ABR
Ant Media Server includes intelligent bitrate switching based on real-time statistics:AppSettings.java:733-749
Configuration
- 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)
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
gpu_and_cpu: Try GPU first, fallback to CPUonly_gpu: Only use GPU (fail if unavailable)
Monitoring ABR
Check encoding status via REST API:Troubleshooting
Encoding Not Starting
-
Check encoder availability:
- Verify encoder settings are valid JSON
- Check CPU/GPU resources
Quality Issues
- Increase bitrate for target resolution
- Adjust GOP size
- Try different encoder preset
- Enable hardware encoding
High CPU Usage
- Reduce number of ABR profiles
- Enable GPU encoding
- Increase encoder preset speed (e.g.,
ultrafast) - Use lower resolutions
Next Steps
Streaming Protocols
Learn about protocol options for ABR delivery
Architecture
Understand how ABR fits into the system
