• Stars
    star
    154
  • Rank 233,517 (Top 5 %)
  • Language
    Go
  • License
    Other
  • Created almost 3 years ago
  • Updated 2 months ago

Reviews

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

Repository Details

Command line interface to LiveKit
The LiveKit icon, the name of the repository and some sample code in the background.

LiveKit CLI

This package includes command line utilities that interacts with LiveKit. It allows you to:

  • Create access tokens
  • Access LiveKit APIs, create, delete rooms, etc
  • Join a room as a participant, inspecting in-room events
  • Start and manage Egress
  • Perform load testing, efficiently simulating real-world load

Installation

Mac

brew install livekit-cli

Linux

curl -sSL https://get.livekit.io/cli | bash

Windows

Download the latest release here

Build from source

This repo uses Git LFS for embedded video resources. Please ensure git-lfs is installed on your machine.

git clone github.com/livekit/livekit-cli
make install

Usage

See livekit-cli --help for a complete list of subcommands.

Set up your project [new]

When a default project is set up, you can omit url, api-key, and api-secret when using the CLI. You could also set up multiple projects, and switch the active project used with the --project flag.

Adding a project

livekit-cli project add

Listing projects

livekit-cli project list

Switching defaults

livekit-cli project set-default <project-name>

Publishing to a room

Publish demo video track

To publish a demo video as a participant's track, use the following.

livekit-cli join-room --room yourroom --identity publisher \
  --publish-demo

It'll publish the video track with simulcast, at 720p, 360p, and 180p.

Publish media files

You can publish your own audio/video files. These tracks files need to be encoded in supported codecs. Refer to encoding instructions

livekit-cli join-room --room yourroom --identity publisher \
  --publish path/to/video.ivf \
  --publish path/to/audio.ogg \
  --fps 23.98

This will publish the pre-encoded ivf and ogg files to the room, indicating video FPS of 23.98. Note that the FPS only affects the video; it's important to match video framerate with the source to prevent out of sync issues.

Publish from FFmpeg

It's possible to publish any source that FFmpeg supports (including live sources such as RTSP) by using it as a transcoder.

This is done by running FFmpeg in a separate process, encoding to a Unix socket. (not available on Windows). livekit-cli can then read transcoded data from the socket and publishing them to the room.

First run FFmpeg like this:

ffmpeg -i <video-file | rtsp://url> \
  -c:v libx264 -bsf:v h264_mp4toannexb -b:v 2M -profile:v baseline -pix_fmt yuv420p \
    -x264-params keyint=120 -max_delay 0 -bf 0 \
    -listen 1 -f h264 unix:/tmp/myvideo.sock \
  -c:a libopus -page_duration 20000 -vn \
  	-listen 1 -f opus unix:/tmp/myaudio.sock

This transcodes the input into H.264 baseline profile and Opus.

Then, run livekit-cli like this:

livekit-cli join-room --room yourroom --identity bot \
  --publish h264:///tmp/myvideo.sock \
  --publish opus:///tmp/myaudio.sock

You should now see both video and audio tracks published to the room.

Publish from TCP (i.e. gstreamer)

It's possible to publish from video streams coming over a TCP socket. livekit-cli can act as a TCP client. For example, with a gstreamer pipeline ending in ! tcpserversink port=16400 and streaming H.264.

Run livekit-cli like this:

livekit-cli join-room --room yourroom --identity bot \
  --publish h264:///127.0.0.1:16400

Publish streams from your application

Using unix sockets, it's also possible to publish streams from your application. The tracks need to be encoded into a format that WebRTC clients could playback (VP8, H.264, and Opus).

Once you are writing to the socket, you could use ffplay to test the stream.

ffplay -i unix:/tmp/myvideo.sock

Recording & egress

Recording requires egress service to be set up first.

Example request.json files are located here.

# start room composite (recording of room UI)
livekit-cli start-room-composite-egress --request request.json

# start track composite (audio + video)
livekit-cli start-track-composite-egress --request request.json

# start track egress (single audio or video track)
livekit-cli start-track-egress --request request.json

Testing egress templates

In order to speed up the development cycle of your recording templates, we provide a sub-command test-egress-template that helps you to validate your templates.

