rtmp-swarm
Publish, consume, and discover RTMP streams in a network swarm.
Install
$ npm install rtmp-swarm
Example
Start a RTMP network daemon belonging to a network swarm specified by a key.
const discovery = const port = processargv2 || 0const key = processargv3 || 'rtmp-swarm' const node = node node node node
Publish video on demand with ffmpeg
to the rtmp endpoint logged above:
$ ffmpeg -re -i 2k.mp4 \ -c:v libx264 \ -c:a aac \ -preset superfast \ -tune zerolatency \ -ar 44100 \ -f flv 'rtmp://localhost:40523/rtmp-stream'
Start another network swarm with the same key, but with a different
port and then access the stream with mpv
or ffplay
:
$ mpv 'rtmp://localhost:42583/rtmp-stream'
API
const swarm = discovery(opts)
where opts
is
id: // id for this peer net: // network interface maxConnections: 0 // max peering connections
which are passed directly to discovery-channel.
swarm.address()
Returns the server address of this network swarm.
swarm.listen(port, address, cb)
Bind a RTMP server to an optionally specified port and address. Will
call cb(err)
when listening.
swarm.join(key, cb)
Join a network swarm by key. Will call cb(err)
after joining.
swarm.destroy(cb)
swarm.close(cb)
Close and destroy the network swarm.
Command Line Usage
usage: rtmp-stream [-hV] [--help] [--version] [-k|--key|--key=<key>] options: -k, --key=<key> Discovery key
If you do not specify a key
, one will be generated for you.
License
MIT