Overview
Since WCS build 5.2.1504 a stream can be played from server via WebRTC in a number of video qualities like HLS ABR. A browser will play a first available quality track, then playing client can switch between quailities if necessary.
Supported platforms and browsers
Chrome | Firefox | Safari | Chromium Edge | |
---|---|---|---|---|
Windows | + | + | + | |
Linux | + | + | + | |
Mac OS | + | + | + | + |
Android | + | + | + | |
iOS | + (iOS 14.4) | + (iOS 14.4) | + |
Supported publishing technologies
A streams published by all of the available ways can be played via WebRTC ABR:
- WebRTC
- RTMP
- RTSP
- MPEG-TS via UDP or SRT
- Stream mixer
Supported codecs
Any stream will be transcoded to H264+Opus to be played as WebRTC ABR.
Implementation basics
SFU functions with Simulcast are used to implement WebRTC ABR support. A stream published video track is transcoded to a number of H264 video tracks with a different parameters, and the tracks are sent to client as SFU qualities. Audio track is transcoded to Opus and is also sent to client as SFU track. An SFU room named as stream published is created on server because room is a main SFU object.
Configuration
SFU subsystem setup
The following should be done to play a stream published on WCS using SFU Simulcast:
- codecs used by SFU should be limited to H264 + Opus
- H264 encoding profiles should be set
- a bridge from WCS core engine to SFU subsystem should be enabled
codecs_exclude_sfu=alaw,ulaw,g729,speex16,g722,mpeg4-generic,telephone-event,flv,mpv,vp8 profiles=42e01f,640028 wcs_sfu_bridge_enabled=true
WCS must be restarted to apply the settings.
Quality profiles setup
WebRTC ABR quality profiles are set in /usr/local/FlashphonerWebCallServer/conf/wcs_sfu_bridge_profiles.yml
file. By default, the following profiles are used:
profiles: s : width : 320 height : 240 bitrate : 500 gop : 60 fps : 30 m : width : 640 height : 480 bitrate : 800 gop : 60 fps : 30 h : width : 960 height : 720 bitrate : 1300 gop : 60 fps : 30
The following profile parameters are supported:
height
- picture height (mandatory)width
- picture widthbitrate
- encoding bitrate in kbpsgop
- group of frames sizefps
- frames number per second
The gop
parameter actually sets key frames encoding period. In the example above, for 30 frames per second a key frame will be formed every 2 seconds.
Quality profiles may be arbitrary named, they are used to choose a quality at client side. In the example above, the profiles may be named as 240p
, 480p
и 720p
respectively.
WCS must be restarted to apply the quality profiles settings.
Quick manual on testing
1. For test we use:
- WCS server with WebRTC ABR settings
- OBS to publish a stream
- WebRTC ABR Player example
https://test1.flashphoner.com:8444/client2/sfu/webrtc-abr-player/player.html
to play the stream
2. Publish RTMP stream test
720p 30 fps with 2000 kbps bitrate
3. Open WebRTC ABR Player example page, set Stream name
to test
, and click Play
. Stream playback will start
Known issues
1. Not all the qualities may be available to a client depending on channel bandwidth. In this case, unavailable quality buttons in WebRTC ABR Player will be displayed in red.
2. WebRTC ABR increases server CPU load because a number of video encoders are created per every published stream depending on quality profiles count.
3. In iOS Safari audio is muted by default in WebRTC ABR Player example, and unmute button is dispalyed on audio tag because iOS Safari requires a user action to enable sound