• Stars
    star
    286
  • Rank 144,690 (Top 3 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 8 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Livepeer media server

Build status

LPMS - Livepeer Media Server

LPMS is a media server that can run independently, or on top of the Livepeer network. It allows you to manipulate / broadcast a live video stream. Currently, LPMS supports RTMP as input format and RTMP/HLS as output formats.

LPMS can be integrated into another service, or run as a standalone service. To try LPMS as a standalone service, simply get the package:

go get -d github.com/livepeer/lpms/cmd/example

Go to the lpms root directory at $GOPATH/src/github.com/livepeer/lpms. If needed, install the required dependencies; see the Requirements section below. Then build the sample app and run it:

go build cmd/example/main.go
./example

Requirements

LPMS requires libavcodec (ffmpeg) and friends. See install_ffmpeg.sh . Running this script will install everything in ~/compiled. In order to build LPMS, the dependent libraries need to be discoverable by pkg-config and golang. If you installed everything with install_ffmpeg.sh , then run export PKG_CONFIG_PATH=~/compiled/lib/pkgconfig:$PKG_CONFIG_PATH so the deps are picked up.

Running golang unit tests (test.sh) requires the ffmpeg and ffprobe executables in addition to the libraries. However, none of these are run-time requirements; the executables are not used outside of testing, and the libraries are statically linked by default. Note that dynamic linking may substantially speed up rebuilds if doing heavy development.

Testing out LPMS

The test LPMS server exposes a few different endpoints:

  1. rtmp://localhost:1935/stream/test for uploading/viewing RTMP video stream.
  2. http://localhost:7935/stream/test_hls.m3u8 for consuming the HLS video stream.

Do the following steps to view a live stream video:

  1. Start LPMS by running go run cmd/example/main.go

  2. Upload an RTMP video stream to rtmp://localhost:1935/stream/test. We recommend using ffmpeg or OBS.

For ffmpeg on osx, run: ffmpeg -f avfoundation -framerate 30 -pixel_format uyvy422 -i "0:0" -c:v libx264 -tune zerolatency -b:v 900k -x264-params keyint=60:min-keyint=60 -c:a aac -ac 2 -ar 44100 -f flv rtmp://localhost:1935/stream/test

For OBS, fill in Settings->Stream->URL to be rtmp://localhost:1935

  1. If you have successfully uploaded the stream, you should see something like this in the LPMS output
I0324 09:44:14.639405   80673 listener.go:28] RTMP server got upstream
I0324 09:44:14.639429   80673 listener.go:42] Got RTMP Stream: test
  1. Now you have a RTMP video stream running, we can view it from the server. Simply run ffplay http://localhost:7935/stream/test.m3u8, you should see the hls video playback.

Integrating LPMS

LPMS exposes a few different methods for customization. As an example, take a look at cmd/main.go.

To create a new LPMS server:

// Specify ports you want the server to run on, and the working directory for
// temporary files. See `core/lpms.go` for a full list of LPMSOpts
opts := lpms.LPMSOpts {
    RtmpAddr: "127.0.0.1:1935",
    HttpAddr: "127.0.0.1:7935",
    WorkDir:  "/tmp"
}
lpms := lpms.New(&opts)

To handle RTMP publish:

lpms.HandleRTMPPublish(
	//getStreamID
	func(url *url.URL) (strmID string) {
		return getStreamIDFromPath(reqPath)
	},
	//getStream
	func(url *url.URL, rtmpStrm stream.RTMPVideoStream) (err error) {
		return nil
	},
	//finishStream
	func(url *url.URL, rtmpStrm stream.RTMPVideoStream) (err error) {
		return nil
	})

To handle RTMP playback:

lpms.HandleRTMPPlay(
	//getStream
	func(ctx context.Context, reqPath string, dst av.MuxCloser) error {
		glog.Infof("Got req: ", reqPath)
		streamID := getStreamIDFromPath(reqPath)
		src := streamDB.db[streamID]
		if src != nil {
			src.ReadRTMPFromStream(ctx, dst)
		} else {
			glog.Error("Cannot find stream for ", streamID)
			return stream.ErrNotFound
		}
		return nil
	})

To handle HLS playback:

lpms.HandleHLSPlay(
	//getHLSBuffer
	func(reqPath string) (*stream.HLSBuffer, error) {
		streamID := getHLSStreamIDFromPath(reqPath)
		buffer := bufferDB.db[streamID]
		s := streamDB.db[streamID]

		if s == nil {
			return nil, stream.ErrNotFound
		}

		if buffer == nil {
			//Create the buffer and start copying the stream into the buffer
			buffer = stream.NewHLSBuffer()
			bufferDB.db[streamID] = buffer

            //Subscribe to the stream
			sub := stream.NewStreamSubscriber(s)
			go sub.StartHLSWorker(context.Background())
			err := sub.SubscribeHLS(streamID, buffer)
			if err != nil {
				return nil, stream.ErrStreamSubscriber
			}
		}

		return buffer, nil
	})

GPU Support

Processing on Nvidia GPUs is supported. To enable this capability, FFmpeg needs to be built with GPU support. See the FFmpeg guidelines on this.

