Skip to content

WebRTC playback over WHEP

WHEP delivers an Agora stream to a WebRTC player with minimal latency. This guide uses studio, already receiving media, for example from a WHIP sender.

Prepare the stream

Make sure the stream is running and its video is H.264 or AV1. Audio needs Opus; if the source sends AAC or another audio codec, configure conversion to Opus beforehand. WebRTC does not convert codecs. Check video support in the viewing player too.

Allow viewing

In Auth & DRM, configure viewing access. For a private stream, obtain an allowed viewing token or grant. The token given to the encoder for publishing does not replace this permission.

Build the WHEP URL

On the stream card Layout tab, find the streamer serving this stream. Use its HTTP(S) address and the stream name:

https://streamer.example.com/streaming/whep/studio?token=PLAY_TOKEN

This is the direct streamer WHEP URL, rather than the central console address. Replace the domain and token. Instead of the token query parameter, the player can send Authorization: Bearer PLAY_TOKEN.

Connect the player

  1. Open a WHEP-compatible player and enter this URL. The player must support complete initial SDP with ICE candidates, without requiring Trickle ICE.
  2. Start playback. The player POSTs an SDP offer and receives 201 Created, an SDP answer and the session URL in Location.
  3. Check video and audio. A WHEP viewing session with transferred-byte accounting appears in Sessions.

Pasting a WHEP URL into the browser address bar does not start video: GET returns 204 No Content. Browser integration needs a WebRTC player; a plain <video src="…"> does not negotiate WHEP. Use HTTPS and ensure UDP access to the streamer media port.

If the browser page and WHIP/WHEP endpoint use different origins, add the response header Access-Control-Expose-Headers: Location at the HTTPS proxy so the client can read the created session URL. This is unnecessary when the page and API share an origin.

Stop playback

Stop playback in the player. For a custom client, save Location from the POST response and send DELETE to that URL; success returns 204 No Content. The server also removes sessions after an ICE disconnect timeout.

Changing the WebRTC port list requires reconnecting the player. Saving unchanged settings preserves the current port. For archive playback, use an archive delivery protocol instead of this WHEP URL.

Troubleshoot connection failures

Symptom Check
403 Viewing permission; WHEP does not serve DRM-encrypted content.
404 Stream name, selected streamer and available tracks.
415 H.264/AV1 video and correct request Content-Type.
503 UDP listener readiness; reconnect after resolving the cause.
Session exists but no picture Reachability of the announced ICE address and UDP port, and player codec support.

Reference

WHEP contract and limitations.