Giter Club home page Giter Club logo

xiu's Introduction

XIUcrates.io crates.io RTMPcrates.io crates.io HTTPFLVcrates.io crates.io HLScrates.io crates.io FLVcrates.io crates.io MPEGTScrates.io crates.io wechat qqgroup

δΈ­ζ–‡ζ–‡ζ‘£

Xiu is a simple and secure live media server written by pure Rust, it now supports popular live protocols like RTMP/HLS/HTTP-FLV (and maybe other protocols in the future), you can deploy it as a stand-alone server or a cluster using the relay feature.

Features

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

Preparation

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/config.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"

Configuration examples

I edit some configuration files under the following path which can be used directly:

xiu/application/xiu/src/config

It contains the following 4 files:

config_rtmp.toml //enable rtmp only
config_rtmp_hls.toml //enable rtmp and hls
config_rtmp_httpflv.toml //enable rtmp and httpflv
config_rtmp_httpflv_hls.toml //enable all the 3 protocols

Scenarios

Push

You can use two ways:

  • Use OBS to push a live rtmp stream

  • Or use FFmpeg to push a rtmp stream:

      ffmpeg -re -stream_loop -1 -i test.mp4 -c:a copy -c:v copy -f flv -flvflags no_duration_filesize rtmp://127.0.0.1:1935/live/test
    
Play

Use ffplay to play the 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 the above methods to push rtmp 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 the above methods 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

Open issues if you have any problems. Star and pull requests are welcomed. Your stars can make this project go faster and further.

xiu's People

Contributors

harlanc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.