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

@ -221,9 +221,11 @@ class ComplexMedia extends AbstractMediaType
* Apply added filters and execute ffmpeg command.
*
* @return ComplexMedia
* @throws RuntimeException
*/
public function save()
{
$this->assertFiltersAreCompatibleToCurrentFFMpegVersion();
$command = $this->buildCommand();
try {
@ -319,6 +321,28 @@ class ComplexMedia extends AbstractMediaType
return $in . $strCommand . $out;
}
/**
* @return void
* @throws RuntimeException
*/
protected function assertFiltersAreCompatibleToCurrentFFMpegVersion()
{
$messages = array();
$currentVersion = $this->getFFMpegDriver()->getVersion();
/** @var ComplexFilterInterface $filter */
foreach ($this->filters as $filter) {
if (version_compare($currentVersion, $filter->getMinimalFFMpegVersion(), '<')) {
$messages[] = $filter->getName() . ' filter is supported starting from '
. $filter->getMinimalFFMpegVersion() . ' ffmpeg version';
}
}
if (!empty($messages)) {
throw new RuntimeException(implode('; ', $messages)
. '; your ffmpeg version is ' . $currentVersion);
}
}
/**
* @return array
*/