Skip to content
/ river Public

Pure Rust Implementation of RTMP Live Streaming Server

License

Notifications You must be signed in to change notification settings

nintha/river

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.