WHIP / WHEP: WebRTC publish and play
WHIP (publish) and WHEP (play) are the standard HTTP-signaled WebRTC ingest and egress protocols. They are the lowest-latency way in and out of TRaX and work natively from a browser.
Endpoints
POST https://<trax-media-host>:8889/<path>/whip # publish
POST https://<trax-media-host>:8889/<path>/whep # play
Standard WHIP/WHEP semantics: POST an SDP offer (Content-Type: application/sdp),
receive an SDP answer, ICE via the returned resource. TRaX also returns TURN
servers in the signaling response where relay is required.
WHIP is not a publish route for an input created over /v1. The
ingest endpoint
never grants webrtc: the WHIP URL for such an input carries no credential,
so it would only ever answer 401. Publish to an input over
SRT or RTMP/RTMPS.
Authentication
Send the session token as a Bearer header:
Authorization: Bearer <jwt>
Three token audiences exist for the WebRTC plane:
| Token | Purpose |
|---|---|
talk token (aud: trax-mediamtx-talk) |
Publish-capable, scoped to your provisioned session; carries a can_publish claim |
read token (aud: trax-mediamtx-read) |
Single-path, short-TTL playback |
intercom token (aud: trax-mediamtx-intercom) |
A private intercom room; see Private intercom |
For public playback — a token from POST /v1/playback/{playbackId}/token,
handed to an anonymous viewer on your website — the header is the only
supported way to send it. Never put a public playback token in the URL: an
embed's URLs reach your visitors' browser history, your CDN and analytics logs,
and the Referer of every request the page makes. See
Embed a player on your site.
For the other read and talk tokens, where a Bearer header is impossible (some
players), the token is also accepted as an access_token query parameter on the
WHIP/WHEP URL. Prefer the header; query strings end up in logs.
Hard rules
- One token per path. The token's
pathclaim must match the URL path. - Short TTLs. Read tokens especially are minted per playback session — don't cache them.
- Audio codec: WebRTC audio is Opus. Feeds contributed over SRT/RTMP with AAC audio are transparently transcoded for WHEP playback; expect Opus on the receiving side.
Failure modes
| Symptom | Likely cause |
|---|---|
401 on the POST |
Missing/expired token, wrong audience for the operation |
404 |
Path not provisioned (or a typo — paths are exact-match) |
| Connects, video but no audio in browser | Player expecting AAC — WebRTC delivers Opus |