Added runtime check of the ffmpeg version before starting the command in the ComplexMedia. Added the FFMpegDriver::getVersion() method.

This commit is contained in:
CaliforniaMountainSnake 2020-02-26 12:33:45 +03:00
commit d6f95508a9
15 changed files with 212 additions and 25 deletions

View file

@ -16,6 +16,7 @@ use Alchemy\BinaryDriver\Configuration;
use Alchemy\BinaryDriver\ConfigurationInterface;
use Alchemy\BinaryDriver\Exception\ExecutableNotFoundException as BinaryDriverExecutableNotFound;
use FFMpeg\Exception\ExecutableNotFoundException;
use FFMpeg\Exception\RuntimeException;
use Psr\Log\LoggerInterface;
class FFMpegDriver extends AbstractBinary
@ -54,4 +55,20 @@ class FFMpegDriver extends AbstractBinary
throw new ExecutableNotFoundException('Unable to load FFMpeg', $e->getCode(), $e);
}
}
/**
* Get ffmpeg version.
*
* @return string
* @throws RuntimeException
*/
public function getVersion()
{
preg_match('#version\s(\S+)#', $this->command('-version'), $version);
if (!isset($version[1])) {
throw new RuntimeException('Cannot to parse the ffmpeg version!');
}
return $version[1];
}
}