Skip to content

visionlee-sdk/dokibada-peer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dokibada Peer

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.

Features

  • 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

Supported Video Formats

.mp4, .mov, .avi, .mkv, .webm, .m4v, .flv, .wmv

Getting Started

1. Open in Dev Container (optional)

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:

  1. Install the Dev Containers extension.
  2. Open the project folder in VS Code.
  3. Click "Reopen in Container" when prompted.

2. Install Dependencies

npm install

3. Run Setup

Register your firm and configure your API key:

npm start

This runs the interactive setup wizard, then starts the server.

4. Run the Server

For development with auto-reload:

npm run dev

Or start the server directly (skipping setup):

npm run server

Configuration

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

How It Works

  1. The server scans VIDEOS_DIR for supported video files and probes them with FFprobe.
  2. It connects to the signaling server and announces available streams.
  3. When a viewer connects, a WebRTC peer connection is established via the signaling server.
  4. Video data is streamed over a DataChannel as fragmented MP4 segments (ftyp+moov init, then moof+mdat segments).
  5. If FFmpeg is unavailable, the raw file is sent in chunks as a fallback.

Project Structure

  • 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

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors