binext: improve ffmpeg check

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/653/head
Varun Patil 2023-04-29 10:56:43 -07:00
parent 578b0645f4
commit 7e252fd56c
1 changed files with 3 additions and 9 deletions

View File

@ -402,20 +402,14 @@ class BinExt
return $ffmpegPath; return $ffmpegPath;
} }
public static function testFFmpeg(string $path, string $vername) public static function testFFmpeg(string $path, string $name)
{ {
$version = shell_exec("{$path} -version"); $version = shell_exec("{$path} -version");
if (!preg_match("/{$vername} version\\s+([0-9\\.]+)/", $version, $matches)) { if (!preg_match("/{$name} version \\S*/", $version, $matches)) {
throw new \Exception("failed to detect version, found {$version}"); throw new \Exception("failed to detect version, found {$version}");
} }
$minver = '4.0'; return explode(' ', $matches[0])[2];
$semver = $matches[1];
if (!version_compare($semver, $minver, '>=')) {
throw new \Exception("version must be >= {$minver}, found {$semver}");
}
return $semver;
} }
public static function testSystemPerl(string $path): string public static function testSystemPerl(string $path): string