- Introduction
- What is it, and what does it do?
- Minimum Setup
- Publish and Consume Content
- Architecture Summary
- Transcoding
- Hosted Setup
- Start on System Boot
- Roadmap.
This page gives an introduction to simple-streaming-server
.
The main objective is to help you install simple-streaming-server
on a computer.
It will also help you to operate simple-streaming-server
.
This repo is published under MIT License.
simple-streaming-server
is software to run on a computer or a server. It uses entirely open-source and freely available software, and makes extensive use of Livepeer's open-source video infrastructure software.
A simple-streaming-server
can receive and serve streaming content. It can also be configured to transcode streaming content to improve accessibility.
The streaming content must be Video + Audio, and must be published into the simple-streaming-server
in a linear stream.
This stream of content can be live (from camera and microphone) or recorded (from a disk).
It can receive streaming content published in RTMP
format, from tools like OBS Studio, ManyCam, FFmpeg, or many other tools.
It can serve streaming content over http
with a .m3u8
extension, for playback in tools like VLC Media Player, media-enabled Mobile browsers (Brave, Firefox or Chrome), embedded in an html
page using a stream player such as hls.js
, or inside a mobile application using something like ExoPlayer.
Here are instructions to setup a simple-streaming-server
on a local computer. They will work on Mac or Linux (Ubuntu).
- Download the latest release of pre-compiled software from Livepeer's Release Page on Github, under where it says Assets:
-
On a Mac, download the
livepeer-darwin-amd64.tar.gz
file to the Downloads folder -
On Linux (Ubuntu), download the
livepeer-linux-amd64.tar.gz
file
- Unzip the file:
-
On Mac, simply open the file, and it will extract to the folder containing the file (Downloads).
-
On Linux (Ubuntu), open the
livepeer-darwin-amd64.tar.gz
file then click "Extract", and extract it to "Home".
- Open
Terminal
, and navigate to the folder containing thelivepeer
binary:
-
On Mac, run
cd Downloads/livepeer-darwin-amd64
-
On Linux (Ubuntu), run
cd livepeer-linux-amd64
-
Run
./livepeer -broadcaster
-
Wait until the text
Video Ingest Endpoint - rtmp://127.0.0.1:1935
is displayed.
simple-streaming-server
is now running.
Now that simple-streaming-server
is running, here are some further things you can do:
-
Publish and Consume content to and from
simple-streaming-server
, -
Add Transcoding to increase accessibility of streaming content,
This section explains how to publish and consume content to and from simple-streaming-server
.
This can be done via a command line interface using FFmpeg
, or from a graphical user interface using OBS Studio and VLC Media Player.
This section explains how to publish and consume content to and from simple-streaming-server
using a command line interface (CLI).
Install FFmpeg
on Linux (Ubuntu) using sudo apt install ffmpeg
Install FFmpeg
on a Mac using instructions on FFmpeg's website.
FFmpeg
can be used to generate and publish a test source of content to simple-streaming-server
:
-
Make sure
simple-streaming-server
is running on localhost127.0.0.1
. -
Run the following command:
ffmpeg -re -f lavfi -i \
testsrc=size=500x500:rate=30,format=yuv420p \
-f lavfi -i sine -c:v libx264 -b:v 1000k \
-x264-params keyint=60 -c:a aac -f flv \
rtmp://127.0.0.1:1935/test_source
test_source
is the "stream key" for this publication.size=500x500
defines the dimensions of the test video source in pixelsrate=30
defines the frame rate of the test video in frames per second1000k
defines the bitrate for the streamkeyint=60
defines the keyframe interval in frames
- See that
simple-streaming-server
is receiving a stream calledtest_source
.
FFmpeg
can be used to publish recorded content to simple-streaming-server
:
-
Make sure
simple-streaming-server
is running on localhost127.0.0.1
. -
Run the following command:
ffmpeg \
-re \
-i video.mov \
-codec copy \
-f flv rtmp://127.0.0.1:1935/recorded_content
recorded_content
is the "stream key" for this publication.
- See that
simple-streaming-server
is receiving a stream calledrecorded_content
.
ffplay
is part of FFmpeg
, and can be used to request and playback content from simple-streaming-server
.
-
Make sure content is being published into
simple-streaming-server
. -
Run
ffplay http://127.0.0.1:8935/stream/test_source.m3u8
test_source
is the "stream key" used when publishing content tosimple-streaming-server
.
- See the content from the
test_source
stream being played back:
curl
is command line tool and library for transferring data with URLs, and can be used to inspect metadata of content published by simple-streaming-server
.
-
Make sure content is being published into
simple-streaming-server
. -
Run
curl http://127.0.0.1:8935/stream/test_source.m3u8
test_source
is the "stream key" used when publishing content tosimple-streaming-server
.
- View metadata about the stream(s) of content available for consumption, with
.m3u8
extension(s):
-
Run
curl http://127.0.0.1:8935/stream/test_source/source.m3u8
-
View metadata about the segment(s) of content available for consumption, with
.ts
extension(s):
This section explains how to publish content to and consume content from simple-streaming-server
using graphical user interfaces (GUIs).
OBS Studio can be used to configure and publish streaming content to simple-streaming-server
:
-
Download and install OBS Studio
-
Launch OBS Studio, and decline to use the auto-configuration wizard.
-
Go to Settings > Output
-
Set "Output Mode" to "Advanced".
-
Set the Streaming Keyframe interval to
2
seconds.
-
Go to Settings > Stream
-
Set "Service" to
Custom
-
Set "Server" to
rtmp://127.0.0.1
and "Stream Key" toobs-studio
-
Click OK to close "Settings".
-
Under "Sources", click the
+
and select "Text" source. -
Add some text
-
Make sure
simple-streaming-server
is running. -
Click "Start Streaming" (and also "Start Recording" if you also want to record the stream).
-
See that
simple-streaming-server
is receiving a stream calledobs-studio
.
Learn about what other sources of content can be configured.
VLC Media Player can be used to request and playback content from simple-streaming-server
.
-
Make sure content is being published into
simple-streaming-server
. -
Download and install VLC Media Player
-
Launch VLC Media Player
-
Select Media > Open Network Stream... (Ctrl-N)
-
Enter
http://127.0.0.1:8935/stream/obs-studio.m3u8
as the network URL
- Click "Play", and see the content from the
obs-studio
stream:
OBS Studio can be used to add video and audio content sources to be published to simple-streaming-server
.
- Configuring Video:
- The big black box in the middle of the screen is the "canvas" for visual content.
- One or more "Scenes" can be configured, which can be switched between when publishing
- Zero or more "Sources" can be added to each "Scene", to
- Examples of "Sources" are: static text, images, recorded videos, live videos (e.g. from a camera), screenshares, window shares.
Configuring Audio
- Audio being published can be monitored in the "Mixer", both visually and audibly
- Audio sources can be configured in Settings > Audio, and will appear in the "Mixer"
- Examples of sources are sound cards, microphones and audio played by the computer.
Here is an example of a variety of different content sources configured in OBS Studio:
A simple-streaming-server
can be deployed on a hosted server. For this It is assumed that this hosted server is running Linux (Ubuntu).
It is necessary to configure simple-streaming-server
appropriately, in order to allow required remote access to the server.
When starting simple-streaming-server
, run the following command:
./livepeer \
-broadcaster \
-rtmpAddr 127.0.0.1:1935 \
-httpAddr 127.0.0.1:8935
Note: this command is technically equivalent to running the same command without -rtmpAddr
or -httpAddr
flags, as these are the default options. They are explicitly included here for illustrative purposes only.
simple-streaming-server
will only allow content to be published and consumed on the hosted server itself:
publish | consume | |
---|---|---|
local | yes | yes |
remote | no | no |
When starting simple-streaming-server
, run the following command:
./livepeer \
-broadcaster \
-rtmpAddr 127.0.0.1:1935 \
-httpAddr 0.0.0.0:8935
This will only allow content to be published from the hosted server itself but will allow content to be consumed locally or remotely, by any host with network access to the hosted server.
publish | consume | |
---|---|---|
local | yes | yes |
remote | no | yes |
When starting simple-streaming-server
, run the following command:
./livepeer \
-broadcaster \
-rtmpAddr 0.0.0.0:1935 \
-httpAddr 0.0.0.0:8935
This will allow content to be published and / or consumed remotely, by any host with network access to the hosted server.
publish | consume | |
---|---|---|
local | yes | yes |
remote | yes | yes |
Note: when publishing or consuming content from a remote host, the server's IP address must be used instead of 127.0.0.1
Note: you may need to open ports 1935
and 8935
in your server's firewall configuration in order to allow internet access.
This section provides a high level summary of the logical and functional architecture of a simple-streaming-server
.
Content can be published to simple-streaming-server
via RTMP
to port 1935
.
Content can be consumed by requesting a URL with .m3u8
extension, via http
from port 8935
. simple-streaming-server
will respond by serving a sequence of content segment files with .hs
extensions over http
, for playback.
The code for this software is available on Livepeer's go-livepeer repository.
simple-streaming-server
can be configured to transcode the source content into different frame sizes and frame rates.
Transcoding allows content to be consumed by devices with less-performant network connections (bytes per second).
Transcoding can be performed on the same computer / server running the simple-streaming-server
.
- Open a
Terminal
, and run the following command from the folder containinglivepeer
binary:
./livepeer \
-broadcaster \
-orchAddr 127.0.0.1:8936 \
-transcodingOptions P144p30fps16x9,P240p30fps16x9 \
-v 99
-orchAddr
specifies the location of the Orchestrator / Transcoder service on the network-transcodingOptions
specifies frame sizes and frame rates to be transcoded into.-v 99
is the highest level of logging output.
- Open another
Terminal
, and run the following command from the folder containinglivepeer
binary:
./livepeer \
-orchestrator \
-transcoder \
-serviceAddr 127.0.0.1:8936 \
-cliAddr 127.0.0.1:7936 \
-v 99
-orchestrator
and-transcoder
tell the software to run in Orchestrator and Transcoder modes-serviceAddr
specifies the IP address and port that this service should run on the network-v 99
is the highest level of logging output.
simple-streaming-server
is now running with Local Transcoding enabled.
- Inspect the content metadata to see the additional streams available for consumption:
Note: many players of streaming content will dynamically switch between available streams in order to optimise the quality of playback given the available bandwidth.
Transcoding activities can also be distributed across an Orchestrator, and one or more Transcoders.
- Open a
Terminal
, and run the following command from the folder containinglivepeer
binary:
./livepeer \
-broadcaster \
-orchAddr 127.0.0.1:8936 \
-transcodingOptions P144p30fps16x9,P240p30fps16x9 \
-v 99
- Open another
Terminal
, and run the following command from the folder containinglivepeer
binary:
./livepeer \
-orchestrator \
-orchSecret pineapple \
-serviceAddr 127.0.0.1:8936 \
-cliAddr 127.0.0.1:7936 \
-v 99
-orchSecret
is a way for this Orchestrator to allow Transcoders to authenticate
- Open another
Terminal
, and run the following command from the folder containinglivepeer
binary:
./livepeer \
-transcoder \
-orchSecret pineapple \
-orchAddr 127.0.0.1:8936 \
-v 99
simple-streaming-server
is now running with (Local) Distributed Transcoding enabled.
Transcoding can also be performed on a different computer / server from the simple-streaming-server
.
For this you will need two hosts (computers / servers):
- For the
simple-streaming-server
- This host will need to be able to connect to port
8936
on the host of the remote transcoder.
- This host will need to be able to connect to port
- For the remote transcoder
- Open a
Terminal
on the remote transcoder host, and run the following command:
./livepeer \
-broadcaster \
-orchAddr 192.168.2.113:8936 \
-transcodingOptions P144p30fps16x9,P240p30fps16x9 \
-v 99
192.168.2.113
is the IP address of the remote transcoder host
- Open a
Terminal
on thesimple-streaming-server
host, and run the following command:
./livepeer \
-orchestrator \
-transcoder \
-serviceAddr 192.168.2.113:8936 \
-cliAddr 127.0.0.1:7936 \
-v 99
192.168.2.113
is the IP address of the remote transcoder host
simple-streaming-server
is now running with Remote Transcoding enabled.
Transcoding services can be purchased directly from individual Orchestrators operating in Livepeer's public Transcoding Marketplace.
Services are provide on a pay-as-you-go basis using Ethereum, without any minimum contractual obligation.
- Install
geth
, which is client software to run Ethereum, released by Ethereum Foundation.
- This client software can be used to sync Ethereum blockchain, and to broadcast transactions to be included in the blockchain.
- Open a
Terminal
and run the following command to rungeth
client
geth -rpc -rpcapi eth,net,web3 --syncmode "light"
- Wait until
geth
has imported all new block headers, and has started downloading 1 block at a time:
- Open another
Terminal
and run the following command:
./livepeer \
-broadcaster \
-network mainnet \
-transcodingOptions P144p30fps16x9,P240p30fps16x9 \
-ethUrl http://127.0.0.1:8545 \
-pixelsPerUnit 1 \
-maxPricePerUnit 1 \
-v 99
mainnet
signifies Ethereum's main network-ethUrl
is the network location of thegeth
service.-pixelsPerUnit
and-maxPricePerUnit
are for setting the maximum price to be paid for Transcoding
- Enter a Passphrase twice:
Note: no characters will appear in the window when typing the passphrase.
The Passphrase will be used to encrypt the Private Key generated by this process. The Private Key will be used to sign transactions for publishing on Ethereum.
-
Enter the Passphrase again to start the
simple-streaming-server
. -
Wait until the text
CLI server listening on 127.0.0.1:7935
is displayed in the console:
- Open a
Terminal
, and run the following command from the folder containinglivepeer_cli
binary:
./livepeer_cli
-
Send some ETH from your wallet to the
ETH Account
listed underNODE STATS
. -
In
livepeer_cli
, run option12. Invoke "deposit broadcasting funds" (ETH)
This command will deposit some ETH into a smart contract in Livepeer's protocol, which can be spent on Transcoding services.
-
Enter the amount of ETH you would like to deposit into the contract.
-
Enter the amount of ETH you would like to keep in reserve in the contract, and press return.
simple-streaming-server
is now running with Outsourced Transcoding on Livepeer, with payment on Ethereum.
You can now stream content into simple-streaming-server
, and observe that your content is being transcoded into different formats.
Further details on setting the maximum price to be paid for Transcoding can be found in Livepeer's Broadcaster documentation.
To find out more about Livepeer, go to this 10-minute primer.
This section explains how to configure simple-streaming-server
to start when the underlying system starts.
The instructions use systemd
on Linux (Ubuntu), and require root / sudo
access.
-
Ensure the
simple-streaming-server
has been downloaded and installed on the underlying system -
Run the following commands to fetch a
simple-streaming-server.service
file from/etc/systemd/system
folder
cd /etc/systemd/system
sudo wget https://raw.githubusercontent.com/videoDAC/simple-streaming-server/master/systemd/simple-streaming-server.service
- Run the following commands to enable and start
simple-streaming-server.service
:
sudo systemctl enable simple-streaming-server.service
sudo systemctl start simple-streaming-server.service
simple-streaming-server
is now running.
- Run the following command to tail the logs:
sudo journalctl -f --unit=simple-streaming-server.service
Note: by default, the simple-streaming-server
will only accept inbound rtmp
content and serve outbound http
content from and to localhost (127.0.0.1
). To open ports to remote hosts, change the corresponding configuration to 0.0.0.0
and run sudo systemctl daemon-reload
, then sudo systemctl restart simple-streaming-server.service
.
-
Ensure the
FFmpeg
has been downloaded and installed on the underlying system -
Run the following commands to fetch a
publish-test-source.service
file from/etc/systemd/system
folder
cd /etc/systemd/system
sudo wget https://raw.githubusercontent.com/videoDAC/simple-streaming-server/master/systemd/publish-test-source.service
- Run the following commands to enable and start
simple-streaming-server.service
:
sudo systemctl enable publish-test-source.service
sudo systemctl start publish-test-source.service
a test source is now being published into simple-streaming-server
- Run the following command to tail the logs:
sudo journalctl -f --unit=publish-test-source.service
- Run
curl http://0.0.0.0:8935/stream/hello_consumer.m3u8
to see
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:PROGRAM-ID=0,BANDWIDTH=4000000,RESOLUTION=1000x1000
hello_consumer/source.m3u8
-
Ensure the
simple-streaming-server
has been downloaded and installed on the underlying system -
Run the following commands to fetch a
simple-streaming-server.service
file from/etc/systemd/system
folder
cd /etc/systemd/system
sudo wget https://raw.githubusercontent.com/videoDAC/simple-streaming-server/master/systemd/local-transcoding.service
- Run the following commands to enable and start
local-transcoding.service
:
sudo systemctl enable local-transcoding.service
sudo systemctl start local-transcoding.service
simple-streaming-server
is now running with local transcoding service.
- Run the following command to tail the logs:
sudo journalctl -f --unit=local-transcoding.service
- Ensure
publish-test-source.service
is running, then runcurl http://0.0.0.0:8935/stream/hello_consumer.m3u8
to see
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:PROGRAM-ID=0,BANDWIDTH=4000000,RESOLUTION=1000x1000
hello_consumer/source.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=0,BANDWIDTH=400000,RESOLUTION=256x144
hello_consumer/P144p30fps16x9.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=0,BANDWIDTH=600000,RESOLUTION=426x240
hello_consumer/P240p30fps16x9.m3u8
-
Ensure the
geth
binary is in/home/ubuntu/ethereum
-
Run the following commands to fetch a
geth-light.service
file, from/etc/systemd/system
folder
cd /etc/systemd/system
sudo wget https://raw.githubusercontent.com/videoDAC/simple-streaming-server/master/systemd/geth-light.service
- Run the following commands to enable and start
geth-light.service
:
sudo systemctl enable geth-light.service
sudo systemctl start geth-light.service
geth-light
is now running, allowing simple-streaming-server
to connect to Ethereum.
- Run the following command to tail the logs:
sudo journalctl -f --unit=geth-light.service
This section describes additional features to be defined as part of this guide.
This section will describe how to configure simple-streaming-server
to serve content as https
instead of http
.
This is necessary for content to be served to webpages which themselves are served via https
.
- Install
nginx
- Configure
nginx
- Generate and install a cert
- Test the installation
This section will describe how to deploy a web-based streaming content player.
It will describe the code to be embedded into a webpage.
It will also describe how to deploy a webpage hosted on IPFS, with name resolution using ENS. An example of such a page is http://criticaltv.videodac.eth.link
This section will describe how to install and configure Orchid's open-source software to prevent simple-streaming-server
from serving content unless the consumer is paying for the content in OXT.
This section will describe how to configure the -transcoder
process to use a GPU for Transcoding.
This section will describe how to configure a commercial Content Distribution Network (CDN), such as Amazon CloudFront, Cloudflare or Akamai. This is required in order to be able to serve content to large numbers of viewers simultaneously.
This section will explain how to configure simple-streaming-server
to only allow publishing and consuming from specific whitelisted IP addresses.
This section will seek to add instructions for running simple-streaming-server
on a Raspberry Pi.