A professional-grade, reliable, and scalable real-time video monitoring system for multiple classrooms, built on LiveKit WebRTC infrastructure. This system enables educational institutions to efficiently monitor and record classroom activities with minimal latency and high reliability.
graph TD
subgraph "Server Infrastructure (Docker Compose)"
direction LR
B[LiveKit SFU Media Server]
D[Flask Token/Recording Server]
E[Nginx Web Viewer]
end
subgraph "Classroom PC"
A[Python Streamer Script]
A_CAM[IP Camera]
A_MIC[Microphone]
end
subgraph "Principal's PC"
C[Web Browser]
end
A_CAM -- RTSP Video --> A
A_MIC -- PulseAudio --> A
A -- Publishes Stream --> B
C -- Loads Web Page --> E
C -- Requests Token --> D
D -- Returns Token --> C
C -- Subscribes to Stream --> B
B -- Forwards Media (SRTP) --> C
C -- Sends Recording Command --> D
D -- Controls Recording --> B
- π₯ Real-time Video/Audio Streaming: Low-latency streaming from up to 26 classrooms simultaneously
- π Centralized Viewer Dashboard: Dynamic grid view for the Principal with on-demand stream loading
- β‘ Live Status Monitoring: Real-time status indicators showing classroom connectivity
- πΉ Dual Recording Options:
- Browser-based local recording
- Server-side permanent recording
- π Easy Deployment: Docker-based deployment with automated setup scripts
- π§ Production-Ready: Built on LiveKit's professional WebRTC SFU
-
Central Server
- LiveKit Media Server (SFU)
- Flask-based Token/Recording Server
- Redis for state management
- Nginx serving the web viewer
-
Classroom Streamer
- Python-based streaming client
- RTSP camera integration
- PulseAudio capture
- Automatic reconnection handling
-
Principal's Viewer
- Web-based dashboard
- Dynamic grid layout
- Real-time status monitoring
- Recording controls
graph LR
A[Classroom PC] -->|Publish Stream| B[LiveKit SFU]
B -->|Subscribe| C[Principal's Browser]
C -->|Recording Request| D[Flask Server]
D -->|Control| B
- Background connections to all rooms
- Real-time participant status tracking
- Green "LIVE" / Red "OFFLINE" indicators
- Zero video loading until needed
- Click-to-view functionality
- Efficient resource usage
- Multiple simultaneous views supported
- Automatic cleanup on tab close
- Browser-based MediaRecorder implementation
- Direct download to Principal's computer
- WebM format with VP8 video and Opus audio
- No server storage required
- LiveKit Egress API integration
- MP4 format for compatibility
- Permanent storage on server
- Organized by classroom and timestamp
- Ubuntu 20.04 or newer
- Docker 20.10 or newer
- Docker Compose v2.0 or newer
- 4GB RAM minimum
- 50GB storage (for recordings)
- Ubuntu 20.04 Desktop or newer
- Docker 20.10 or newer
- Connected USB/Built-in microphone
- Network-accessible IP camera
- 2GB RAM minimum
```bash git clone https://github.com/ecell-kccemsr/classroom-streamer.git cd classroom-streaming ```
-
Configure environment variables:
cd server cp .env.example .env -
Edit the
.envfile:LIVEKIT_API_KEY=your_api_key_here LIVEKIT_API_SECRET=your_secret_here REDIS_PASSWORD=your_redis_password_here
-
Launch the server:
docker-compose up -d --build
-
Verify the services:
docker-compose ps
-
Configure environment variables:
cd streamer cp .env.example .env -
Edit the
.envfile:LIVEKIT_URL=ws://your_server_ip:7880 LIVEKIT_API_KEY=your_api_key_here LIVEKIT_API_SECRET=your_secret_here ROOM_NAME=classroom101 RTSP_URL=rtsp://camera_ip:554/stream MIC_DEVICE=default
-
Optional: Configure audio loopback for in-room monitoring:
./setup_loopback.sh
-
Build and run the streamer:
docker build -t classroom-streamer . docker run -d \ --name classroom-streamer \ --restart unless-stopped \ --device /dev/snd \ -v /etc/localtime:/etc/localtime:ro \ --env-file .env \ classroom-streamer
-
Open a web browser and navigate to:
http://your_server_ip -
You should see the grid of classrooms with their live status indicators.
For developers who want to modify or extend the platform:
-
Install development dependencies:
# Token Server cd token_server python -m venv venv source venv/bin/activate pip install -r requirements.txt # Viewer cd ../viewer npm install
-
Start development servers:
# Token Server cd token_server python app.py # Viewer cd viewer npm run dev
port: 7880
rtc:
port: 7881
use_external_ip: true
room:
enabled: true
max_participants: 50LIVEKIT_API_KEY: API key for LiveKit authenticationLIVEKIT_API_SECRET: API secret for LiveKit authenticationRECORDINGS_DIR: Directory for server-side recordings
ROOM_NAME: Unique classroom identifierRTSP_URL: IP camera stream URLMIC_DEVICE: PulseAudio device name
-
Streamer Won't Connect
- Check network connectivity
- Verify API key/secret
- Ensure camera URL is accessible
-
No Audio in Stream
- Check microphone permissions
- Verify PulseAudio configuration
- Run
setup_loopback.shagain
-
Recording Issues
- Check disk space
- Verify write permissions
- Check LiveKit logs
Planned features for the next major release:
- πΊ Live Rewind: DVR capability for instant replay
- πΎ Network Storage: NAS integration for recordings
- π Analytics Dashboard: Classroom usage statistics
- π Alert System: Automated notifications
- ποΈ Admin Panel: Advanced configuration UI
We welcome contributions! Please see our Contributing Guide for details.
This project is licensed under the MIT License - see the LICENSE file for details.