- Docker and Docker Compose
- Git (for cloning the repository)
- Basic understanding of live streaming concepts
git clone https://github.com/shihan84/Live-Streaming-Encoder.git
cd Live-Streaming-Encoder# Start all core services
docker-compose up -d
# Or start with all tools (FFmpeg, SCTE-35 tools, etc.)
docker-compose --profile tools up -d- Main Dashboard: http://localhost:3000
- HLS Content: http://localhost:8080/hls/
- Health Check: http://localhost:8080/health
- streaming-encoder: Main Next.js application
- db: SQLite database
- nginx: HLS content delivery
- ffmpeg-scte35: FFmpeg with SCTE-35 patch
- scte35-tools: SCTE-35 utilities
- hls-segmenter: x9k3 HLS segmenter
- redis: Caching and sessions
Create a .env file in the root directory:
# Database
DATABASE_URL=file:./dev.db
# Application
NODE_ENV=production
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-secret-key-here
# SCTE-35 Settings
SCTE35_PROVIDER_ID=0x1
SCTE35_PROVIDER_NAME=YourProvider
SCTE35_AUTO_RETURN=true
# WebSocket
NEXT_PUBLIC_WS_URL=http://localhost:3000Configure system settings through the dashboard UI:
- Go to Settings tab
- Configure FFmpeg path and parameters
- Set HLS segmentation options
- Configure SCTE-35 provider settings
- Set output directories
- Go to Streams tab
- Fill in stream configuration:
- Name: "Live Event"
- Input URL:
rtmp://your-server/live/stream - Output URL:
http://localhost:8080/hls/stream.m3u8 - Bitrate: 2500 kbps
- Resolution: 1920x1080
- Enable SCTE-35: ✅
- Click Start Encoding
- Go to Ad Scheduler tab
- Fill in ad break details:
- Select Stream: Choose your stream
- Scheduled Time: Future date/time
- Duration: 30 seconds
- Ad ID: "commercial-001"
- Provider Name: "YourProvider"
- Click Schedule Ad Break
- Go to Monitoring tab
- View system status and metrics
- Check real-time logs
- Monitor encoding progress
# Build custom FFmpeg with SCTE-35
docker build -f Dockerfile.ffmpeg -t ffmpeg-scte35 .
# Build SCTE-35 tools
docker build -f Dockerfile.scte35 -t scte35-tools .
# Build HLS segmenter
docker build -f Dockerfile.x9k3 -t x9k3-segmenter .# Generate SCTE-35 sidecar file
docker-compose run --rm scte35-tools \
python /app/scripts/scte35-tools.py sidecar \
adbreaks.json --output sidecar.json
# Parse SCTE-35 from MPEG-TS
docker-compose run --rm scte35-tools \
python /app/scripts/scte35-tools.py parse_ts \
input.ts --output cues.json
# Inject SCTE-35 into HLS
docker-compose run --rm scte35-tools \
python /app/scripts/scte35-tools.py inject_hls \
playlist.m3u8 scte35_cues.json# Start HLS segmentation
docker-compose run --rm hls-segmenter \
python /app/scripts/x9k3-segmenter.py start \
--input rtmp://input.example.com/live/stream \
--output stream \
--bitrates 1000 2500 5000 \
--resolutions 1280x720 1920x1080 1920x1080 \
--scte35# Check application health
curl http://localhost:3000/api/health
# Check nginx health
curl http://localhost:8080/health
# View container status
docker-compose ps# View application logs
docker-compose logs -f streaming-encoder
# View database logs
docker-compose logs -f db
# View nginx logs
docker-compose logs -f nginx
# View all logs
docker-compose logs -f- Encoding Progress: Real-time progress in dashboard
- System Metrics: CPU, memory, disk usage
- Stream Status: Active streams and their status
- Ad Break Tracking: Scheduled and triggered ad breaks
- Change Default Secrets: Update NEXTAUTH_SECRET
- Use HTTPS: Configure SSL certificates
- Firewall: Restrict access to necessary ports
- Authentication: Enable NextAuth.js for user management
- Rate Limiting: Implement API rate limiting
# Expose only necessary ports
ports:
- "3000:3000" # Dashboard
- "8080:80" # HLS content
- "1935:1935" # RTMP input (optional)
# Use internal networking for services
networks:
streaming-network:
driver: bridge
internal: true# docker-compose.prod.yml
version: '3.8'
services:
streaming-encoder:
build: .
environment:
- NODE_ENV=production
- DATABASE_URL=file:/data/prod.db
volumes:
- ./data:/app/data
- ./hls:/var/www/hls
- ./logs:/app/logs
restart: unless-stopped
deploy:
resources:
limits:
cpus: '2.0'
memory: 4G# Scale the application
docker-compose up -d --scale streaming-encoder=3
# Load balancing with nginx
upstream streaming_backend {
server streaming-encoder:3000;
server streaming-encoder:3001;
server streaming-encoder:3002;
}# Backup database
docker-compose exec db sqlite3 /data/dev.db ".backup /backups/db_$(date +%Y%m%d).db"
# Backup configuration
tar -czf configs_$(date +%Y%m%d).tar.gz docker-compose.yml .env
# Backup HLS content (if needed)
tar -czf hls_$(date +%Y%m%d).tar.gz hls/# Check container logs
docker-compose logs streaming-encoder
# Check port conflicts
netstat -tulpn | grep :3000
# Restart services
docker-compose restart# Check database file
ls -la data/
# Recreate database
docker-compose down -v
docker-compose up -d# Check FFmpeg availability
docker-compose run --rm ffmpeg-scte35 ffmpeg -version
# Check input stream
ffplay rtmp://input.example.com/live/stream
# Check output directory
ls -la hls/# Check WebSocket connectivity
curl -I http://localhost:3000/api/socketio/
# Check Socket.IO logs
docker-compose logs streaming-encoder | grep socket# Monitor resource usage
docker stats
# Check encoding performance
docker-compose exec streaming-encoder ps aux
# Optimize FFmpeg settings
# Update system settings in dashboard# Get all streams
GET /api/streams
# Create stream
POST /api/streams
{
"name": "Stream Name",
"inputUrl": "rtmp://...",
"outputUrl": "http://...",
"bitrate": 2500,
"resolution": "1920x1080",
"scte35Enabled": true
}# Get all ad breaks
GET /api/adbreaks
# Create ad break
POST /api/adbreaks
{
"streamId": "stream-id",
"scheduledTime": "2025-01-01T12:00:00Z",
"duration": 30,
"adId": "ad-001"
}# Get encoding sessions
GET /api/encoding
# Start encoding
POST /api/encoding
{
"streamId": "stream-id"
}- Documentation: Read this guide and TEST_RESULTS.md
- Issues: Check GitHub issues
- Logs: Review application and system logs
- Community: Ask questions in discussions
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Happy Streaming! 🎬