Add FrameFilters::fixDisplayRatio method

This commit is contained in:
Romain Neutron 2013-09-05 11:16:26 +02:00
commit bb31915285
3 changed files with 44 additions and 1 deletions

View file

@ -21,4 +21,19 @@ class FrameFilters
{
$this->frame = $frame;
}
/**
* Fixes the display ratio of the output frame.
*
* In case the sample ratio and display ratio are different, image may be
* anamorphozed. This filter fixes this by specifying the output size.
*
* @return FrameFilters
*/
public function fixDisplayRatio()
{
$this->frame->addFilter(new DisplayRatioFixerFilter());
return $this;
}
}

View file

@ -0,0 +1,21 @@
<?php
namespace FFMpeg\Tests\Filters\Frame;
use FFMpeg\Tests\TestCase;
use FFMpeg\Filters\Frame\FrameFilters;
class FrameFiltersTest extends TestCase
{
public function testResize()
{
$frame = $this->getFrameMock();
$filters = new FrameFilters($frame);
$frame->expects($this->once())
->method('addFilter')
->with($this->isInstanceOf('FFMpeg\Filters\Frame\DisplayRatioFixerFilter'));
$filters->fixDisplayRatio();
}
}

View file

@ -40,6 +40,13 @@ class TestCase extends \PHPUnit_Framework_TestCase
->getMock();
}
public function getFrameMock()
{
return $this->getMockBuilder('FFMpeg\Media\Frame')
->disableOriginalConstructor()
->getMock();
}
public function getFFMpegDriverMock()
{
return $this->getMockBuilder('FFMpeg\Driver\FFMpegDriver')
@ -129,7 +136,7 @@ class TestCase extends \PHPUnit_Framework_TestCase
->getMock();
$video->expects($this->any())
->method('getFilename')
->method('getPathfile')
->will($this->returnValue($filename));
return $video;