#rtmp #hls #video #streaming #httpflv

bin+lib xiu

A powerful live server by Rust

9 releases

0.0.11 Jul 21, 2022
0.0.10 Jan 29, 2022
0.0.9 Dec 23, 2021
0.0.5 Sep 5, 2021
0.0.4 Aug 21, 2021

#71 in Video

Download history 13/week @ 2022-04-24 25/week @ 2022-05-01 69/week @ 2022-05-08 140/week @ 2022-05-15 39/week @ 2022-05-22 69/week @ 2022-05-29 57/week @ 2022-06-05 1/week @ 2022-06-12 4/week @ 2022-06-19 11/week @ 2022-06-26 19/week @ 2022-07-03 8/week @ 2022-07-10 30/week @ 2022-07-17 33/week @ 2022-07-24 25/week @ 2022-07-31 5/week @ 2022-08-07

93 downloads per month

MIT license

290KB
7K SLoC

Xiu

crates.io

Xiu is a live server written by Rust.

Functionalities

  • RTMP
    • publish and play
    • relay: static push
    • relay: static pull
  • HTTPFLV
  • HLS

Dev Environment Establish

Install Rust and Cargo

Document

Install and run

There are two ways to install xiu :

  • Using cargo to install
  • Building from source

Install using cargo

Issue the following command to install xiu:

cargo install xiu

Start the service with the following command:

xiu configuration_file_path/confit.toml

Build from souce

Clone Xiu

git clone https://github.com/harlanc/xiu.git

use master branch

Build

cd ./xiu/application/xiu
cargo build --release

Run

cd ./xiu/target/release
./xiu config.toml

Configurations

RTMP
[rtmp]
enabled = true
port = 1935

# pull streams from other server node.
[rtmp.pull]
enabled = false
address = "192.168.0.1"
port = 1935

# push streams to other server node.
[[rtmp.push]]
enabled = true
address = "localhost"
port = 1936
[[rtmp.push]]
enabled = true
address = "192.168.0.3"
port = 1935
HTTPFLV
[httpflv]
# true or false to enable or disable the feature
enabled = true
# listening port
port = 8081
HLS
[hls]
# true or false to enable or disable the feature
enabled = true
# listening port
port = 8080
Log
[log]
level = "info"

Scenarios

Push

Use OBS to push a live rtmp stream.

Play

Use ffplay to play rtmp/httpflv/hls live stream:

ffplay -i rtmp://localhost:1935/live/test
ffplay -i http://localhost:8081/live/test.flv
ffplay -i http://localhost:8080/live/test/test.m3u8
Relay static push

The configuration files are as follows:

The configuration file of Service 1 named config.toml:

[rtmp]
enabled = true
port = 1935
[[rtmp.push]]
enabled = true
address = "localhost"
port = 1936

The configuration file of Service 2 named config_push.toml:

[rtmp]
enabled = true
port = 1936

Run the 2 services:

./xiu config.toml
./xiu config_push.toml

Use Obs to push live stream to service 1, then the stream can be pushed to service 2 automatically, you can play the same live stream from both the two services:

ffplay -i rtmp://localhost:1935/live/test
ffplay -i rtmp://localhost:1936/live/test
Relay static pull

The configuration file are as follows:

The configuration file of Service 1 named config.toml:

[rtmp]
enabled = true
port = 1935

The configuration file of Service 2 named config_pull.toml:

[rtmp]
enabled = true
port = 1936
[rtmp.pull]
enabled = false
address = "localhost"
port = 1935

Run the 2 services:

./xiu config.toml
./xiu config_pull.toml

Use obs to push live stream to service 1, when you play the stream from serivce 2, it will pull the stream from service 1:

ffplay -i rtmp://localhost:1935/live/test
ffplay -i rtmp://localhost:1936/live/test

Star History

link

Thanks

Others

You can open issues if have any problems. Star and pull requests are welcomed.

Dependencies

~10–17MB
~312K SLoC