Skip to main content

Stream from your own encoder and embed the player

This guide takes a stream from creation to your own web page: you create a stream, send video to it from OBS or ffmpeg, and embed the Envision Streaming player with the stream's playout name. The stream you create here is permanent: you can go live on it again and again.

Before you start​

You needDetails
A Envision Streaming accountWith a role that may create streams
An encoderOBS Studio, ffmpeg, vMix, Wirecast or a hardware encoder that sends RTMP
A web pageAny HTML page where you can paste an iframe

Step 1: Create a stream​

Option A: Dashboard​

  1. Sign in to the Envision Streaming Dashboard.
  2. Create a new stream.
  3. The stream's page shows the RTMP URL and the stream name.

Option B: REST API​

Create a stream with your organisation's API key:

API_KEY=<YOUR_API_KEY>

curl --request POST \
--url https://api.envisionstreaming.com/stream \
--header "x-bintu-apikey: $API_KEY" \
--header "content-type: application/json" \
--data '{ "tags": ["my-first-stream"] }'

In the response, the ingest details are under ingest.rtmp (url and streamname), and the name for playback is under playout.h5live[0].rtmp.streamname. The API key belongs on your server, never in a web page.

info

Ingest name vs playout name. A stream has a name for sending (the ingest stream name, also shown as stream key) and a name for playing (the playout stream name). They are often the same string, but not always. Always put the playout name into the player. See Key concepts.

Step 2: Send video to the stream​

You need two values from Step 1: the RTMP URL (server) and the stream name (stream key). Copy them exactly; don't build the URL by hand.

Recommended encoder settings: H.264 video, AAC audio, a keyframe every 2 seconds, no B-frames.

OBS Studio​

  1. Open Settings › Stream and set Service to Custom.
  2. Paste the RTMP URL into Server and the stream name into Stream Key.
  3. Under Settings › Output (Advanced mode), set Rate Control to CBR and Keyframe Interval to 2.
  4. Click Start Streaming.

ffmpeg​

Send a test pattern with a tone:

RTMP_URL="<YOUR_RTMP_URL>" # copy yours from Step 1
STREAM_NAME="XXXXX-YYYYY" # your ingest stream name

ffmpeg -re -f lavfi -i "testsrc=size=1280x720:rate=25" -f lavfi -i "sine=frequency=150" \
-c:v libx264 -preset veryfast -tune zerolatency -pix_fmt yuv420p -g 50 -b:v 1000k \
-c:a aac -b:a 128k \
-f flv "$RTMP_URL/$STREAM_NAME"

-g 50 sets a keyframe every 2 seconds at 25 fps. If you change the frame rate, change -g with it (for example -g 60 at 30 fps). To send a video file instead, replace the two -f lavfi -i ... inputs with -i input.mp4.

Check that the stream is live​

In the Dashboard, the stream's state changes from created to live.

Step 3: Embed the player​

The quickest way is to copy the ready-made player code for your stream from the Dashboard; it is filled in with your playout name. To write it yourself, paste this iframe where the player should appear and replace XXXXX-YYYYY with your playout stream name:

<iframe
src="https://dashboard.envisionstreaming.com/player/nanoplayer.html?group.id=XXXXX-YYYYY"
frameborder="0"
allowfullscreen
width="1280"
height="720">
</iframe>

Keep allowfullscreen if your site supports fullscreen playback.

warning

Never put your API key in a web page. The player needs only the playout stream name (and a playback token if your account uses secure playback).

What can go wrong​

SymptomLikely causeFix
Player stays on loading, or reports the stream isn't foundThe stream isn't live, or the player has the ingest name instead of the playout nameCheck the stream is live; use the playout name
Player shows an error on a stream that plays in the DashboardYour account uses secure playbackAdd a valid playback token
Encoder is rejectedWrong stream name, or another encoder is already sending to itCopy the stream name again; stop the other encoder
Stuttering, long startBitrate too high for the uplink, or keyframes too far apartLower the bitrate; keyframe every 2 seconds

Next steps​