44 lines
945 B
PHP
44 lines
945 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Esun\Video\Model;
|
|
|
|
use Symfony\Component\Process\Process;
|
|
|
|
class MediaBinaryStatus
|
|
{
|
|
public function __construct(private readonly Config $config)
|
|
{
|
|
}
|
|
|
|
public function getMissingBinaries(): array
|
|
{
|
|
$binaries = [
|
|
'ffmpeg' => $this->config->getFfmpegBinary(),
|
|
'ffprobe' => $this->config->getFfprobeBinary(),
|
|
];
|
|
$missing = [];
|
|
|
|
foreach ($binaries as $name => $binary) {
|
|
if (!$this->isAvailable($binary)) {
|
|
$missing[$name] = $binary;
|
|
}
|
|
}
|
|
|
|
return $missing;
|
|
}
|
|
|
|
private function isAvailable(string $binary): bool
|
|
{
|
|
$process = new Process([$binary, '-version']);
|
|
$process->setTimeout(5);
|
|
|
|
try {
|
|
$process->run();
|
|
return $process->isSuccessful();
|
|
} catch (\Throwable) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|