๐ฌ AV1 Distributed Transcoding System
High-performance distributed media transcoding system that converts your entire library to AV1 (SVT-AV1) with Opus audio. Features modern web interface, smart quality optimization, and distributed processing across multiple machines.
โจ Features
Core Capabilities
- โ AV1 Encoding - SVT-AV1 with configurable presets (0-13)
- โ Opus Audio - High-quality audio with excellent compression
- โ Smart Quality - Automatic CRF/bitrate based on source resolution and codec
- โ Modern Web UI - Real-time monitoring with detailed progress tracking
- โ Safe Processing - Testing mode, backups, atomic file operations
- โ Efficient - Only replaces files with 5%+ space savings
- โ HDR Support - Automatic HDR10 detection and preservation
Distributed Processing
- โ Master/Worker Architecture - Coordinate jobs across multiple computers
- โ Auto Job Distribution - Workers request jobs when idle
- โ Real-time Monitoring - Single unified web interface
- โ Health Monitoring - Auto-detect and recover from worker failures
- โ Linear Scaling - Add workers for proportional speedup
- โ HTTP File Transfer - Workers download and upload files via HTTP
Advanced Features
- โ Job Controls - Cancel, retry, skip, delete operations
- โ Detailed Tracking - Resolution, codec, bitrate, worker assignment
- โ Time Estimates - Per-file and overall ETA with processing speed
- โ Process Priority - Configurable nice/ionice for background operation
- โ HDR Support - Automatic detection and preservation
- โ Configurable Processing Order - Process files by oldest/newest/largest/smallest
๐ Quick Start
Master Server + Local Worker (Linux)
# Clone the repository git clone https://github.com/Hack2C/av1-distributed-encoder.git cd av1-distributed-encoder # Start master + 1 local worker docker compose -f docker-compose.test.yml up -d - โ **Time Estimates** - Per-file and overall ETA with processing speed # Access web interface- โ **Process Priority** - Configurable nice/ionice for background operation http://localhost:8090- โ **HDR Support** - Automatic detection and preservation - โ **Configurable Processing Order** - Process files by oldest/newest/largest/smallest ```- โ **Multi-track** - Preserves all audio tracks, subtitles, and metadata ### 2. Windows Worker## ๐ Quick Start Edit `docker-compose.windows-worker.yml` and replace `MASTER_IP_HERE` with your master server IP:### Docker (Recommended) ```yaml**Master Server:** command: python3 worker_client.py http://192.168.1.100:8090```bash ```# Create config directory mkdir -p master-data/config Then start the worker: # Start master ```bashdocker compose -f docker-compose.master.yml up -d docker compose -f docker-compose.windows-worker.yml up -d ```# Access web UI open http://localhost:8090 ## Architecture``` # Access web interface http://localhost:8090
Additional Workers
# Copy worker config cp docker-compose.worker.yml docker-compose.worker-1.yml # Edit configuration (set MASTER_URL and media paths) nano docker-compose.worker-1.yml # Start worker docker compose -f docker-compose.worker-1.yml up -d
๐ฆ Installation
Prerequisites
- Docker Desktop (Windows/Mac) or Docker Engine (Linux)
- Access to media files (local or network share)
Architecture
- Master Server: Coordinates jobs, serves web UI, provides file downloads
- Workers: Process transcoding jobs, download files from master, upload results
- File Distribution: HTTP-based file transfer (no NFS/SMB required)
- Quality Lookup: Built-in CRF/bitrate tables (no manual config needed)
โ๏ธ Configuration
Quality settings are built into the container - no manual configuration required!
Master
-
MEDIA_DIRS: Comma-separated list of media directories# Run -
TESTING_MODE: Creates.bakbackups instead of deleting originalspython3 transcode.py -
SVT_AV1_PRESET: Encoder preset (0=slowest/best, 13=fastest/worst)``` -
FILE_ORDER: Processing order (oldest,newest,largest,smallest) -
SKIP_AUDIO_TRANSCODE: Set totrueto copy audio without transcoding (useful for complex multi-channel audio) -
PUID/PGID: User/Group ID for file ownership (default: 1000)
Distributed Mode:
Master
Worker
SVT_AV1_PRESET: Encoder presetPUID/PGID: User/Group ID for file ownership (default: 1000)
./start_worker.sh http://MASTER_IP:8090
๐จ HDR Handling
The system automatically detects and handles HDR content:
- โ HDR10 (Static): Transcoded with proper color parameters preserved
- โ HDR10+ (Static): Static metadata preserved, dynamic metadata handled gracefully
- โ HDR10+ (Dynamic): Skipped - dynamic metadata cannot be preserved
- โ Dolby Vision: Always skipped - dynamic metadata cannot be preserved
Quality Protection: Files with dynamic HDR are skipped to prevent quality degradation.
๐ฆ Installation
Prerequisites
- Docker Desktop (Windows/Mac) or Docker Engine (Linux)
- Access to media files (local or network share)
Docker Compose Files
docker-compose.test.yml: Master + 1 local worker for testingdocker-compose.master.yml: Master server onlydocker-compose.worker.yml: Worker node templatedocker-compose.windows-worker.yml: Windows worker using GHCR image
Quality settings are built into the container - no manual configuration required!
Recommended Setup: File Distribution Mode
- โ No shared storage needed - Workers download files via HTTP
- โ Simplified deployment - No NFS/SMB mount configuration
- โ Better security - No privileged containers required
- โ Cross-platform - Works on Windows, Linux, macOS workers
๐ Monitoring
Web interface (http://localhost:8090) provides:
- Overall statistics (files processed, space saved)
- Worker status and performance monitoring
- File queue with detailed progress tracking
- Real-time updates via WebSockets
โ๏ธ Configuration
Web interface (http://localhost:8090) provides:
- Overall statistics (files processed, savings)
- Worker status and performance
- File queue with progress tracking
- Real-time updates via WebSockets
Configuration
Environment Variables
# Master Configuration MEDIA_DIRS=/media/Movies,/media/TV # Media directories (comma-separated) TEMP_DIR=/tmp/av1_transcoding # Temporary processing directory WEB_PORT=8090 # Web interface port TESTING_MODE=true # Keep backup files for verification # Worker Configuration MASTER_URL=http://192.168.1.100:8090 # Master server URL MEDIA_DIRS= # Empty for file distribution mode # Encoding Settings # Encoding Settings Workers automatically:SVT_AV1_PRESET=8 # 0-13 (0=slowest/best, 8=balanced, 13=fastest) - Clean temp directory on startup - Clean temp files after each job (success or failure)# Process Priority - Remove abandoned files from crashes/restartsNICE_LEVEL=19 # CPU priority (0-19, 19=lowest) IONICE_CLASS=3 # I/O priority (1-3, 3=idle) ## Repository ## Repository https://github.com/Hack2C/av1-distributed-encoder # Network Shares (Optional - for shared file access) SMB_HOST=192.168.1.10 # NAS hostname/IP SMB_SHARE=Media # Share name SMB_USERNAME=user # Username SMB_PASSWORD=password # Password SMB_VERSION=3.0 # SMB protocol version
๐๏ธ Architecture
System Overview
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Master Server (8090) โ
โ โข Job coordination & queue management โ
โ โข Worker health monitoring โ
โ โข Modern web interface โ
โ โข Progress aggregation โ
โ โข File distribution (optional) โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโดโโโโโโโโโโโโฌโโโโโโโโโโโโโโโ
โ โ โ
โโโโผโโโโโโโโโ โโโโโโโโผโโโโโโ โโโโโผโโโโโโโโโ
โ Worker 1 โ โ Worker 2 โ โ Worker 3 โ
โ Transcode โ โ Transcode โ โ Transcode โ
โ Progress โ โ Progress โ โ Progress โ
โ Heartbeat โ โ Heartbeat โ โ Heartbeat โ
โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ
Processing Pipeline
- Scan - Master scans media directories for video files
- Queue - Files added to SQLite database with metadata
- Probe - FFmpeg analyzes source (codec, resolution, HDR, audio)
- Assign - Master assigns job to idle worker
- Download - Worker downloads file from master via HTTP
- Transcode - Worker encodes with SVT-AV1 + Opus
- Upload - Worker uploads result back to master
- Verify - Check quality and size savings (minimum 5%)
- Replace - Atomic file replacement with backup
- Cleanup - Delete backup if not in testing mode
๐จ Web Interface
Modern Dashboard
Access at http://MASTER_IP:8090
Statistics Overview:
- Total files, pending, processing, completed
- Space saved across library
- Estimated time remaining
Worker Cards:
- Status (idle/processing/offline)
- CPU and memory usage
- Current file with progress bar
- Processing speed (FPS) and ETA
- Completed/failed job counts
File Queue:
- Detailed file information (resolution, codec, size)
- Status badges with color coding
- Real-time progress bars
- Job controls (cancel, retry, skip, delete)
- Filter by status
- Search by filename
Job Controls:
- Cancel - Stop processing file
- Retry - Restart failed or stuck jobs
- Skip - Mark file as complete without processing
- Delete - Remove file from queue
- Re-encode - Re-process completed files
- Scan Library - Trigger new media scan
โ๏ธ Configuration
Quality Optimization
The system uses lookup tables to determine optimal encoding settings:
quality_lookup.json - Video CRF values
{
"SD": {"x264": 28, "x265": 30, "av1": 35},
"720p": {"x264": 26, "x265": 28, "av1": 33},
"1080p": {"x264": 24, "x265": 26, "av1": 31},
"1440p": {"x264": 22, "x265": 24, "av1": 29},
"4K": {"x264": 20, "x265": 22, "av1": 27}
}audio_codec_lookup.json - Opus bitrates
{
"1": 64,
"2": 96,
"6": 256,
"8": 320
}Editing Configuration:
Docker:
# Edit files in persistent volume nano master-data/config/quality_lookup.json nano master-data/config/audio_codec_lookup.json # Restart to apply docker compose restart
Native:
# Edit files directly
nano quality_lookup.json
nano audio_codec_lookup.jsonWorkers automatically fetch updated config from master on startup.
Docker Compose Files
docker-compose.master.yml - Master server only
services: master: build: . ports: - "8090:8090" volumes: - ./master-data:/data - ./Movies:/media/Movies - ./TV:/media/TV environment: - MEDIA_DIRS=/media/Movies,/media/TV - SVT_AV1_PRESET=8
docker-compose.worker.yml - Distributed worker
services: worker: build: . volumes: - ./worker-data:/data - /tmp/worker_temp:/tmp/av1_transcoding environment: - MASTER_URL=http://192.168.1.100:8090 - FILE_DISTRIBUTION_MODE=false - SMB_HOST=192.168.1.10 - SMB_SHARE=Media
docker-compose.test.yml - Distributed transcoding test
services: master: # Master has access to media files worker1: # Worker downloads files from master
๐ Performance
Scaling Examples
Processing 100 files (30 minutes each at SVT-AV1 preset 8):
| Workers | Time | Speedup |
|---|---|---|
| 1 | 50 hours | 1ร |
| 2 | 25 hours | 2ร |
| 4 | 12.5 hours | 4ร |
| 8 | 6.25 hours | 8ร |
Encoding Presets
SVT-AV1 preset performance (varies by hardware):
| Preset | Quality | Speed | Use Case |
|---|---|---|---|
| 0-3 | Excellent | Very Slow | Archival, maximum quality |
| 4-6 | Very Good | Slow | High-quality encodes |
| 7-9 | Good | Medium | Balanced (recommended) |
| 10-13 | Fair | Fast | Quick previews, testing |
Recommended: Preset 8 for balanced quality and speed.
Space Savings
Typical compression results (varies by source):
| Source | Target | Savings |
|---|---|---|
| H.264 High Bitrate | AV1 | 40-60% |
| H.265/HEVC | AV1 | 20-40% |
| VP9 | AV1 | 10-25% |
| Old Codecs (MPEG-2) | AV1 | 60-80% |
๐ง Troubleshooting
Common Issues
Workers Not Connecting:
# Test master accessibility curl http://MASTER_IP:8090/api/status # Check firewall sudo ufw allow 8090/tcp # View master logs docker compose logs -f master
Jobs Not Processing:
# Check worker status in web UI # Verify files are in "pending" status # Check worker logs docker compose logs -f worker # Verify media directory access docker compose exec worker ls -la /media
Web UI Not Updating:
# Check WebSocket connection in browser console # Clear browser cache # Verify no proxy blocking WebSocket
Low Processing Speed:
# Check CPU usage docker stats # Adjust preset (higher = faster) docker compose down # Edit SVT_AV1_PRESET in compose file docker compose up -d # Verify nice/ionice settings docker compose exec worker ps aux | grep ffmpeg
Logs
Docker:
# Master logs docker compose -f docker-compose.master.yml logs -f # Worker logs docker compose -f docker-compose.worker.yml logs -f # Specific container docker logs av1-master --tail 100 -f
Native:
# Check system logs journalctl -u av1-transcode -f # Application logs (if configured) tail -f /var/log/av1-transcode.log
๐ Project Structure
av1/
โโโ README.md # This file
โโโ requirements.txt # Python dependencies
โโโ Dockerfile # Multi-stage Docker build
โโโ docker-entrypoint.sh # Container startup script
โ
โโโ docker-compose.master.yml # Master server
โโโ docker-compose.worker.yml # Worker node
โโโ docker-compose.filedist-test.yml # File distribution test
โ
โโโ transcode.py # Standalone server
โโโ master_server.py # Master coordinator
โโโ worker_client.py # Worker client
โโโ init_config.py # Config initialization
โ
โโโ config.json # Native Python config
โโโ quality_lookup.json # Video CRF defaults
โโโ audio_codec_lookup.json # Audio bitrate defaults
โ
โโโ lib/
โ โโโ config.py # Configuration management
โ โโโ database.py # SQLite queue + stats
โ โโโ scanner.py # Media directory scanner
โ โโโ probe.py # FFmpeg metadata extraction
โ โโโ quality.py # Quality lookup logic
โ โโโ transcoder.py # Encoding engine
โ โโโ master_coordinator.py # Worker coordination
โ โโโ web_api.py # Flask API routes
โ
โโโ web/
โโโ index.html # Service status page
โโโ master.html # Master server web interface
โโโ master.js # Web interface JavaScript
โโโ style.css # Web interface styles
๐ Security Considerations
Production Deployment
Network Security:
- Use HTTPS reverse proxy (nginx, Caddy)
- Implement authentication (Basic Auth, OAuth)
- Restrict master port access via firewall
- Use VPN for remote workers
File Security:
- Run containers as non-root user
- Use read-only media mounts where possible
- Implement backup strategy
- Enable testing mode initially
SMB/NFS:
- Use credentials with minimum required permissions
- Store passwords in .env file (not in compose yaml)
- Use SMB3 or NFS4 with encryption
Example Nginx Reverse Proxy
server { listen 443 ssl http2; server_name transcode.example.com; ssl_certificate /path/to/cert.pem; ssl_certificate_key /path/to/key.pem; auth_basic "Restricted"; auth_basic_user_file /etc/nginx/.htpasswd; location / { proxy_pass http://localhost:8090; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }
๐ ๏ธ Development
Building
# Build Docker image docker build -t av1-transcoder . # Build specific architecture docker buildx build --platform linux/amd64,linux/arm64 -t av1-transcoder .
Testing
# Run master + 2 workers locally docker compose -f docker-compose.filedist-test.yml up # View logs docker compose -f docker-compose.filedist-test.yml logs -f # Stop and cleanup docker compose -f docker-compose.filedist-test.yml down
Contributing
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing) - Commit changes (
git commit -am 'Add amazing feature') - Push to branch (
git push origin feature/amazing) - Open Pull Request
๐ License
MIT License - See LICENSE file for details
๐ Acknowledgments
- SVT-AV1 - Scalable Video Technology for AV1
- Opus - High-quality audio codec
- FFmpeg - Multimedia processing framework
- Flask - Python web framework
- Socket.IO - Real-time bidirectional communication
๐ Additional Resources
๐ Changelog
Version 2.2.0 (November 2025)
- ๐๏ธ Architecture Simplification: Removed shared storage mode - now uses only file distribution for simpler deployment
- ๐ฅ Three-Phase Progress System: Distinct 0-100% progress tracking for Downloading/Processing/Uploading phases
- ๐ Enhanced Telemetry: Real-time speed (MB/s) for download/upload phases, FPS for processing phase
- ๐จ Visual Progress Distinction: Color-coded progress bars (Blue=Download, Yellow=Processing, Purple=Upload)
- ๐ Streamlined Configuration: Removed FILE_DISTRIBUTION_MODE - workers always download files from master
- ๐งน Codebase Cleanup: Eliminated 200+ lines of shared storage code, simplified Docker configurations
Version 2.1.1 (November 2025)
- ๐ Enhanced Statistics Dashboard: Added "Space Saved %" and "Est Total Savings" panels for better progress visualization
- ๐ฑ Mobile UI Improvements: Responsive header layout with improved button placement and version display
- ๐ฅ Download Progress Bar: Real-time download progress with speed (MB/s) and ETA display during file distribution
- ๐ฏ Dynamic Progress Display: Existing progress bars now show download metrics during download phase, transcoding metrics during encoding
- ๐ง Smart Progress Transitions: Seamless switching between download speed/ETA and transcoding FPS/ETA
Version 2.1.0 (November 2025)
- ๐๏ธ Centralized Audio Configuration:
SKIP_AUDIO_TRANSCODEnow configured on master and distributed to all workers - ๐ต Enhanced Audio Handling: Improved support for complex multi-channel audio layouts with optional transcoding bypass
- ๐ Production HDR Support: Comprehensive HDR10/HDR10+ parameter validation and intelligent fallback mechanisms
- ๐ Better Progress Reporting: Detailed status messages for download, analysis, transcoding, and upload phases
- ๐ Performance Optimizations: Database compound indexes for large libraries (5000+ files) and configurable processing order
- ๐ง Production Improvements: Enhanced error handling, frame rate validation, and selective FFmpeg stream mapping
Version 2.0.0 (October 2025)
- Initial distributed transcoding system with file distribution mode
- HDR content support and quality-based encoding
- Web-based monitoring and progress tracking
Version: 2.2.0
Last Updated: November 2025