/** * {@inheritdoc} */ public function apply(Video $video, VideoInterface $format) { foreach ($video->getStreams()->videos() as $stream) { if ($stream->has('width') && $stream->has('height')) { $stream->set('width', $this->dimension->getWidth()); $stream->set('height', $this->dimension->getHeight()); } } return array('-filter:v', 'crop=' . $this->dimension->getWidth() . ':' . $this->dimension->getHeight() . ':' . $this->point->getX() . ':' . $this->point->getY()); }
public function testCommandParamsAreCorrectAndStreamIsUpdated() { $stream = new Stream(array('width' => 320, 'height' => 240, 'codec_type' => 'video')); $streams = new StreamCollection(array($stream)); $video = $this->getVideoMock(); $video->expects($this->once())->method('getStreams')->will($this->returnValue($streams)); $format = $this->getMock('FFMpeg\\Format\\VideoInterface'); $dimension = new Dimension(200, 150); $point = new Point(25, 35); $filter = new CropFilter($point, $dimension); $expected = array('-filter:v', 'crop=' . $dimension->getWidth() . ":" . $dimension->getHeight() . ":" . $point->getX() . ":" . $point->getY()); $this->assertEquals($expected, $filter->apply($video, $format)); $this->assertEquals(200, $stream->get('width')); $this->assertEquals(150, $stream->get('height')); }
public function testGetters() { $point = new Point(4, 25); $this->assertEquals(4, $point->getX()); $this->assertEquals(25, $point->getY()); }