An open source P2P livestreaming module for synchronized playback in HTML5.
p2ptv distributes live WebM by sending the WebM Byte Stream Format directly to the browser where the experimental MSE API is used for playback. Livestreams are transcoded from RTMP or from a file before being processed by this module.
The plan is to significantly reduce the cost of livestreaming by forming a P2P distribution network using WebRTC. Currently has only client-server implementation. If you're interested in starting a webservice, it is probably in your best interest to use conventional streaming methods.
Please note that this is alpha software. Meaning it is experimental, unstable, incomplete, and likely to change drastically between versions. Feel free to contribute if you are interested in the project.
- Chrome 34+
- Opera 15+
- Firefox 43+
npm install p2ptv
$ git clone git://github.com/eadle/p2ptv.git $ cd p2ptv $ npm install
- You may need to install FFmpeg from source with --enable-libvorbis and --enable-libvpx flags.
- You may need to setup an RTMP server.
- OBS has been extremely useful.
$ node example/example.js
With verbose logging:
$ DEBUG=p2ptv,gateway,peer,push-pull-window node example/example.js
There's no FFmpeg flag to force placement of a keyframe at the beginning of each cluster. Until this project switches to DASH, just set -cluster_size_limit and -cluster_time_limit to 999999999 or some value that's greater than your expected media segments. It's ugly, but it works.
From RTMP (with upstream port set to 9001):
ffmpeg -re -i rtmp://localhost:1935/480p/test -c:a libvorbis -c:v libvpx \ -g 150 -crf 23 -lag-in-frames 15 -profile:v 2 -qmax 50 -qmin 1 \ -cpu-used 0 -slices 4 -b:v 2M -cluster_size_limit 999999999 \ -cluster_time_limit 999999999 -deadline realtime \ -f webm tcp://localhost:9001;
From a file:
ffmpeg -i media/test.mp4 -c:a libvorbis -c:v libvpx -g 150 -crf 23 \ -lag-in-frames 15 -profile:v 2 -qmax 50 -qmin 1 -cpu-used 0 -b:v 1M \ -cluster_size_limit 999999999 -cluster_time_limit 999999999 \ -deadline realtime -f webm tcp://127.0.0.1:9001
You may have better results transcoding from RTMP. It really depends on how much processing power you're willing to give your transcoding box.
Not really actively working on this anymore. Feel free to create an issue or pull request though.