From bcf3e5f65a07a3d1127eeb7b062fe405521bf435 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Wed, 4 Sep 2013 19:52:24 +0200 Subject: [PATCH] Apply frame filters on Frame::save --- src/FFMpeg/Filters/Frame/FrameFilterInterface.php | 3 +-- src/FFMpeg/Media/Frame.php | 10 ++++++++-- tests/FFMpeg/Tests/Media/FrameTest.php | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/FFMpeg/Filters/Frame/FrameFilterInterface.php b/src/FFMpeg/Filters/Frame/FrameFilterInterface.php index db4fdac..d9df0e4 100644 --- a/src/FFMpeg/Filters/Frame/FrameFilterInterface.php +++ b/src/FFMpeg/Filters/Frame/FrameFilterInterface.php @@ -13,9 +13,8 @@ namespace FFMpeg\Filters\Frame; use FFMpeg\Filters\FilterInterface; use FFMpeg\Media\Frame; -use FFMpeg\Format\FrameInterface; interface FrameFilterInterface extends FilterInterface { - public function apply(Frame $frame, FrameInterface $format); + public function apply(Frame $frame); } diff --git a/src/FFMpeg/Media/Frame.php b/src/FFMpeg/Media/Frame.php index 55d4311..a48c50e 100644 --- a/src/FFMpeg/Media/Frame.php +++ b/src/FFMpeg/Media/Frame.php @@ -97,16 +97,22 @@ class Frame extends AbstractMediaType '-y', '-ss', (string) $this->timecode, '-i', $this->pathfile, '-vframes', '1', - '-f', 'image2', $pathfile + '-f', 'image2' ); } else { $commands = array( '-y', '-i', $this->pathfile, '-vframes', '1', '-ss', (string) $this->timecode, - '-f', 'image2', $pathfile + '-f', 'image2' ); } + foreach ($this->filters as $filter) { + $commands = array_merge($commands, $filter->apply($this)); + } + + $commands = array_merge($commands, array($pathfile)); + try { $this->driver->command($commands); } catch (ExecutionFailureException $e) { diff --git a/tests/FFMpeg/Tests/Media/FrameTest.php b/tests/FFMpeg/Tests/Media/FrameTest.php index c98cb87..b64d6e9 100644 --- a/tests/FFMpeg/Tests/Media/FrameTest.php +++ b/tests/FFMpeg/Tests/Media/FrameTest.php @@ -11,7 +11,7 @@ class FrameTest extends AbstractMediaTestCase */ public function testWithInvalidFile() { - new Frame('/No/file', $this->getFFMpegDriverMock(), $this->getFFProbeMock(), $this->getTimeCodeMock()); + new Frame($this->getVideoMock('/No/file'), $this->getFFMpegDriverMock(), $this->getFFProbeMock(), $this->getTimeCodeMock()); } public function testGetTimeCode()