Add FrameFilters::fixDisplayRatio method
This commit is contained in:
parent
e43da86152
commit
bb31915285
3 changed files with 44 additions and 1 deletions
|
|
@ -21,4 +21,19 @@ class FrameFilters
|
||||||
{
|
{
|
||||||
$this->frame = $frame;
|
$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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
21
tests/FFMpeg/Tests/Filters/Frame/FrameFiltersTest.php
Normal file
21
tests/FFMpeg/Tests/Filters/Frame/FrameFiltersTest.php
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -40,6 +40,13 @@ class TestCase extends \PHPUnit_Framework_TestCase
|
||||||
->getMock();
|
->getMock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getFrameMock()
|
||||||
|
{
|
||||||
|
return $this->getMockBuilder('FFMpeg\Media\Frame')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
}
|
||||||
|
|
||||||
public function getFFMpegDriverMock()
|
public function getFFMpegDriverMock()
|
||||||
{
|
{
|
||||||
return $this->getMockBuilder('FFMpeg\Driver\FFMpegDriver')
|
return $this->getMockBuilder('FFMpeg\Driver\FFMpegDriver')
|
||||||
|
|
@ -129,7 +136,7 @@ class TestCase extends \PHPUnit_Framework_TestCase
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$video->expects($this->any())
|
$video->expects($this->any())
|
||||||
->method('getFilename')
|
->method('getPathfile')
|
||||||
->will($this->returnValue($filename));
|
->will($this->returnValue($filename));
|
||||||
|
|
||||||
return $video;
|
return $video;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue