This guide explains how to run the complete FFmpeg RTMP stack (master + agent) locally on a single machine for development and testing.
# Run the automated script (recommended)
./scripts/run_local_stack.sh
# Or skip the test job submission
SKIP_TEST_JOB=true ./scripts/run_local_stack.shThe script will:
- Check prerequisites (Go, Python, FFmpeg, curl)
- 🔨 Build all binaries (master, agent, CLI)
- Start the master node with TLS
- Register and start the compute agent
- ✔️ Verify the stack is running
- Submit a test job (optional)
- Display helpful commands and URLs
- Port: 8080 (HTTPS)
- Endpoints:
- Health:
https://localhost:8080/health - Nodes:
https://localhost:8080/nodes - Jobs:
https://localhost:8080/jobs
- Health:
- Metrics: http://localhost:9090/metrics
- Database: SQLite (
master.db) - Logs:
logs/master.log
- Registration: Automatic with master
- Mode: Master-as-worker (development only)
- Metrics: http://localhost:9091/metrics
- Logs:
logs/agent.log
The script checks for these automatically:
- Go 1.21+ - For building binaries
- Python 3.10+ - For helper scripts
- FFmpeg - For video transcoding
- curl - For API testing
The script respects these variables:
# Master API port (default: 8080)
export MASTER_PORT=8080
# Agent API port (default: 8081)
export AGENT_PORT=8081
# API key (auto-generated if not set)
export MASTER_API_KEY="your-secret-key"
# Skip test job submission
export SKIP_TEST_JOB=true# List registered nodes
curl -s -k -H "Authorization: Bearer $MASTER_API_KEY" \
https://localhost:8080/nodes | python3 -m json.tool
# List all jobs
curl -s -k -H "Authorization: Bearer $MASTER_API_KEY" \
https://localhost:8080/jobs | python3 -m json.tool
# Check master health
curl -s -k https://localhost:8080/health# Simple test job
curl -X POST -k \
-H "Authorization: Bearer $MASTER_API_KEY" \
-H "Content-Type: application/json" \
https://localhost:8080/jobs \
-d '{
"scenario": "test-720p",
"confidence": "auto",
"parameters": {
"duration": 30,
"bitrate": "2000k",
"resolution": "1280x720",
"fps": 30
}
}'
# Live stream job (high priority)
curl -X POST -k \
-H "Authorization: Bearer $MASTER_API_KEY" \
-H "Content-Type: application/json" \
https://localhost:8080/jobs \
-d '{
"scenario": "live-stream-1080p",
"confidence": "auto",
"queue": "live",
"priority": "high",
"parameters": {
"duration": 60,
"bitrate": "5000k"
}
}'# Get specific job status
JOB_ID="<your-job-id>"
curl -s -k \
-H "Authorization: Bearer $MASTER_API_KEY" \
https://localhost:8080/jobs/$JOB_ID | python3 -m json.tool
# Watch logs in real-time
tail -f logs/agent.log
tail -f logs/master.log# Master metrics
curl -s http://localhost:9090/metrics | grep ffmpeg_
# Agent metrics
curl -s http://localhost:9091/metrics | grep ffmpeg_Press Ctrl+C in the terminal running the script. The cleanup handler will:
- Stop the agent process
- Stop the master process
- Display cleanup confirmation
If you prefer to run components manually:
make build-distributedexport MASTER_API_KEY=$(openssl rand -base64 32)
./bin/master --port 8080 &
MASTER_PID=$!./bin/agent \
--register \
--master https://localhost:8080 \
--api-key "$MASTER_API_KEY" \
--allow-master-as-worker \
--skip-confirmation &
AGENT_PID=$!kill $AGENT_PID
kill $MASTER_PIDProblem: Agent fails to register with master
Solutions:
- Check master is running:
curl -k https://localhost:8080/health - Verify API key matches:
echo $MASTER_API_KEY - Check logs:
cat logs/agent.log
Problem: Port 8080 or 9090 already in use
Solutions:
# Use different ports
MASTER_PORT=8888 ./scripts/run_local_stack.sh
# Or kill existing process
lsof -ti:8080 | xargs kill -9Problem: SSL certificate verification fails
Solutions:
- Use
-kflag with curl:curl -k https://localhost:8080/health - The agent automatically skips verification for localhost
- For production, use proper certificates with
--certand--keyflags
Problem: Jobs stay in "queued" status
Solutions:
- Check agent is running:
ps aux | grep agent - Verify node is available:
curl -k -H "Authorization: Bearer $MASTER_API_KEY" https://localhost:8080/nodes - Check agent logs:
tail -f logs/agent.log
Problem: Go build errors
Solutions:
# Update dependencies
go mod tidy
go mod download
# Clear Go cache
go clean -cache -modcache
# Rebuild
make build-distributedAll logs are written to the logs/ directory:
logs/
├── master.log # Master node logs
└── agent.log # Agent node logsView logs:
# Tail logs in real-time
tail -f logs/master.log
tail -f logs/agent.log
# Search logs
grep "error" logs/*.log
grep "job" logs/agent.logRunning master + agent on the same machine:
- CPU: Shared between orchestration and transcoding
- Memory: ~500MB for master, variable for agent (depends on job)
- Disk: Minimal (logs + SQLite database)
For local testing:
- CPU: 4+ cores
- RAM: 8GB+
- Storage: 10GB+ free space
For heavier workloads:
- CPU: 8+ cores
- RAM: 16GB+
- GPU: Optional (NVIDIA for hardware acceleration)
This local setup is for development/testing only
For production:
- Deploy master on dedicated server
- Deploy agents on separate compute nodes
- Use proper TLS certificates
- Configure firewall rules
- Set up monitoring (Grafana + VictoriaMetrics)
- Use systemd services for auto-restart
See deployment/README.md for production setup.