Broadcasting to an Amazon IVS Real-Time Stream with WHIP from OBS
Todd Sharp
Posted on February 22, 2024
Until recently, broadcasting to an Amazon Interactive Video Service (Amazon IVS) real-time stage required developers to utilize one of our Broadcast SDKs (web and mobile). Behind the scenes, the SDKs abstract all of the logic required to initialize a peer connection and broadcast the user's video to the stage. This makes it easier for developers who want to integrate real-time streaming in their applications, but also limits the options for the end users who will ultimately be broadcasting to that stage to only web and mobile based client software. The addition of support for any WHIP-compatible encoder opens the door for additional options for media publish to a real-time stage.
WHIP??
Bit of a weird name for a protocol, I'll admit ๐คท๐ปโโ๏ธ. But, I'm not in charge of naming things (which is probably a good thing). WHIP stands for WebRTC-HTTP Ingest Protocol which is an IETF protocol that standardizes the process of the one-time exchange of Session Description Protocol (SDP) offers and answers using HTTP POST
requests.
๐ก Not Down With SDP? Check out 'What is the Session Description Protocol (SDP)?' on WebRTC for the Curious.
As you may have guessed from the name, the WHIP protocol refers to ingest (AKA 'broadcasting' or 'publishing') only. There's a separate protocol called WHEP that deals with egress (AKA 'viewing' or 'subscribing'). If you're struggling with insomnia ๐ฅฑ, feel free to read the entire IETF draft for WHIP or WHEP.
Broadcasting to an Amazon IVS Stage with OBS
OBS is widely-used because of it's advanced production features like scene transitions, overlays, easy screen sharing, audio mixing and more. To broadcast to an Amazon IVS stage from OBS, the user will need at least OBS version 30 and a stage participant token. These tokens usually have an expiration time of 12 hours (the default), but this can be extended up to 14 days.
To try it out, generate a stage participant token via an AWS SDK, the AWS CLI, or the Amazon IVS management console and head into the 'Settings' dialog in OBS.
In the 'Stream' tab, choose 'WHIP' as the 'Service', enter https://global.whip.live-video.net
as the 'Server' and paste a valid stage participant token as the 'Bearer Token'.
Note: OBS will warn you that WHIP broadcasting requires Opus audio encoding. This is expected, so select 'Yes' to continue.
Next, head to the 'Output' tab and make sure that the 'Output Mode' is 'Advanced'.
For the best performance, make sure your 'Bitrate' is at or below 2500 Kbps
, use a 'Keyframe Interval' of 1s
or 2s
, set 'CPU Usage Preset' to ultrafast
and 'Tune' to zerolatency
.
Now exit from the 'Settings' dialog and click 'Start Streaming' and you'll be broadcasting to the stage.
Refer to the docs on OBS and WHIP Support for more info.
Broadcasting to an Amazon IVS Stage with GStreamer
If you're a fan of the open source multimedia framework GStreamer, you can take advantage of WHIP support as well. Here's a simple pipeline that could be used to publish a webcam and microphone to a stage. This pipeline is specific to MacOS, but can be adapted to any supported OS. Make sure to obtain and set a participant token into IVS_STAGE_TOKEN
(or include a raw token instead).
gst-launch-1.0 </span>
avfvideosrc device-index=0 </span>
! videoconvert </span>
! x264enc tune=zerolatency bitrate=2500 speed-preset=ultrafast </span>
! rtph264pay </span>
! 'application/x-rtp,media=video,encoding-name=H264,payload=97,clock-rate=90000,width=1280,height=720,framerate=30/1' </span>
! whip.sink_0 autoaudiosrc wave=4 </span>
! audioconvert </span>
! opusenc </span>
! rtpopuspay </span>
! 'application/x-rtp,media=audio,encoding-name=OPUS,payload=96,clock-rate=48000,encoding-params=(string)2' </span>
! whip.sink_1 </span>
whipsink </span>
name=whip </span>
auth-token=$IVS_STAGE_TOKEN </span>
whip-endpoint=https://global.whip.live-video.net/
Summary
In this post, we learned how to publish to an Amazon IVS real-time stage via WHIP-compatible encoders. This support opens up many possibilities for real-time streaming with Amazon IVS. Refer to the Amazon IVS Real-Time User Guide page on OBS and WHIP Support for further details. If you have any questions or ideas for possible use-cases drop a comment below!
Posted on February 22, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.