added custom frame filter

This commit is contained in:
Ilja Lukin 2018-11-20 23:32:47 +01:00
commit b3bfb34475
2 changed files with 68 additions and 0 deletions

View file

@ -0,0 +1,54 @@
<?php
/*
* This file is part of PHP-FFmpeg.
*
* (c) Alchemy <dev.team@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FFMpeg\Filters\Frame;
use FFMpeg\Exception\RuntimeException;
use FFMpeg\Media\Frame;
class CustomFrameFilter implements FrameFilterInterface
{
/** @var string */
private $filter;
/** @var integer */
private $priority;
/**
* A custom filter, useful if you want to build complex filters
*
* @param string $filter
* @param int $priority
*/
public function __construct($filter, $priority = 0)
{
$this->filter = $filter;
$this->priority = $priority;
}
/**
* {@inheritdoc}
*/
public function getPriority()
{
return $this->priority;
}
/**
* {@inheritdoc}
*/
public function apply(Frame $frame)
{
$commands = array('-vf', $this->filter);
return $commands;
}
}

View file

@ -36,4 +36,18 @@ class FrameFilters
return $this;
}
/**
* Applies a custom filter: -vf foo bar
*
* @param string $parameters
*
* @return FrameFilters
*/
public function custom($parameters)
{
$this->frame->addFilter(new CustomFrameFilter($parameters));
return $this;
}
}