Billion-scale P2P live streaming — H.264 ABR, FEC, tiered mesh, HLS export
Project description
p2p-stream v3
Billion-scale decentralised live streaming — H.264 multi-quality, FEC, adaptive bitrate, tiered mesh, HLS/RTMP export, hardware encoder support.
Architecture
Publisher (TIER_0: super-seed)
└─ Relay nodes ×N (TIER_1: 50 Mbps+, up to 100 children each)
└─ Peer nodes ×N (TIER_2: 5 Mbps+, up to 20 children each)
└─ Viewers ×∞ (TIER_3: any bandwidth)
Every node caches segments. Fan-out=20, depth=10 → 20^10 viewers max.
Install
sudo apt install libssl-dev liblz4-dev libminiupnpc-dev
pip install pybind11 cmake
pip install -e .
Quick start
Publisher
import asyncio, p2p_stream
async def main():
s = p2p_stream.StreamSession("myroom", qualities=(0,1,2), hls_dir="/tmp/hls")
await s.publish(bootstrap=[("seed.example.com", 8468)])
await asyncio.Event().wait()
asyncio.run(main())
Watcher
import asyncio, p2p_stream
async def main():
s = p2p_stream.StreamSession("myroom")
await s.watch(bootstrap=[("seed.example.com", 8468)])
await p2p_stream.display_track(s.node.upstream_track)
asyncio.run(main())
CLI
p2p-stream genkey
p2p-stream publish --room live --qualities 0,1,2 --hls /tmp/hls
p2p-stream watch --room live --bootstrap seed:8468
p2p-stream relay --room live --bootstrap seed:8468
p2p-stream stats --room live --bootstrap seed:8468
Quality levels
| ID | Name | Resolution | Bitrate |
|---|---|---|---|
| 0 | 360p | 640×360 | 500 kbps |
| 1 | 480p | 854×480 | 1 Mbps |
| 2 | 720p | 1280×720 | 2.5 Mbps |
| 3 | 1080p | 1920×1080 | 5 Mbps |
| 4 | 4K | 3840×2160 | 15 Mbps |
HLS / RTMP export
VLC, OBS, and all video editors can consume the HLS output directly:
vlc /tmp/hls/stream.m3u8
ffmpeg -i /tmp/hls/stream.m3u8 -c copy output.mp4
ffmpeg -re -i /tmp/hls/stream.m3u8 -c copy -f flv rtmp://live.twitch.tv/app/KEY
GStreamer
from p2p_stream.compat import GStreamerSink
print(GStreamerSink.pipeline_string(1280, 720, 30))
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
p2p_stream_v2_yoyo-3.0.0.tar.gz
(27.7 kB
view details)
File details
Details for the file p2p_stream_v2_yoyo-3.0.0.tar.gz.
File metadata
- Download URL: p2p_stream_v2_yoyo-3.0.0.tar.gz
- Upload date:
- Size: 27.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2dae9f53dd4153544a9826964be2d7a771a18020776754cbc2eeeef9be95e9e
|
|
| MD5 |
d1fe93443a29df7bdd82cdc3dcfe07eb
|
|
| BLAKE2b-256 |
84c15b7c69ce133a24b81cc84e5b94d8f8d6717d9c485bbce3abf2463028b0cf
|