init
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user