call := client.Video().Call("default", uuid.New().String())
// create the call where the WHIP will be sent to
response, err := call.GetOrCreate(ctx, &getstream.GetOrCreateCallRequest{})
// ensure we have a user for the host to send video via WHIP
client.UpdateUsers(ctx, &getstream.UpdateUsersRequest{
Users: map[string]getstream.UserRequest{
"whip-user": {
ID: "whip-user",
},
},
})
// create a token for the user sending video
streamKey, err := client.CreateToken("whip-user-id")
whipURL := response.Data.Call.Ingress.Whip.Address
fmt.Println("WHIP Server URL:", whipURL, "Bearer token:", streamKey)
WHIP
WHIP allows you to ingest media streams over WebRTC directly from OBS, ffmpeg and other video clients.Compared to other protocols supported to ingest video such as RTMP and SRT, WHIP has two main advantages: it comes with no additional ingress charges and it has a much lower latency.
Quickstart
Acquire credentials
To get the endpoint and token, you can use the following API:# WHIP URL is: response.call.whip.address
curl -X GET "https://video.stream-io-api.com/api/v2/video/call/livestream/${CALL_ID}?api_key=${API_KEY}" \
-H "Authorization: ${TOKEN}" \
-H "stream-auth-type: jwt"
OBS Setup
Show how to configure OBS to use WHIP.
- Open OBS and go to the “Stream” settings.
- Select “WHIP” Service.
- Enter Server URL obtained from SDK.
- Enter Bearer token obtained from SDK.
- Press OK
FFMPEG
Some ffmpeg installation from package managers do not have WHIP enabled. So ffmpeg should be compiled with WHIP support. To check if your installation supports WHIP run ffmpeg -muxers
and check if there is whip in the list.
This is minimal example required to work with whip:
Download code from official repo or github mirror.
In this directory run:
./configure --enable-openssl --enable-protocol=dtls --enable-muxer=whip \
--enable-libx264 --enable-gpl --enable-libopus --enable-version3
make install ## or make build
Example command to publish video with ffmpeg using WHIP:
ffmpeg -i input.mp4 -strict -2 -vcodec libx264 -profile:v baseline -b\:v 2000k \
-maxrate 2500k -bufsize 5000k -c\:a opus -ar 48000 -ac 2 \
-f whip -authorization $BEARER_TOKEN "$SERVER_URL"
RTMP vs WHIP
Stream supports both RTMP and WHIP, here’s a quick comparison to better understand when to use one or the other.
- WHIP is free-of-charge
- RTMP ingress creates additional video tracks in different resolutions and bitrates
- WHIP has much lower latency than RTMP
- WHIP is a recent protocol, expect adoption on clients and libraries to be more limited