To execute the nvidia tests within the ffmpeg directory, run this command:

go test --tags=nvidia -run Nvidia

To run the tests on a particular GPU, use the GPU_DEVICE environment variable:

# Runs on GPU number 3
GPU_DEVICE=3 go test --tags=nvidia -run Nvidia

Aside from the tests themselves, there is a sample program that can be used as a reference to the LPMS GPU transcoding API. The sample program can select GPU or software processing via CLI flags. Run the sample program via:

# software processing
go run cmd/transcoding/transcoding.go transcoder/test.ts P144p30fps16x9,P240p30fps16x9 sw

# nvidia processing, GPU number 2
go run cmd/transcoding/transcoding.go transcoder/test.ts P144p30fps16x9,P240p30fps16x9 nv 2

Testing GPU transcoding with failed segments from Livepeer production environment

To test transcoding of segments failed on production in Nvidia environment:

  1. Install Livepeer from sources by following the installation guide
  2. Install Google Cloud SDK
  3. Make sure you have access to the bucket with the segments
  4. Download the segments:
    gsutil cp -r gs://livepeer-production-failed-transcodes /home/livepeer-production-failed-transcodes
  5. Run the test
    cd transcoder
    FAILCASE_PATH="/home/livepeer-production-failed-transcodes" go test --tags=nvidia -timeout 6h -run TestNvidia_CheckFailCase
  6. After the test has finished, it will display transcoding stats. Per-file results are logged to results.csv in the same directory

Contribute

Thank you for your interest in contributing to LPMS!

To get started:

More Repositories

1

go-livepeer

Official Go implementation of the Livepeer protocol
Go
546
star
2

wiki

Wiki for the Livepeer Project
204
star
3

livepeer-monorepo

JavaScript tools and applications that interact with Livepeer's smart contracts and peer-to-peer network
JavaScript
167
star
4

protocol

Livepeer protocol
JavaScript
153
star
5

file-video

TypeScript
79
star
6

studio

Livepeer Studio is your home for building, broadcasting, and publishing video on the open internet with the Livepeer Network. Effortlessly manage livestreams, video uploads, API keys, network usage, billing, and more.
TypeScript
77
star
7

ui-kit

Livepeer UI Kit: Video primitives for React
TypeScript
64
star
8

grants

⚠️ DEPRECATED ⚠️ Please visit the new homepage at https://livepeer.notion.site/Livepeer-Grants-Program-f91071b5030d4c31ad4dd08e7c026526
44
star
9

livepeer-swarm

POC implementation of Livepeer network node, built on Swarm and Devp2p
Go
39
star
10

docs

Livepeer documentation
MDX
37
star
11

awesome-livepeer

A community curated list of projects, tutorials, demos, and resources within the Livepeer ecosystem
HTML
37
star
12

merkle-mine

Token distribution based on providing Merkle proofs of inclusion in genesis state to generate allocation
JavaScript
29
star
13

stream-tester

Stream tester is a tool to measure performance and stability of Livepeer transcoding network
Go
23
star
14

catalyst

Livepeer's Decentralized Media Server
Go
22
star
15

livepeer-lens-shortvideos

A demo TikTok clone built on top of Livepeer and Lens Protocol
JavaScript
19
star
16

org

Livepeer.org is the primary online resource for participants and users of the Livepeer network.
TypeScript
18
star
17

go-livepeer-basicnet

Basic p2p video streaming for Livepeer
Go
18
star
18

ai-worker

Python
16
star
19

LivepeerDesktop

Desktop Application For Livepeer (Out of date)
JavaScript
16
star
20

verification-truebit

WIP PoC verification system for the Livepeer protocol using Truebit
JavaScript
16
star
21

video-nft

SDK and CLI for minting video NFTs
TypeScript
14
star
22

arbitrum-lpt-bridge

A bridge to move LPT between Ethereum and Arbitrum
TypeScript
13
star
23

webrtmp-sdk

SDK for streaming media via RTMP from the web.
TypeScript
12
star
24

go-PPSPP

Go implementation of the Peer-to-Peer Streaming Peer Protocol (rfc7574)
Go
11
star
25

minecraft

LPT mining dapp
JavaScript
11
star
26

livepeer-demo-react-native

TypeScript
9
star
27

LIPs

Livepeer Improvement Proposals
9
star
28

transcode-cli

CLI transcoding tool
Go
9
star
29

explorer

TypeScript
9
star
30

verification-classifier

Metrics-based Verification Classifier
Jupyter Notebook
8
star
31

project-management

Livepeer open source ideas, dapps, and improvement proposals.
8
star
32

studio-sample-app

JavaScript
8
star
33

streamingviz

Network visualization server and client that allows livepeer to track popular events and visualize the network
Go
8
star
34

research

Organization of the current open research tracks within the Livepeer Project
7
star
35

livepeer-nft-gate-example

TypeScript
6
star
36

design-system

Design system for Livepeer Inc Products
TypeScript
6
star
37

Broadcaster-Chat-App

an end to end tutorial on how to build a dapp on top of livepeer
JavaScript
5
star
38

interactive-video

For storing research results
JavaScript
5
star
39

