A real-time camera streaming web application with live admin monitoring, photo capture, and multi-camera support. Built with WebRTC for low-latency peer-to-peer video streaming.
- Real-time WebRTC streaming from client to admin panel
- Multi-camera support with seamless switching (front/back cameras)
- Low-latency peer-to-peer video transmission
- Auto-reconnection and connection state monitoring
- One-click photo capture from live camera feed
- Automatic server storage with timestamps
- Real-time photo gallery in admin panel
- Instant notifications for new photos
- Live camera streams from multiple clients simultaneously
- Real-time statistics (total photos, file sizes, last activity)
- Connection monitoring with status indicators (CONNECTING/LIVE)
- Camera switch notifications and client management
- HTTPS/WebRTC ready (works with ngrok tunneling)
- WebSocket signaling for real-time communication
- Responsive design for desktop and mobile
- Cross-browser compatibility (Chrome, Firefox, Safari)
- Node.js (v14 or higher)
- Modern browser with camera support
- HTTPS connection (use ngrok for development)
- Clone and install dependencies:
git clone <repository>
cd camera-recording-app
bun install
- Start the server:
bun dev
- Set up HTTPS tunnel (required for camera access):
# Install ngrok if you haven't already
brew install ngrok # macOS
# or download from https://ngrok.com/download
# Create HTTPS tunnel
ngrok http 3000
- Access the application:
- Client (Camera):
https://your-ngrok-url.ngrok.io
- Admin Panel:
https://your-ngrok-url.ngrok.io/admin
- Client (Camera):
- Start Camera: Click "Start Recording" and allow camera permissions
- Switch Cameras: Use dropdown to select different cameras (front/back)
- Take Photos: Click "Take Photo" to capture and save images
- Live Streaming: Your camera feed automatically streams to admin panel
- Monitor Live Streams: View real-time camera feeds from all connected clients
- Track Statistics: See total photos, file sizes, and activity timestamps
- Manage Connections: Monitor connection status and retry failed connections
- View Photo Gallery: Browse all captured photos with timestamps and metadata
βββ server.js # Express + Socket.IO server with WebRTC signaling
βββ package.json # Dependencies and npm scripts
βββ public/
β βββ index.html # Client camera interface with WebRTC
β βββ admin.html # Admin dashboard with live monitoring
βββ uploads/ # Photo storage directory (auto-created)
GET /
- Client camera interfaceGET /admin
- Admin monitoring dashboardPOST /upload-photo
- Upload captured photos (multipart/form-data)GET /api/photos
- Retrieve all photos metadata (JSON)GET /uploads/:filename
- Serve stored photo files
client-ready
- Camera is ready for streamingclient-stopped
- Camera has been stoppedcamera-switched
- User switched to different cameraoffer/answer/ice-candidate
- WebRTC signaling
camera-available
- New camera client connectedcamera-disconnected
- Camera client disconnectedcamera-switched
- Client switched camerasnew-photo
- New photo was captured
bun run dev # Auto-restart on file changes
NODE_ENV=production # Enables HTTPS redirect for production
PORT=3000 # Server port (default: 3000)
The app uses Google's STUN servers for NAT traversal:
stun:stun.l.google.com:19302
stun:stun1.l.google.com:19302
For production, consider adding TURN servers for better connectivity.
- Chrome 56+ (recommended)
- Firefox 52+
- Safari 11+
- Edge 79+
- Camera access
- Microphone access (optional)
- JavaScript enabled
Modern browsers require HTTPS for camera access. Use ngrok for development or deploy with SSL certificates.
"Camera access denied"
- Ensure you're using HTTPS (not HTTP)
- Check browser permissions for camera access
- Try refreshing and allowing permissions again
"No stream in admin panel"
- Verify both client and admin use the same HTTPS URL
- Check browser console for WebRTC connection errors
- Try the "Retry" button in admin panel
"Connection timeout"
- Check network connectivity
- Verify WebSocket connection is established
- Ensure no firewall blocking WebRTC traffic
Open browser console (F12) to see detailed WebRTC connection logs and troubleshooting information.
- Set
NODE_ENV=production
- Use proper SSL certificates (Let's Encrypt recommended)
- Configure reverse proxy (nginx/Apache) if needed
- Consider adding TURN servers for better WebRTC connectivity
FROM node:16-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3000
CMD ["bun", "start"]
MIT License - feel free to use this project for your own applications!
Contributions welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.