Encoder Settings Object
Each encoder profile consists of four main parameters:Video resolution height in pixels (e.g., 480, 720, 1080).The width is automatically calculated to maintain the aspect ratio of the source stream.
Video bitrate in bits per second (bps).Examples:
- 240p: 200,000 - 400,000 bps
- 360p: 300,000 - 600,000 bps
- 480p: 500,000 - 1,000,000 bps
- 720p: 1,500,000 - 3,000,000 bps
- 1080p: 3,000,000 - 6,000,000 bps
Audio bitrate in bits per second (bps).Typical values:
- 64,000 bps (64 kbps) - Low quality
- 96,000 bps (96 kbps) - Standard quality
- 128,000 bps (128 kbps) - Good quality
- 192,000 bps (192 kbps) - High quality
Enable/disable stream resolution check.If enabled, Ant Media Server will ignore adaptive resolutions higher than the incoming stream.Example: If incoming stream is 480p and you request 720p encoding with
forceEncode: true, the 720p profile will be ignored.Configuration Methods
Via encoderSettingsString
TheencoderSettingsString parameter accepts a JSON array of encoder profiles:
Via Web Panel
Encoder settings can be configured through the Ant Media Server web panel:- Navigate to your application settings
- Go to the Adaptive Bitrate section
- Add or modify encoder profiles
- Save changes
Video Encoder Configuration
Encoder Selection
Specific encoder to use for transcoding.Options:
"h264_nvenc"- NVIDIA GPU encoder (requires NVIDIA GPU)"openh264"- OpenH264 software encoder"libx264"- x264 software encoder- Empty string - Auto-select based on available hardware
Encoder selection strategy:
"gpu_and_cpu"- Try GPU first, fallback to CPU if GPU unavailable"only_gpu"- Only use GPU encoder, fail if unavailable
Encoder Parameters
Encoder-specific parameters in JSON format. Keys should match official FFmpeg encoder names.Example:
Thread Configuration
Number of threads for encoding. 0 means auto-detect.
Thread type for encoding:
0- Auto1- Frame-based threading2- Slice-based threading
Codec Support
H.264
Enable/disable H.264 encoding.
H.265 (HEVC)
Enable/disable H.265/HEVC encoding.
VP8
Enable/disable VP8 encoding.
Number of threads for VP8 encoder.
Audio Configuration
AAC Encoding
Enable AAC encoding.If true, AAC encoding is active even if MP4 or HLS muxing is not enabled.
Set to true if sending streams to RTMP endpoints or enabling/disabling MP4 recording on the fly.
Audio bitrate in SFU mode for transcoding to AAC and Opus formats.After version 2.3, incoming audio is forwarded directly to viewers without transcoding when possible.
GOP and Quality Settings
Group of Pictures (GOP) size - the interval between keyframes.Important: This is NOT in seconds, but in frame count.Example: If GOP size is 50 and frame rate is 25 fps:
- Keyframe interval = 50 / 25 = 2 seconds
Force aspect ratio to match incoming stream exactly.When enabled, Ant Media Server may adjust output height to maintain perfect aspect ratio. Critical for DASH streaming with multiple bitrates.Example:
- Incoming: 1280x720 (16:9)
- Target: 480p
- Without force: Output may be exactly 480p with slight ratio difference
- With force: Output height adjusted to 853x480 for perfect 16:9
Hardware Acceleration
Enable GPU-based video frame scaling for adaptive bitrate.Note: Requires special build - contact Ant Media Support.
Common Encoder Profiles
Low Latency Streaming
High Quality Streaming
Mobile-Optimized Streaming
Conference/Webinar (Speaker + Attendees)
SFU Mode vs Transcoding
SFU Mode (No Adaptive Bitrate)
IfencoderSettingsString is empty or not set, Ant Media Server operates in SFU (Selective Forwarding Unit) mode:
- No transcoding is performed
- Original stream is forwarded directly to viewers
- Lower CPU usage
- Single quality available to viewers
- Ideal for WebRTC-to-WebRTC streaming
Transcoding Mode (With Adaptive Bitrate)
When encoder settings are configured:- Stream is transcoded to multiple qualities
- Viewers automatically receive appropriate quality based on bandwidth
- Higher CPU/GPU usage
- Better viewer experience across different network conditions
- Required for HLS/DASH playback from WebRTC sources
Best Practices
- Start with 2-3 profiles - Don’t create too many profiles initially. Monitor usage and add more if needed.
-
Bitrate guidelines - Use approximately 2-4 bits per pixel for good quality:
- 720p @ 30fps: 1280×720×30×3 ≈ 2,000,000 bps
- Audio bitrate - 96-128 kbps is sufficient for most use cases. Use 64 kbps only for very low-bandwidth scenarios.
- GOP size - Keep GOP size small (1-2 seconds) for low latency. Larger GOP reduces bandwidth but increases latency.
- Hardware encoding - Use GPU encoding (h264_nvenc) when available for better performance.
- Test your settings - Always test encoder settings with real streams under actual network conditions.
