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 need | Details |
|---|---|
| A Envision Streaming account | With a role that may create streams |
| An encoder | OBS Studio, ffmpeg, vMix, Wirecast or a hardware encoder that sends RTMP |
| A web page | Any HTML page where you can paste an iframe |
Step 1: Create a stream
Option A: Dashboard
- Sign in to the Envision Streaming Dashboard.
- Create a new stream.
- 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.
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
- Open Settings › Stream and set Service to Custom.
- Paste the RTMP URL into Server and the stream name into Stream Key.
- Under Settings › Output (Advanced mode), set Rate Control to CBR and Keyframe Interval to 2.
- 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.
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
| Symptom | Likely cause | Fix |
|---|---|---|
| Player stays on loading, or reports the stream isn't found | The stream isn't live, or the player has the ingest name instead of the playout name | Check the stream is live; use the playout name |
| Player shows an error on a stream that plays in the Dashboard | Your account uses secure playback | Add a valid playback token |
| Encoder is rejected | Wrong stream name, or another encoder is already sending to it | Copy the stream name again; stop the other encoder |
| Stuttering, long start | Bitrate too high for the uplink, or keyframes too far apart | Lower the bitrate; keyframe every 2 seconds |