In-Depth Streaming Guide
This guide provides more detailed examples of how to push streams to and play streams from LiveGo using common tools.
Pushing Streams (Ingest)
Any RTMP-compliant encoder can push a stream to LiveGo.
Using FFmpeg
FFmpeg is a powerful command-line tool for media manipulation. It's excellent for testing, scripting, or streaming from a file.
Prerequisites:
- You have a stream name (e.g.,
my_stream
). - You have obtained a
channelkey
from the API:curl "http://localhost:8090/control/get?room=my_stream"
.
Example: Streaming a video file
This command reads a file, input.mp4
, and streams its content to LiveGo without re-encoding, which is efficient.
# Replace {channelkey} with your actual key
ffmpeg -re -i input.mp4 -c copy -f flv rtmp://localhost:1935/live/{channelkey}
-re
: Reads the input at its native frame rate.-i input.mp4
: Specifies the input file.-c copy
: Copies the streams without re-encoding.-f flv
: Specifies the output format as FLV, required for RTMP.
Using OBS Studio
OBS Studio is a popular free and open-source software for live streaming and recording.
- Open Settings: Go to
File
>Settings
. -
Go to the Stream Tab:
- Service: Select
Custom...
. - Server: Enter the RTMP ingest URL:
rtmp://localhost:1935/live
. - Stream Key: Paste the
channelkey
you obtained from the LiveGo API. - Apply and Start Streaming: Click
OK
to save the settings, then clickStart Streaming
in the main OBS window.
- Service: Select
Playing Streams (Egress)
Using VLC or ffplay
For desktop playback, media players like VLC or the ffplay
command-line tool are great options.
-
RTMP Playback:
- URL:
rtmp://localhost:1935/live/my_stream
- Command:
ffplay rtmp://localhost:1935/live/my_stream
- URL:
-
HTTP-FLV Playback:
- URL:
http://localhost:7001/live/my_stream.flv
- Command:
ffplay http://localhost:7001/live/my_stream.flv
- URL:
-
HLS Playback:
- URL:
http://localhost:7002/live/my_stream.m3u8
- Command:
ffplay http://localhost:7002/live/my_stream.m3u8
- URL:
Web Playback with flv.js
As mentioned in the README.md
, LiveGo works well with flv.js
for low-latency streaming in web browsers.
Here is a minimal HTML example:
<!DOCTYPE html>
<html>
<head>
<title>LiveGo with flv.js</title>
<script src="https://cdn.jsdelivr.net/npm/flv.js/dist/flv.min.js"></script>
</head>
<body>
<video id="videoElement" controls autoplay muted></video>
<script>
if (flvjs.isSupported()) {
var videoElement = document.getElementById('videoElement');
var flvPlayer = flvjs.createPlayer({
type: 'flv',
isLive: true,
url: 'http://localhost:7001/live/my_stream.flv' // Your stream URL
});
flvPlayer.attachMediaElement(videoElement);
flvPlayer.load();
flvPlayer.play();
}
</script>
</body>
</html>
To use this example:
- Save the code as
index.html
. - Make sure a stream named
my_stream
is being published to LiveGo. - Open the
index.html
file in a web browser.
Note: You may need to serve this HTML file from a local web server to avoid CORS issues, or configure LiveGo to send appropriate CORS headers if you deploy it on a different domain.