Add PHP Video Converter Suite with live stream pipelines and nuclear control panel UI

Full-featured video conversion platform with:
- FFmpeg-based pipeline system with composable stages (transcode, scale, filter, audio, bitrate, framerate, trim, deinterlace, denoise, stabilize)
- Live stream management with real-time format switching (RTMP/RTSP/HTTP)
- Industrial/nuclear power plant control room themed UI with gauges, switches, LED indicators
- Format switchboard for instant conversion between 16+ video/audio formats
- Pipeline designer with visual flow editor and drag-and-drop stage composition
- Job queue with priority scheduling and batch conversion
- WebSocket server for real-time progress broadcasting
- REST API for all operations (upload, convert, streams, pipelines, queue)
- System monitoring (CPU, memory, disk) with animated gauge displays
- Docker Compose setup with web, websocket, and worker services

https://claude.ai/code/session_01WxmHGnVFXGm2bwbFREHkHb
This commit is contained in:
Claude
2026-02-07 18:11:04 +00:00
parent 282d8b70fc
commit 6c56306873
27 changed files with 4746 additions and 0 deletions
@@ -0,0 +1,68 @@
#!/usr/bin/env php
<?php
/**
* Video Converter Suite - Queue Worker
*
* Processes jobs from the queue sequentially.
* Usage: php bin/queue-worker.php
*/
spl_autoload_register(function ($class) {
$prefix = 'VideoConverter\\';
$baseDir = __DIR__ . '/../src/';
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) return;
$relative = substr($class, $len);
$file = $baseDir . str_replace('\\', '/', $relative) . '.php';
if (file_exists($file)) require $file;
});
use VideoConverter\Queue\JobQueue;
use VideoConverter\Format\FormatConverter;
$config = require __DIR__ . '/../config/app.php';
echo "=== Video Converter Suite - Queue Worker ===\n";
echo "Max concurrent: {$config['limits']['max_concurrent_jobs']}\n\n";
$queue = new JobQueue();
$converter = new FormatConverter();
$running = 0;
while (true) {
$queue = new JobQueue(); // Reload state
$converter = new FormatConverter();
$activeJobs = array_filter($converter->getAllJobs(), fn($j) => $j['status'] === 'running');
$running = count($activeJobs);
if ($running < $config['limits']['max_concurrent_jobs']) {
$nextJob = $queue->dequeue();
if ($nextJob) {
echo "[" . date('H:i:s') . "] Processing: {$nextJob['queue_id']}\n";
try {
$result = $converter->convert([
'input_file' => $nextJob['input_file'] ?? '',
'output_format' => $nextJob['output_format'] ?? 'mp4',
'preset' => $nextJob['preset'] ?? 'balanced',
'resolution' => $nextJob['resolution'] ?? null,
]);
if (isset($result['error'])) {
$queue->fail($nextJob['queue_id'], $result['error']);
echo "[" . date('H:i:s') . "] Failed: {$result['error']}\n";
} else {
$queue->complete($nextJob['queue_id'], $result);
echo "[" . date('H:i:s') . "] Started job: {$result['id']}\n";
}
} catch (\Throwable $e) {
$queue->fail($nextJob['queue_id'], $e->getMessage());
echo "[" . date('H:i:s') . "] Error: {$e->getMessage()}\n";
}
}
}
sleep(2);
}
+101
View File
@@ -0,0 +1,101 @@
#!/bin/bash
# Video Converter Suite - Startup Script
# Starts all services: Web Server, WebSocket Server, Queue Worker
echo "================================================"
echo " VIDEO CONVERTER SUITE - Starting Services"
echo "================================================"
echo ""
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$DIR"
# Create storage directories
mkdir -p storage/{uploads,outputs,thumbnails,logs,temp}
# Check FFmpeg
if command -v ffmpeg &> /dev/null; then
echo "[OK] FFmpeg: $(ffmpeg -version 2>&1 | head -1)"
else
echo "[!!] FFmpeg not found. Install with: apt install ffmpeg"
echo " The application will work but conversions will fail."
fi
# Check PHP
if command -v php &> /dev/null; then
echo "[OK] PHP: $(php -v 2>&1 | head -1)"
else
echo "[!!] PHP not found."
exit 1
fi
# Install dependencies if needed
if [ ! -d "vendor" ]; then
echo ""
echo "Installing dependencies..."
if command -v composer &> /dev/null; then
composer install
else
echo "[!!] Composer not found. WebSocket server won't work."
echo " The web interface will still work without it."
fi
fi
echo ""
echo "Starting services..."
echo ""
# Start Web Server
echo "[1/3] Web Server on http://localhost:8080"
php -S 0.0.0.0:8080 -t public public/router.php \
-d upload_max_filesize=5G \
-d post_max_size=5G \
-d memory_limit=512M \
-d max_execution_time=3600 \
> storage/logs/web.log 2>&1 &
WEB_PID=$!
# Start WebSocket Server (optional, requires Ratchet)
if [ -f "vendor/autoload.php" ]; then
echo "[2/3] WebSocket Server on ws://localhost:8081"
php bin/websocket-server.php > storage/logs/websocket.log 2>&1 &
WS_PID=$!
else
echo "[2/3] WebSocket Server: SKIPPED (run composer install first)"
WS_PID=""
fi
# Start Queue Worker
echo "[3/3] Queue Worker"
php bin/queue-worker.php > storage/logs/worker.log 2>&1 &
WORKER_PID=$!
echo ""
echo "================================================"
echo " All services started!"
echo ""
echo " Web UI: http://localhost:8080"
echo " WebSocket: ws://localhost:8081"
echo ""
echo " PIDs: Web=$WEB_PID WS=$WS_PID Worker=$WORKER_PID"
echo " Logs: storage/logs/"
echo ""
echo " Press Ctrl+C to stop all services"
echo "================================================"
# Trap exit to kill all processes
cleanup() {
echo ""
echo "Stopping all services..."
kill $WEB_PID 2>/dev/null
[ -n "$WS_PID" ] && kill $WS_PID 2>/dev/null
kill $WORKER_PID 2>/dev/null
echo "All services stopped."
exit 0
}
trap cleanup EXIT INT TERM
# Wait for any process to exit
wait
@@ -0,0 +1,41 @@
#!/usr/bin/env php
<?php
/**
* Video Converter Suite - WebSocket Server
*
* Provides real-time status updates to connected clients.
* Usage: php bin/websocket-server.php
*/
require_once __DIR__ . '/../vendor/autoload.php';
use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
use VideoConverter\WebSocket\StatusServer;
$config = require __DIR__ . '/../config/app.php';
$host = $config['websocket']['host'];
$port = $config['websocket']['port'];
echo "=== Video Converter Suite - WebSocket Server ===\n";
echo "Starting on {$host}:{$port}\n\n";
$statusServer = new StatusServer();
$server = IoServer::factory(
new HttpServer(
new WsServer($statusServer)
),
$port,
$host
);
// Broadcast status every 2 seconds
$server->loop->addPeriodicTimer(2, function () use ($statusServer) {
$statusServer->broadcastStatus();
});
echo "WebSocket server running. Press Ctrl+C to stop.\n";
$server->run();