subgraph

This repository contains the code for the Livepeer Protocol subgraph
TypeScript
5
star
40

livepeer-wowza

Livepeer + Wowza Integration Plugin
Java
5
star
41

livepeer-js

JavaScript library for the Livepeer API.
TypeScript
5
star
42

catalyst-api

Go
4
star
43

loki-client

GO client library for Grafana's Loki
Go
4
star
44

Aptos-NFT-Dapp

Sample app for creating video NFTs with Livepeer SDK on the Aptos blockchain
TypeScript
4
star
45

go-ethereum-p2p-test

testing ground for creating a p2p network on top of devp2p
Go
4
star
46

sorted-doubly-ll

ZeppelinOS EVM Package for a Sorted Doubly Linked List
JavaScript
4
star
47

player

Embeddable HLS player, optimized for Livepeer streams and assets.
TypeScript
4
star
48

test-harness

JavaScript
3
star
49

task-runner

Background service that executes tasks from the Livepeer API. Mainly used for VOD.
Go
3
star
50

ethdenver

EthDenver Hackathon on 2/16-2/18 in Denver, Colorado
JavaScript
3
star
51

livepeer-monitoring

JavaScript
3
star
52

merkle-earnings-cli

CLI tool to generate, verify and claim snapshot earnings
TypeScript
3
star
53

livepeer-studio-docs

Livepeer Studio Documentation
JavaScript
3
star
54

video-nft-sample

JavaScript
3
star
55

bounties

Livepeer Software Bounties Portal.
3
star
56

chat

TypeScript
2
star
57

create-livepeer-app

JavaScript
2
star
58

livepeer-go

Go library for the Livepeer API.
Go
2
star
59

livepeer-tv

Open source decentralised event app built with Next.js, and Livepeer Studio
TypeScript
2
star
60

polygon-video-nft

2
star
61

livepeer-truebit-bigchaindb

Prototyping collaboration between Livepeer, Truebit, and Bigchaindb
2
star
62

livepeer-gateway

Web Gateway To Livepeer's Video Stream Network
JavaScript
2
star
63

TranscodingVerification

Metrics-Based Transcoding Verification
C
2
star
64

community-governance

Community governance project management
2
star
65

testnet-services

Extra deployable services for running an internal test network
Go
2
star
66

docker-livepeer

Base Livepeer Docker image
Shell
2
star
67

tokenholders.livepeer.org

Livepeer tokenholder web site.
TypeScript
2
star
68

livepeer-ai-sdks

DEPRECATED - Auto-generated SDKs for interacting with the Livepeer AI Subnet.
Python
2
star
69

ai-video-frontend-playground

TypeScript
2
star
70

go-livepeer-bitexact-verifier

Verification code based on bitexact comparison of video transcoding
Go
2
star
71

storj-livepeer-nodejs-example

Example nodejs code for uploading videos to Storj and transcoding with Livepeer
JavaScript
1
star
72

go-api-client

Implementation of a client for the Livepeer API written in Go
Go
1
star
73

action-gh-checksum-and-gpg-sign

Generate gpg signatures and checksums for release artifacts
Shell
1
star
74

livepeer-data

Data service from Livepeer platform.
Go
1
star
75

discord-message-bot

Simple discord bot to capture discord engagement through messages.
JavaScript
1
star
76

ethberlin

Livepeer collaboration with ETHBerlin Hackathon
1
star
77

web3storage-livepeer-nodejs-example

JavaScript
1
star
78

livepeer-charts

Livepeer Helm chart for Kubernetes
Smarty
1
star
79

production-success

Assisting developers building with Livepeer Studio
1
star
80

verification-computation-archive

Docker application for transcoding verification
JavaScript
1
star
81

ffmpeg-plus-bunny

FFMpeg plus a copy of Big Buck Bunny in a Docker container
Dockerfile
1
star
82

streamer

Ruby
1
star
83

livepeer-ml

Python
1
star
84

action-gh-codesign-apple

GitHub action to generate codesigned binaries
Shell
1
star
85

livepeer-metrics

Simple Metrics Daemon
JavaScript
1
star
86

livepeer-python

Python library for the Livepeer API.
Python
1
star
87

go-livepeer-ppspp

The VideoNetwork implementation using go-PPSPP
Go
1
star
88

devenv

Setting up a local test environment
Shell
1
star
89

product-discovery-playground

TypeScript
1
star
90

catalyst-uploader

Livepeer cloud storage upload utility. Called by Mist to upload video segments. Has CLI interface.
Go
1
star
91

action-gh-release-tags

Github Action to automatically grab tags about the current build for tagging assets (e.g. Docker images)
Shell
1
star
92

pagerduty-to-discord

Cloudflare worker that eats PagerDuty webhooks and spits Discord webhooks
JavaScript
1
star
93

leaderboard-serverless

Serverless API for the Livepeer Orchestrator Leaderboard using Vercel for deploying these endpoints
Go
1
star
94

poll-stats

Simple protocol app to display detailed information about votes on Governance polls
TypeScript
1
star
95

orchestrator-price-api

A tool for enhancing the price visibility in Livepeer ecosystem.
Go
1
star