A peer server that serves video files to Dokibada viewers over WebRTC. It connects to the Dokibada signaling server, announces available videos, and streams them to viewers via WebRTC DataChannels using fragmented MP4.
- WebRTC peer-to-peer video streaming via werift
- FFmpeg remuxing to fragmented MP4 for browser-compatible streaming
- Automatic fallback to raw file transfer when FFmpeg is unavailable
- TURN server support for NAT traversal
- Optional stream password protection
- HTTP server for direct video playback and download
- Auto-reconnecting signaling connection
.mp4, .mov, .avi, .mkv, .webm, .m4v, .flv, .wmv
If you are using VS Code, you can open this project in a Dev Container for a pre-configured environment with Node.js 20 and FFmpeg:
- Install the Dev Containers extension.
- Open the project folder in VS Code.
- Click "Reopen in Container" when prompted.
npm install
Register your firm and configure your API key:
npm start
This runs the interactive setup wizard, then starts the server.
For development with auto-reload:
npm run dev
Or start the server directly (skipping setup):
npm run server
Environment variables (set in .env or your shell):
| Variable | Default | Description |
|---|---|---|
API_KEY |
Firm API key (obtained during setup) | |
API_URL |
https://api.visionlee.com |
Dokibada API server URL |
SIGNALING_URL |
wss://api.visionlee.com/ws/signal |
WebSocket signaling server |
HTTP_PORT |
3001 |
Local HTTP server port |
HTTP_URL |
http://localhost:3001 |
Public URL for this peer |
VIDEOS_DIR |
./videos |
Directory containing video files |
STREAM_PASSWORD |
Password viewers must provide (empty = public) | |
FFMPEG_PATH |
ffmpeg |
Path to FFmpeg binary |
FFPROBE_PATH |
ffprobe |
Path to FFprobe binary |
- The server scans
VIDEOS_DIRfor supported video files and probes them with FFprobe. - It connects to the signaling server and announces available streams.
- When a viewer connects, a WebRTC peer connection is established via the signaling server.
- Video data is streamed over a DataChannel as fragmented MP4 segments (ftyp+moov init, then moof+mdat segments).
- If FFmpeg is unavailable, the raw file is sent in chunks as a fallback.
src/index.ts-- Main server (HTTP, WebRTC, signaling, streaming)src/setup.ts-- Interactive setup wizard (firm registration)videos/-- Place video files here.devcontainer/-- Dev container configuration
MIT