Added runtime check of the ffmpeg version before starting the command in the ComplexMedia. Added the FFMpegDriver::getVersion() method.
This commit is contained in:
parent
580fb21d5a
commit
d6f95508a9
15 changed files with 212 additions and 25 deletions
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue