The LiveSwitch HLS Demo listens for new connections using LiveSwitch Cloud webhooks and converts them into a near-real-time HLS stream using lsconnect
and ffmpeg
.
The LiveSwitch HLS Demo was built using Node.js and TypeScript. It is provided as a Visual Studio solution, but Visual Studio is not required.
Create a LiveSwitch Cloud application if you haven't already.
LiveSwitch Server customers can use this demo as well. Simply update
gatewayUrl
inapp.ts
to point to your LiveSwitch Gateway.
Update applicationId
and sharedSecret
in app.ts
to your LiveSwitch application ID and shared secret.
First, make sure "express" is installed. In a terminal, browse to src/FM.LiveSwitch.Hls
and type:
npm install
Create the 'hls' directory under 'static' -> .\src\FM.LiveSwitch.Hls\static\hls
In a terminal, browse to src/FM.LiveSwitch.Hls
and type:
node app.js
The web server is now listening for inbound webhooks.
Use ngrok in a separate terminal to create a secure tunnel to port 3000:
ngrok http 3000
Using
ngrok
is not required, but avoids the need to configure firewalls to allow inbound requests.
Finally, add a channel-level webhook for the Connection Connected
event to your LiveSwitch Cloud application pointing to your ngrok
URL.
In your node
terminal window, you should see a URL with your application ID and shared secret:
Browse to: https://demo.liveswitch.io/#application=...&sharedsecret=...&mode=1
If you see
<YOUR_APPLICATION_ID_GOES_HERE>
or<YOUR_SHARED_SECRET_GOES_HERE>
in the URL, you missed a step from the previous section.
Open a web browser and navigate to the URL. You should see the standard LiveSwitch demo app. Join any channel, and you should see a few things happen:
- The
ngrok
terminal should show that an inbound POST request has been forwarded to port 3000. - The
node
terminal should show logs indicating that a webhook event has been received and is being processed bylsconnect
andffmpeg
. - The file system should show HLS output under
src/FM.LiveSwitch.Hls/static/hls
.
Open a new browser tab and navigate to http://localhost:3000. You should see a list of live recordings, including the one that is currently active!
Download the Unity Liveswitch Sender app from here.
Run it and it will start sending audio/video data.
If you are using macOS or Linux, you may need to set the executable bit on lsconnect
:
chmod +x lsconnect
chmod +x lsconnect-macos
To learn more, visit frozenmountain.com or liveswitch.io.
For inquiries, contact [email protected].
All contents copyright © Frozen Mountain Software.