Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Lasse Lehtinen 2018-05-30 15:02:09 +03:00
commit 4f40ba9d96
5 changed files with 57 additions and 11 deletions

View file

@ -35,6 +35,10 @@ class ExtractMultipleFramesFilter implements VideoFilterInterface
private $priority;
private $frameRate;
private $destinationFolder;
private $frameFileType = 'jpg';
/** @var array */
private static $supportedFrameFileTypes = ['jpg', 'jpeg', 'png'];
public function __construct($frameRate = self::FRAMERATE_EVERY_SEC, $destinationFolder = __DIR__, $priority = 0)
{
@ -49,6 +53,20 @@ class ExtractMultipleFramesFilter implements VideoFilterInterface
$this->destinationFolder = $destinationFolder;
}
/**
* @param string $frameFileType
* @throws \FFMpeg\Exception\InvalidArgumentException
* @return ExtractMultipleFramesFilter
*/
public function setFrameFileType($frameFileType) {
if (in_array($frameFileType, self::$supportedFrameFileTypes)) {
$this->frameFileType = $frameFileType;
return $this;
}
throw new InvalidArgumentException('Invalid frame file type, use: ' . implode(',', self::$supportedFrameFileTypes));
}
/**
* {@inheritdoc}
*/
@ -117,7 +135,7 @@ class ExtractMultipleFramesFilter implements VideoFilterInterface
// Set the parameters
$commands[] = '-vf';
$commands[] = 'fps=' . $this->frameRate;
$commands[] = $this->destinationFolder . 'frame-%'.$nbDigitsInFileNames.'d.jpg';
$commands[] = $this->destinationFolder . 'frame-%'.$nbDigitsInFileNames.'d.' . $this->frameFileType;
}
catch (RuntimeException $e) {
throw new RuntimeException('An error occured while extracting the frames: ' . $e->getMessage() . '. The code: ' . $e->getCode());

View file

@ -72,7 +72,7 @@ class Concat extends AbstractMediaType
/**
* Saves the concatenated video in the given array, considering that the sources videos are all encoded with the same codec.
*
* @param array $outputPathfile
* @param string $outputPathfile
* @param string $streamCopy
*
* @return Concat
@ -144,6 +144,7 @@ class Concat extends AbstractMediaType
$this->driver->command($commands);
} catch (ExecutionFailureException $e) {
$this->cleanupTemporaryFile($outputPathfile);
// TODO@v1: paste this line into an `finally` block.
$this->cleanupTemporaryFile($sourcesFile);
throw new RuntimeException('Unable to save concatenated video', $e->getCode(), $e);
}

View file

@ -115,7 +115,9 @@ class Frame extends AbstractMediaType
$commands = array_merge($commands, $filter->apply($this));
}
$commands = array_merge($commands, array($pathfile));
if (!$returnBase64) {
$commands = array_merge($commands, array($pathfile));
}
try {
if(!$returnBase64) {