GithubHelp home page GithubHelp logo

swzhxx / river Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nintha/river

0.0 0.0 0.0 279 KB

Pure Rust Implementation of RTMP Live Streaming Server

License: Apache License 2.0

Rust 96.58% HTML 3.42%

river's Introduction

River

Pure Rust Implementation of RTMP Live Stream Server

Usage

USAGE:
    river.exe [OPTIONS]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
        --http-flv-port <http-flv-port>          disabled if port is 0 [default: 0]
        --http-player-port <http-player-port>    disabled if port is 0 [default: 0]
        --rtmp-port <rtmp-port>                  [default: 1935]
        --ws-fmp4-port <ws-fmp4-port>            disabled if port is 0 [default: 0]
        --ws-h264-port <ws-h264-port>            disabled if port is 0 [default: 0]

Push

OBS, x264, tune=zerolatency, CBR, preset=veryfast, profile=baseline

Play

ffplay

ffplay -fflags nobuffer -analyzeduration 100000 rtmp://localhost:11935/channel/token

-fflags nobuffer -analyzeduration 100000 could reduce the latency. On my computer, the latency is about 1 second.

JMuxer

Playing in the browser with Jmuxer.

If pushing stream with x264 codec, recommended profile is baseline

If you are using x264 encoding to push the stream, it is recommended that profile=baseline to avoid frequent video jitter. The current local test latency is about 1 second.

Example:

  1. Run River
cargo run -- --http-player-port=8080 --ws-h264-port=18000
  1. Push with OBS, x264, tune=zerolatency, CBR, preset=veryfast, profile=baseline

  2. Open your browser http://localhost:8080

Completed

  • support custom width and height
  • support audio
  • support HTTP-FLV output
  • support raw H264 stream output
  • deal with the problem of websocket message backlog
  • configurable startup parameters (monitoring server port)
  • optional output formats based on the startup parameters
  • web video player with JMuxer (ws-h264-port required)

TODO

  • PUSH/PULL authentication
  • support fragmented MP4 output

FAQ

The Chrome auto pauses muted video in inactive tabs.

  • Listen to the event visibilitychange, and change Video playback progress manually
var video = document.getElementById('video');
document.addEventListener("visibilitychange", function() {
  video.currentTime = video.buffered.end(0);
});
  • Timed changing Video playback progress manually
var video = document.getElementById('video');
setInterval(()=>{
  var latest = video.buffered.end(0);
  // over 200ms
  if (latest - video.currentTime > 0.2){
    video.currentTime = latest;
  }
}, 1000);

Reference

Thanks to Jetbrains for their great IDEs and the free open source license.

river's People

Contributors

nintha 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.