Restreaming to Social Media platforms
This page outlines the steps required to restream to various social media networks from the PhenixRTS platform using the Restreaming API. These instructions use the PhenixRTS Customer Portal for ease of use; however, this workflow is not limited to the Portal.
Beta Notice
Restreaming is currently in beta testing.
Phenix has tested restreaming to YouTube, Twitch, Instagram, and Facebook. Please contact Phenix for guidance.
The main factor that impacts latency is resolution. Some restreaming targets, such as Instagram, insert additional delay (typically about 10 seconds) to the Creator's Live feed for its viewers.
Requirements
To restream to another platform, you must have the following:
-
Access to the Phenix Customer Portal.
-
Knowledge on how to use EdgeAuth - this document uses the packaged nodeJS EdgeAuth library.
-
A stream published to an existing channel. The capabilities for the stream's publish token must include
streaming
if using the default restreaming mode, or must include at least one ofmulti-bitrate
,multi-bitrate-contribution
, orprefer-h264
if using low-latency mode. -
A viewing token with
egress
set in the capabilities, and with origin stream id. An additional capability may be required, depending on the restreaming mode selected. You can retrieve the stream id using the Notifications API programmatically if preferred. -
An account on the desired platform (e.g., YouTube) prepared to receive the stream. Each platform has its own requirements to ingest external video. For example, Tiktok requires you to be 18 as well as have 1000 followers before they will let a user have access to their stream key. Youtube can take up to 24 hours for live streaming to be enabled.
Restream
-
In the portal, select the Streams tab in the channel you created. Copy the
stream id
below the video that is displaying your published stream. -
Using EdgeAuth, create a token with
egress
in the capabilities and with the stream id. If using the low-latency restreaming mode, include thempegts-egress
capability as well.
The Phenix EdgeAuth library comes in a variety of languages. Choose the one most suitable for your development environment.
To get started quickly, use the node-based command line application to build a token. This method should not be used for production.
An example is shown below.
git clone git@github.com:PhenixRTS/EdgeAuth.git
cd EdgeAuth/node
npm install
node src/edgeAuth.js --applicationId "my-application-id" --secret 'my-secret' --expiresInSeconds 31536000 --originStreamId "my-stream-id-from-portal" --capabilities "egress" --streamingOnly
The result will be a base64-encoded token.
- Replace the following variables per these instructions to create the restream cURL command below.
- The Authorization: Bearer is the token created in the previous step. Replace
DIGEST:..
with that token. - Replace
<SOCIAL_MEDIA_URI>
with the uri provided by the social media platform. Example:rtmp://liveingest.com/appname/
- Replace
<STREAM_KEY>
with the stream key provided by the social media platform. - Replace
<APPLICATION_ID>
with your Phenix RTS application id. - Replace
<rtmp|rtmps>
with the required protocol of the platform you are using. Note, this should match what is leading the social media platform’s uri above.
curl --connect-timeout 3 \
-H 'Authorization: Bearer DIGEST:..' \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-X PUT --data '{
"uri" : "<SOCIAL_MEDIA_URI>/<STREAM_KEY>"
}' \
https://pcast.phenixrts.com/pcast/<APPLICATION_ID>/stream/egress/uri/<rtmp|rtmps>
The successful result of the call should look like the following, note that the token is truncated:
{"status":"ok","streamId":"us-southwest#phx-ad-2.Z8j50oGL.20230511.EyNDdzxy","sharedSecret":"DIGEST:...","options":[]}%
Restreaming tips:
-
Pay attention to the protocol used at the end of the uri as it will need to be adjusted per what protocol the platform supports. For example, Facebook expects
rtmps
where twitch expectsrtmp
. -
If you get a status of unauthorized, double check your token's expiration value, format and stream id.