Merge branch 'master' into jens1o-patch-1
This commit is contained in:
commit
da7a0b3777
2 changed files with 49 additions and 8 deletions
|
|
@ -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());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue