Dev Environment - Livepeer Video Services (Independent / Self-Sovereign)

Summary

This quickstart guide is for developers of livestreaming applications who wish to incorporate Livepeer Video Services into their application stack.

It is primarily intended to be run on a developer’s PC as part of their local dev environment, but can also run on a VPS / hosted server (see notes below).

Notes on Self-Sovereignty

This guide does not require you to provide an email address, or to create an account with any centralised provider of infrastructure services.

It is intended to help you build and operate directly on Livepeer’s Public Network, and maintain full operational independence as a self-sovereign entity.

It does not require you to pay any cryptocurrency while developing and testing, or while operating with low volume in production.

Feedback

Please leave and feedback or suggestions as comments below.

Pre-requisites

You will need

  • a host (e.g. your PC, or a VPS) running Linux (amd64), MacOS or Windows
  • an internet connection
  • ffmpeg and curl installed on your host

Setup

Follow these steps in order to get up and running with a Livepeer Broadcaster on the test network.

Get Livepeer Software

These steps will download the Livepeer software to your host.

  1. Download a .tar.gz file containing livepeer’s latest software for your host’s operating system.

  2. Extract the software to a directory on your host.

Run Broadcaster

These steps will start a Livepeer Broadcaster process on your host.

  1. Open a Terminal window, and navigate to the directory containing the livepeer executable binary.

  2. Run the following (if using Windows, use livepeer.exe instead of ./livepeer):

./livepeer \
        -broadcaster \
        -network arbitrum-one-rinkeby \
        -ethUrl https://rinkeby.arbitrum.io/rpc \
        -ethPassword password
  1. When prompted for a Passphrase: type password (no characters will appear).

  2. Wait for the Broadcaster to display Video Ingest Endpoint - rtmp://127.0.0.1:1935. The Broadcaster is ready to ingest live video.

Publish Live Stream

These steps will publish a test live stream into the Livepeer Broadcaster running on your host.

  1. In a new tab, run the following command, to publish a live stream into the Broadcaster:
ffmpeg \
        -re -f lavfi \
        -i testsrc=size=1280x720: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/live-stream-id
  1. In a new tab, run curl http://127.0.0.1:8935/stream/live-stream-id.m3u8. This should display the metadata of the live stream being served by the Broadcaster:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:PROGRAM-ID=0,BANDWIDTH=4000000,RESOLUTION=1280x720
stream-id/source.m3u8
  1. Run ffplay http://127.0.0.1:8935/stream/stream-id/source.m3u8 to play back your stream’s source rendition.

Start Transcoding (via Livepeer Public Testnet)

These steps will configure your Livepeer Broadcaster to connect to Orchestrators on Livepeer Public Testnet, to transcode the test livestream. This helps content to be accessible to more users.

  1. Run ./livepeer_cli and make a note of the Broadcaster Account listed under NODE STATS. Observe that the address’s ETH Balance is currently 0.

  2. Go to Rinkeby Arbitrum FaucETH and request some test funds. You will need to provide the Broadcaster Account from the previous step.

  3. In livepeer_cli, select 1 (Get node status), and observe that the ETH Balance is now non-zero.

  4. Observe that under BROADCASTER STATS, the Deposit and Reserve are both currently 0.

  5. Select option 11 (Invoke “deposit broadcasting funds” (ETH)). Enter 0.3 for deposit, 0.1 for reserve.

  6. Select 1 (Get node status), and observe that the Deposit and Reserve are both currently 0.

  7. Run curl http://127.0.0.1:8935/stream/stream-id.m3u8 again.

  8. Notice that there are now two additional renditions being served - in 240p and 360p. These renditions are being provided by Orchestrators running on Livepeer’s Testnet:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:PROGRAM-ID=0,BANDWIDTH=4000000,RESOLUTION=1280x720
stream-id/source.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=0,BANDWIDTH=600000,RESOLUTION=426x240
stream-id/P240p30fps16x9.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=0,BANDWIDTH=1200000,RESOLUTION=640x360
stream-id/P360p30fps16x9.m3u8
  1. Run ffplay http://127.0.0.1:8935/stream/stream-id/P360p30fps16x9.m3u8 to play back the 360p rendition.

  2. Run ffplay http://127.0.0.1:8935/stream/stream-id/P240p30fps16x9.m3u8 to play back the 240p rendition.

Congratulations, you are now running a Livepeer Video Services in your development environment.

Appendices

Technical Parameters

rtmp endpoint: rtmp://127.0.0.1:1935/{insert-stream-id-here}
hls manifest: http://127.0.0.1:8935/stream/{insert-stream-id-here}.m3u8

Running on a VPS / hosted server

The above instructions will also work on a VPS or a hosted server. This will very likely be required when deploying your application into production.

In order to publish to and consume from a Broadcaster, you will need to expose ports 1935 and 8935 to the internet.

GUI-based publishing and playback

It is also possible to publish and playback live video using graphical user interfaces such as OBS Studo and VLC Player. More details here.

Migration to Mainnet

Once you have developed your application, migrating your stack to a production environment is very easy.

This will provide you with the highest quality of service available, from financially-incentivised mainnet Orchestrators.

Run the ./livepeer command with different parameters, as described below.

./livepeer \
        -broadcaster \
        -network arbitrum-one-mainnet \
        -ethUrl https://arb1.arbitrum.io/rpc \
        -ethPassword password

You will need to submit a deposit and a reserve, denominated in Ether, in order to pay for the services provided by Orchestrators on Livepeer’s Public Network.

1 Like