The command will spin up a few virtual publishers, and then simulate them joining your room It'll then open a browser to the template URL, with the correct parameters filled in.

Here's an example:

livekit-cli test-egress-template \
  --base-url http://localhost:3000 \
  --room <your-room> --layout <your-layout> --video-publishers 3

This command will launch a browser pointed at http://localhost:3000, while simulating 3 publishers publishing to your livekit instance.

Load Testing

Load testing utility for LiveKit. This tool is quite versatile and is able to simulate various types of load.

Note: livekit-load-tester has been renamed to sub-command livekit-cli load-test

Quickstart

This guide requires a LiveKit server instance to be set up. You can start a load tester with:

livekit-cli load-test \
  --room test-room --video-publishers 8

This simulates 8 video publishers to the room, with no subscribers. Video tracks are published with simulcast, at 720p, 360p, and 180p.

Simulating audio publishers

To test audio capabilities in your app, you can also simulate simultaneous speakers to the room.

livekit-cli load-test \
  --room test-room --audio-publishers 5

The above simulates 5 concurrent speakers, each playing back a pre-recorded audio sample at the same time. In a meeting, typically there's only one active speaker at a time, but this can be useful to test audio capabilities.

Watch the test

Generate a token so you can log into the room:

livekit-cli create-token --join \
  --room test-room --identity user  

Head over to the example web client and paste in the token, you can see the simulated tracks published by the load tester.

Load tester screenshot

Running on a cloud VM

Due to bandwidth limitations of your ISP, most of us wouldn't have sufficient bandwidth to be able to simulate 100s of users download/uploading from the internet.

We recommend running the load tester from a VM on a cloud instance, where there isn't a bandwidth constraint.

To make this simple, make will generate a linux amd64 binary in bin/. You can scp the binary to a server instance and run the test there.

Configuring system settings

Prior to running the load tests, it's important to ensure file descriptor limits have been set correctly. See Performance tuning docs.

On the machine that you are running the load tester, they would also need to be applied:

ulimit -n 65535
sysctl -w fs.file-max=2097152
sysctl -w net.core.somaxconn=65535
sysctl -w net.core.rmem_max=25165824
sysctl -w net.core.wmem_max=25165824

Simulate subscribers

You can run the load tester on multiple machines, each simulating any number of publishers or subscribers.

LiveKit SFU's performance is measured by the amount of data sent to its subscribers.

Use this command to simulate a load test of 5 publishers, and 500 subscribers:

livekit-cli load-test \
  --duration 1m \
  --video-publishers 5 \
  --subscribers 500

It'll print a report like the following. (this run was performed on a 16 core, 32GB memory VM)

Summary | Tester  | Tracks    | Bitrate                 | Latency     | Total Dropped
        | Sub 0   | 10/10     | 2.2mbps                 | 78.86829ms  | 0 (0%)
        | Sub 1   | 10/10     | 2.2mbps                 | 78.796542ms | 0 (0%)
        | Sub 10  | 10/10     | 2.2mbps                 | 79.361718ms | 0 (0%)
        | Sub 100 | 10/10     | 2.2mbps                 | 79.449831ms | 0 (0%)
        | Sub 101 | 10/10     | 2.2mbps                 | 80.001104ms | 0 (0%)
        | Sub 102 | 10/10     | 2.2mbps                 | 79.833373ms | 0 (0%)
...
        | Sub 97  | 10/10     | 2.2mbps                 | 79.374331ms | 0 (0%)
        | Sub 98  | 10/10     | 2.2mbps                 | 79.418816ms | 0 (0%)
        | Sub 99  | 10/10     | 2.2mbps                 | 79.768568ms | 0 (0%)
        | Total   | 5000/5000 | 678.7mbps (1.4mbps avg) | 79.923769ms | 0 (0%)

Advanced usage

You could customize various parameters of the test such as

  • --video-publishers: number of video publishers
  • --audio-publishers: number of audio publishers
  • --subscribers: number of subscribers
  • --video-resolution: publishing video resolution. low, medium, high
  • --no-simulcast: disables simulcast
  • --num-per-second: number of testers to start each second
  • --layout: layout to simulate (speaker, 3x3, 4x4, or 5x5)


