Skip to main content

Overview

WebRTC (Web Real-Time Communication) provides sub-second latency streaming, making it ideal for interactive applications like video conferencing, live auctions, and real-time broadcasts. Ant Media Server supports WebRTC for both publishing and playing streams.

Key Benefits

  • Ultra-low latency: Sub-second (typically 0.5s) latency
  • Peer-to-peer capable: Direct browser-to-browser communication
  • Adaptive bitrate: Automatically adjusts quality based on network conditions
  • Secure by default: Encryption with DTLS and SRTP
  • Codec support: H.264, VP8, VP9, H.265 (HEVC), AV1, Opus audio

Publishing Streams

WebRTC SDK Publishing

Playing Streams

WebRTC SDK Playback

Configuration Options

Server-Side Configuration

Configure WebRTC settings in your application’s application.properties or via REST API:

Client-Side Media Constraints

Advanced PeerConnection Configuration

Adaptive Bitrate Streaming (ABR)

WebRTC adaptor in Ant Media Server automatically manages stream quality based on network conditions:

Troubleshooting

Common Issues

No Video/Audio

  1. Check browser permissions for camera/microphone
  2. Verify HTTPS is being used (required for WebRTC)
  3. Check ICE connection state in browser console
  4. Verify firewall allows WebRTC ports (50000-60000)

High Latency

  • Check network conditions and bandwidth
  • Verify server is geographically close to clients
  • Reduce video resolution or bitrate
  • Enable TURN server for better connectivity

Connection Failures

  1. Verify WebSocket URL is correct and accessible
  2. Check STUN/TURN server configuration
  3. Verify stream exists on server
  4. Check server logs for errors

Debug Mode

Enable detailed logging:

Performance Optimization

Video Conferencing:
Live Broadcasting:
Screen Sharing:

API Reference

For complete WebRTC API documentation, see: