From 72d7a8c2369c7d866291e876877b91b2663d433d Mon Sep 17 00:00:00 2001 From: sylvainv Date: Wed, 30 Jul 2014 17:59:55 +0800 Subject: [PATCH] Added custom filter support --- src/FFMpeg/Filters/Video/CustomFilter.php | 51 +++++++++++++++++++ .../Tests/Filters/Video/CustomFilterTest.php | 20 ++++++++ 2 files changed, 71 insertions(+) create mode 100644 src/FFMpeg/Filters/Video/CustomFilter.php create mode 100644 tests/FFMpeg/Tests/Filters/Video/CustomFilterTest.php diff --git a/src/FFMpeg/Filters/Video/CustomFilter.php b/src/FFMpeg/Filters/Video/CustomFilter.php new file mode 100644 index 0000000..4946c62 --- /dev/null +++ b/src/FFMpeg/Filters/Video/CustomFilter.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace FFMpeg\Filters\Video; + +use FFMpeg\Format\VideoInterface; +use FFMpeg\Media\Video; + +class CustomFilter implements VideoFilterInterface +{ + /** @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(Video $video, VideoInterface $format) + { + $commands = array('-vf', $this->filter); + return $commands; + } +} diff --git a/tests/FFMpeg/Tests/Filters/Video/CustomFilterTest.php b/tests/FFMpeg/Tests/Filters/Video/CustomFilterTest.php new file mode 100644 index 0000000..ff8ad75 --- /dev/null +++ b/tests/FFMpeg/Tests/Filters/Video/CustomFilterTest.php @@ -0,0 +1,20 @@ +getVideoMock(); + $format = $this->getMock('FFMpeg\Format\VideoInterface'); + + $filter = new CustomFilter('whatever i put would end up as a filter'); + $this->assertEquals(array('-vf', 'whatever i put would end up as a filter'), $filter->apply($video, $format)); + } +}