LiveKit Ecosystem
Client SDKsComponents · JavaScript · Rust · iOS/macOS · Android · Flutter · Unity (web) · React Native (beta)
Server SDKsNode.js · Golang · Ruby · Java/Kotlin · PHP (community) · Python (community)
ServicesLivekit server · Egress · Ingress
ResourcesDocs · Example apps · Cloud · Self-hosting · CLI

More Repositories

1

livekit

End-to-end stack for WebRTC. SFU media server and SDKs.
Go
6,715
star
2

client-sdk-js

LiveKit browser client SDK (javascript)
TypeScript
273
star
3

client-sdk-flutter

Flutter Client SDK for LiveKit
Dart
197
star
4

livekit-react

React component and library for LiveKit
TypeScript
166
star
5

server-sdk-go

Client and server SDK for Golang
Go
164
star
6

client-sdk-swift

LiveKit Swift Client SDK. Easily build live audio or video experiences into your mobile app, game or website.
Swift
145
star
7

client-sdk-android

LiveKit SDK for Android
Kotlin
138
star
8

egress

Export and record WebRTC sessions and tracks
Go
137
star
9

rust-sdks

LiveKit real-time SDK and server API for Rust
Rust
119
star
10

agents

Build real-time multimodal AI applications 🤖🎙️📹
Python
111
star
11

components-js

Official open source React components and examples for building with LiveKit.
TypeScript
104
star
12

server-sdk-js

JS Server SDK to LiveKit
TypeScript
100
star
13

client-sdk-react-native

TypeScript
80
star
14

protocol

LiveKit protocol. Protobuf definitions for LiveKit's signaling protocol
Go
58
star
15

ingress

Ingest streams (RTMP/WHIP) or files (HLS, MP4) to LiveKit WebRTC
Go
48
star
16

sip

SIP to WebRTC bridge for LiveKit
Go
46
star
17

client-sdk-unity-web

Client SDK for Unity WebGL
C#
42
star
18

python-sdks

LiveKit real-time SDK and server API for Python
Python
38
star
19

livekit-helm

LiveKit Helm charts
Smarty
36
star
20

livekit-recorder

Go
31
star
21

livekit-server-sdk-python

LiveKit Server SDK for Python
Python
25
star
22

server-sdk-kotlin

Kotlin
24
star
23

track-processors-js

TypeScript
23
star
24

client-example-swift

Example app for LiveKit Swift SDK 👉 https://github.com/livekit/client-sdk-swift
Swift
21
star
25

server-sdk-ruby

LiveKit Server SDK for Ruby
Ruby
20
star
26

client-sdk-unity

C#
20
star
27

psrpc

Go
17
star
28

meet

Open source video conferencing app built on LiveKit Components, LiveKit Cloud, and Next.js.
TypeScript
16
star
29

client-unity-demo

Demo for LiveKit Unity SDK
C#
11
star
30

client-sdk-cpp

C++
11
star
31

WebRTC-swift

Swift package for WebRTC
Objective-C
10
star
32

agents-playground

TypeScript
9
star
33

deploy

Resources for deploying LiveKit
Go
8
star
34

livekit-docs

JavaScript
8
star
35

chrometester

A livekit tester to simulate a subscriber in a room, uses headless Chromium
JavaScript
8
star
36

nats-test

benchmarking app that emulates our usage patterns
Go
7
star
37

mediatransportutil

Media transport utilities
Go
5
star
38

webrtc-vmaf

VMAF benchmarking tool for WebRTC codecs
Python
4
star
39

client-example-collection-swift

A collection of small examples for the LiveKit Swift SDK 👉 https://github.com/livekit/client-sdk-swift
Swift
3
star
40

webrtc-chrome

Fork of Google's WebRTC repo, with LiveKit patches.
C++
3
star
41

rtcscore-go

Library to calculate Mean Opinion Score(MOS)
Go
2
star
42

ios-test-apps

Swift
1
star
43

gstreamer

C
1
star
44

mageutil

Go
1
star
45

components-android

Kotlin
1
star
46

gst-plugins

Go
1
star