|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Tests\FFMpeg\Unit\Filters\Video; |
| 4 | + |
| 5 | +use FFMpeg\Filters\Video\PadFilter; |
| 6 | +use Tests\FFMpeg\Unit\TestCase; |
| 7 | +use FFMpeg\FFProbe\DataMapping\Stream; |
| 8 | +use FFMpeg\FFProbe\DataMapping\StreamCollection; |
| 9 | +use FFMpeg\Coordinate\Dimension; |
| 10 | + |
| 11 | +class PadFilterTest extends TestCase |
| 12 | +{ |
| 13 | + /** |
| 14 | + * @dataProvider provideDimensions |
| 15 | + */ |
| 16 | + public function testApply(Dimension $dimension, $width, $height, $expected) |
| 17 | + { |
| 18 | + $video = $this->getVideoMock(); |
| 19 | + $pathfile = '/path/to/file'.mt_rand(); |
| 20 | + |
| 21 | + $format = $this->createMock('FFMpeg\Format\VideoInterface'); |
| 22 | + |
| 23 | + $streams = new StreamCollection(array( |
| 24 | + new Stream(array( |
| 25 | + 'codec_type' => 'video', |
| 26 | + 'width' => $width, |
| 27 | + 'height' => $height, |
| 28 | + )) |
| 29 | + )); |
| 30 | + |
| 31 | + $filter = new PadFilter($dimension); |
| 32 | + $this->assertEquals($expected, $filter->apply($video, $format)); |
| 33 | + } |
| 34 | + |
| 35 | + public function provideDimensions() |
| 36 | + { |
| 37 | + return array( |
| 38 | + array(new Dimension(1000, 800), 640, 480, array('-vf', 'scale=iw*min(1000/iw\,800/ih):ih*min(1000/iw\,800/ih),pad=1000:800:(1000-iw)/2:(800-ih)/2')), |
| 39 | + array(new Dimension(300, 600), 640, 480, array('-vf', 'scale=iw*min(300/iw\,600/ih):ih*min(300/iw\,600/ih),pad=300:600:(300-iw)/2:(600-ih)/2')), |
| 40 | + array(new Dimension(100, 900), 640, 480, array('-vf', 'scale=iw*min(100/iw\,900/ih):ih*min(100/iw\,900/ih),pad=100:900:(100-iw)/2:(900-ih)/2')), |
| 41 | + array(new Dimension(1200, 200), 640, 480, array('-vf', 'scale=iw*min(1200/iw\,200/ih):ih*min(1200/iw\,200/ih),pad=1200:200:(1200-iw)/2:(200-ih)/2')), |
| 42 | + ); |
| 43 | + } |
| 44 | +} |
0 commit comments