Live streaming
Streaming a meeting to YouTube, Facebook or any RTMP address: how the relay works, FFmpeg and the cron worker, destinations and stream keys, the package feature, settings and troubleshooting.
The Live Streaming plugin sends a meeting to YouTube Live, Facebook Live, Twitch or any other RTMP address while the meeting runs. It is free and new in version 1.1.0.
1. How it works
A browser cannot push RTMP, so your server relays the stream.
- The host or a co-host presses Live in the room, chooses where to send, and presses Go live.
- The host's browser mixes the tiles, the shared screen and every voice into one 1280 x 720 picture. It records that picture in short pieces (2 seconds each) and posts them to your site.
- The pieces are saved in
uploads/streams/<session>/<id>.webm. - A background program,
plugins/live-streaming/worker.php, feeds the file to FFmpeg. FFmpeg encodes H.264 video and AAC sound and sends it to the destination. - Everyone in the room sees a red LIVE badge.
The stream comes from the host's browser. The host must keep the room tab open.
The stream stops when:
- the host or a co-host presses Stop live stream,
- the host who started it leaves the room,
- the meeting ends,
- no video arrives for the idle time (30 seconds by default), or
- the longest time is reached (6 hours by default).
The pieces are deleted when the stream ends.
2. What you need
- The package feature Live streaming on the host's package. On the default packages it is on for Enterprise only. See Packages and billing. Without it, Go live says that live streaming is not in the package.
- FFmpeg on the server, with the H.264 encoder (
libx264) and AAC. Check withffmpeg -versionandffmpeg -encoders. - A way to start a background program. PHP must be allowed to run
execorpopen. If your host blocks them, use the cron fallback in section 4. - The cron job. The streams job restarts a relay that has stopped and closes streams that are stuck.
- CPU. FFmpeg encodes every stream. Each stream uses a share of the CPU.
Most cPanel shared hosts do not allow FFmpeg or long background programs. Use a VPS or a host that does.
Installing FFmpeg
On Ubuntu or Debian:
apt install ffmpeg
Find its path with which ffmpeg. It is often /usr/bin/ffmpeg.
3. Admin settings
Open Settings, Plugins and activate Live Streaming. Two items appear in the admin menu under Plugins: Live streams and Streaming settings.
| Field | Default | What it does |
|---|---|---|
| FFmpeg path | ffmpeg | The command, or the full path such as /usr/bin/ffmpeg. |
| Longest stream (hours) | 6 | A stream stops by itself after this time. From 1 to 24. |
| Video bitrate (kbps) | 2500 | What FFmpeg sends. YouTube and Facebook like 2500 to 4500 for 720p. From 500 to 8000. |
| Picture size | 1280 x 720 | The size FFmpeg sends: 1280 x 720, 854 x 480 or 640 x 360. The room is always mixed at 1280 x 720. |
| Streams at the same time | 3 | The most streams on the whole server. From 1 to 50. Plan one share of CPU for each. |
| Stop when no video comes for (seconds) | 30 | If the host browser stops sending, the stream ends after this time. From 10 to 300. |
| Start the relay at once | Yes | On: the relay starts the moment the host goes live. Off: only the cron job starts it. |
| PHP command for the relay | empty | Leave empty to find PHP by itself. Example: /usr/local/bin/php. |
| Keep the recorded file | No | Keep the browser pieces for a day after the stream. |
| Allow a file as destination (testing only) | No | FFmpeg writes an .flv file. Keep it off on a live site. |
Live streams lists running and past streams with the title, the meeting ID, the size, the time and any error. A Stop button ends a running stream.
4. The cron job
The plugin adds a job called streams to the normal cron. The cron is described in Requirements and installation. For streaming, run the cron every minute if you can.
The job:
- starts a relay for a stream that has none,
- closes a stream whose meeting has ended,
- ends a stream that is stopping,
- fails a stream that has received no video at all after 2 minutes,
- stops a relay that stopped answering for 90 seconds.
If your host does not allow background programs from the web, switch Start the relay at once off. The cron job then starts every relay. A stream can start up to one cron interval late.
5. Destinations
A destination is an RTMP address and a stream key. The host can type one when going live, or use one saved in the account.
YouTube
- In YouTube Studio press Create, Go live, then Stream.
- Copy the Stream URL. It starts with
rtmp://a.rtmp.youtube.com/live2. - Copy the Stream key.
- In the Live Producer choose Streaming software.
- Copy the Server URL. It starts with
rtmps://live-api-s.facebook.com:443/rtmp/. - Copy the Stream key.
Twitch and others
Twitch uses rtmp://live.twitch.tv/app with your stream key. Any service that gives you an rtmp:// or rtmps:// address and a key works.
The address must start with rtmp:// or rtmps://, must not contain spaces and must point to a public server. Addresses that point to your own server or a private network are refused. The stream key may only hold letters, digits and a few signs (. _ ~ % ! $ & ' ( ) * + , ; = : @ / ? -).
Saved destinations
Members open Streaming destinations in the account menu to add, name and delete destinations. In the room, Save this destination saves the one being used. The stream key is stored encrypted and is never sent back to a browser. The list shows only a short hint of the key.
A member can save destinations before the package includes streaming. They work after an upgrade.
6. Going live, step by step
- Start the meeting. Open Live in the toolbar.
- Choose Send to: a saved destination, or A new address with the RTMP address and the stream key. Tick Save this destination to keep it.
- Type a Title (the meeting title is the default).
- Create the broadcast in YouTube or Facebook first, so the platform is waiting.
- Press Go live. The state goes from Starting to LIVE. The panel shows the time and the bitrate.
- Press Stop live stream when you are done, then end the broadcast on the platform.
Only one live stream can run in a meeting. Use Chrome, Edge or Firefox for the host. Browsers without MediaRecorder support cannot stream.
7. Troubleshooting
| Problem | Fix |
|---|---|
| "Live streaming is not in your package" | Turn on the Live streaming feature in the host's package. |
| "The server is streaming at full capacity" | The streams limit is reached. Raise Streams at the same time only if the CPU can take it. |
| The state stays on Starting | The relay did not start. Check the FFmpeg path and that the cron job runs. Switch Start the relay at once off if the host blocks background programs. |
| The stream fails at once with an error | Read the error in Live streams. FFmpeg's last words are shown with the address and key cut out. |
| "No video arrived from the room" | The host's browser did not send. Use Chrome, Edge or Firefox, and keep the tab open and in front. |
| The platform shows no picture | The address or the key is wrong, or the platform has not started the broadcast. Copy them again. |
| The picture stutters | Lower Video bitrate and Picture size. Check the CPU of the server. |
| The stream ends after some hours | The Longest stream limit was reached. Raise it, up to 24 hours. |
| "That address points to this server or a private network" | Use the public address given by the stream service. |