Quickstart: Running a full Livepeer stack on a Testnet (Rinkeby)

Here are some commands for running livepeer on localhost, connecting to Rinkeby testnet. They are optimised for linux, but can be adapted for mac and windows.

For beginners, this will set up a minimum viable stack of Livepeer’s video instructure software on a single host, and demonstrate a) a livestreaming server, b) live video transcoding, and c) probabilistic micropayments.

For experienced users of Livepeer, this is a good opportunity to learn a little bit about the role of -broadcaster in Livepeer network, which can be useful in onboarding new Broadcasters in the future :slight_smile:

If you found this useful, or have any issues, please leave a comment below.

Assumptions

  • you have an RPC endpoint from infura or alchemy
    • running these instructions against a local geth node is currently not possible due to this issue.
  • ffmpeg is installed on your localhost, if not then:
    • sudo apt install ffmpeg
  • latest version of livepeer (0.5.25) is installed and unzipped in /home/ubuntu, if not then:
    • wget https://github.com/livepeer/go-livepeer/releases/download/v0.5.25/livepeer-linux-amd64.tar.gz
    • tar -xzf livepeer-linux-amd64.tar.gz

Run an Orchestrator/Transcoder

In a Terminal window, run:

./livepeer -orchestrator -transcoder \
        -network rinkeby \
        -ethUrl {your-infura/alchemy-endpoint} \
        -pricePerUnit 1000000 \
        -serviceAddr 127.0.0.1:8935 \
        -ethPassword password \
        -v 99

Note: you will need to enter the password twice as password when you first run this process.

Configure the O/T

  • In a new Terminal window, run ./livepeer_cli

  • Make a note of the Orchestrator Account from the NODE STATS.

  • In a browser, request testnet ETH from:

  • In livepeer_cli

    • run command 16. Get test LPT
    • run command 12. Invoke multi-step "become an orchestrator" and follow the prompts. Bond all 10 LPT.
  • This will trigger four transactions to be signed and published. Wait for the final transaction (setServiceURI) to be confirmed before continuing.

  • Restart the O process. The Orchestrator is now ready to start doing work.

  • NOTE: You will have to wait until the new “round” starts before the O can redeem winning tickets. The number of the current round is found in the 1. Get node status option in livepeer_cli. Each round of livepeer protocol on Rinkeby is 300 blocks.

  • While you wait for a new round to start, you can set up a Broadcaster.

Run a Broadcaster

In a new Terminal window, run:

./livepeer -broadcaster \
        -network rinkeby \
        -ethUrl {your-infura/alchemy-endpoint} \
        -httpAddr :8936 \
        -cliAddr :7936 \
        -rtmpAddr :1936 \
        -orchAddr 127.0.0.1:8935 \
        -ethPassword password \
        -transcodingOptions P720p30fps16x9,P576p30fps16x9,P360p30fps16x9,P240p30fps16x9,P144p30fps16x9 \
        -pixelsPerUnit 1 \
        -maxTicketEV 1000000000000000 \
        -v 99

Configure the B

  • In a new Terminal window, run ./livepeer_cli -http 7936

    • note the -http 7936. Without this, it will connect to the O/T, not the B
  • Run command 11. Invoke "deposit broadcasting funds" (ETH)

    • as a reference, this guide works with a deposit of 0.06 ETH and reserve of 0.02 ETH
  • Restart the Broadcaster process.

Start streaming

  • In a new Terminal window, run the following command:
ffmpeg -re -f lavfi \
           -i testsrc=size=1920x1080:rate=30,format=yuv420p \
           -f lavfi \
           -i sine \
           -c:v libx264 \
           -b:v 10000k \
           -x264-params keyint=60 \
           -c:a aac \
           -f flv rtmp://127.0.0.1:1936/test_source
  • This will publish a 1920x1080 (1080p = FullHD) test stream into the Broadcaster at 30fps.

  • Observe the B starting to receive and serve a new livestream.

  • Observe the O/T starting to transcode multiple renditions of the stream (into 1280x720 (720p = Standard HD), 1024x576 (576p), 640x360 (360p), 426x240 (240p) and 256x144 (144p).

  • Also observe the O/T receiving Probabilistic Micropayment tickets.

Validate output streams

  • In a new Terminal window, run:
curl http://localhost:8936/stream/test_source.m3u8

This should return the following, showing all available renditions of the livestream:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:PROGRAM-ID=0,BANDWIDTH=4000000,RESOLUTION=1920x1080
test_source/source.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=0,BANDWIDTH=4000000,RESOLUTION=1280x720
test_source/P720p30fps16x9.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=0,BANDWIDTH=1500000,RESOLUTION=1024x576
test_source/P576p30fps16x9.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=0,BANDWIDTH=1200000,RESOLUTION=640x360
test_source/P360p30fps16x9.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=0,BANDWIDTH=600000,RESOLUTION=426x240
test_source/P240p30fps16x9.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=0,BANDWIDTH=400000,RESOLUTION=256x144
test_source/P144p30fps16x9.m3u8
  • To playback the smallest rendition (144p), run the following:
ffplay http://localhost:8936/stream/test_source/P144p30fps16x9.m3u8

This should play like this:

Probabilistic Micropayments

When the Orchestrator receives a winning ticket, it will call the redeemWinningTicket function onchain. This will claim the ticket’s faceValue, and add it to the Pending Fees. Pending Fees can be verified in livepeer_cli.

In order to withdraw these Pending Fees, a user can call 9. Invoke "withdraw fees" (ETH). This will withdraw fees to the user’s wallet.

All transactions called by the node can be observed on Rinkeby Etherscan.

Cleaning Up

If you have finished using the Orchestrator, you can tidy up by calling 6. Invoke "unbond" in livepeer_cli.

Easter egg

You can import the JSON keystore file, found in ~/.lpData, into MetaMask, and use that to manage your account on Rinkeby network. Look for “Import Account” and “Select Type” as “JSON file”. Use the same password as above. Works on mainnet too :wink:

3 Likes

Awesome Tutorial. exactly what i needed. thank you!