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:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user