Service: SRS - EyevinnOSC/community GitHub Wiki
Simple Realtime Server (SRS)
Simple Realtime Server (serviceId ossrs-srs) is a high-performance, open source live streaming server supporting RTMP, HLS, HTTP-FLV, SRT and MPEG-DASH. It is widely used as a media origin for live streaming platforms and CDNs. In Eyevinn Open Source Cloud (OSC) it is a long-running service instance. License: MIT. Source: ossrs/srs.
What it can do
- Ingest live streams over RTMP from OBS, ffmpeg or any RTMP encoder.
- Serve the live stream as HLS, HTTP-FLV and RTMP.
- Show publishers, active players and real-time bitrate and frame rate statistics in the SRS web console.
- Expose an HTTP API, for example to list active streams.
Creating an instance
Call create-service-instance with serviceId: "ossrs-srs". The instance name must be alphanumeric and at most 20 characters. SRS has no other options and no dependencies on other OSC services.
{ "name": "mystream" }
Wait with wait-for-service-ready (or get-instance-status) and read the instance host and URLs with describe-service-instance.
Options
| Option | Required | Type | Meaning |
|---|---|---|---|
| name | Yes | string | Name of the instance. Alphanumeric/underscore only, at most 20 characters. |
The service has no other options and no secrets.
Using the instance
Push a stream via RTMP
SRS listens for RTMP on port 1935 by default. Push with OBS, ffmpeg or any RTMP encoder:
INSTANCE_HOST=mystream.ossrs-srs.auto.prod-se.osaas.io
ffmpeg -re -i input.mp4 \
-c:v libx264 -preset veryfast -b:v 2000k \
-c:a aac -b:a 128k \
-f flv rtmp://${INSTANCE_HOST}/live/stream
The stream key (last path segment, here stream) can be any string you choose.
Play the stream
Once a stream is pushed it is available in several formats:
| Protocol | URL |
|---|---|
| HLS | https://{instance-host}/live/stream.m3u8 |
| HTTP-FLV | http://{instance-host}/live/stream.flv |
| RTMP | rtmp://{instance-host}/live/stream |
ffplay https://mystream.ossrs-srs.auto.prod-se.osaas.io/live/stream.m3u8
SRS console and API
The SRS web console is available at the instance URL. Example of listing active streams with the HTTP API:
const INSTANCE_URL = 'https://mystream.ossrs-srs.auto.prod-se.osaas.io';
const response = await fetch(`${INSTANCE_URL}/api/v1/streams/`);
const { streams } = await response.json();
for (const stream of streams) {
console.log(`Stream: ${stream.name}, clients: ${stream.clients}`);
}
CLI usage
osc create ossrs-srs myserver -o name="myserver"