Version 0.3
This commit is contained in:
parent
0d69145ec3
commit
ad3a5af623
130 changed files with 7283 additions and 2627 deletions
83
tests/FFMpeg/Tests/Coordinate/AspectRatioTest.php
Normal file
83
tests/FFMpeg/Tests/Coordinate/AspectRatioTest.php
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
namespace FFMpeg\Tests\Coordinate;
|
||||
|
||||
use FFMpeg\Coordinate\Dimension;
|
||||
use FFMpeg\Tests\TestCase;
|
||||
use FFMpeg\Coordinate\AspectRatio;
|
||||
|
||||
class AspectRatioTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideDimensionsAndExpectedratio
|
||||
*/
|
||||
public function testFromDimensions($width, $height, $strategy, $expected, $calculatedWidth, $calculatedHeight, $modulus = 2)
|
||||
{
|
||||
$ratio = AspectRatio::create(new Dimension($width, $height), $strategy);
|
||||
$this->assertEquals($expected, $ratio->getValue());
|
||||
|
||||
$this->assertEquals($calculatedHeight, $ratio->calculateHeight(240, $modulus));
|
||||
$this->assertEquals($calculatedWidth, $ratio->calculateWidth(320, $modulus));
|
||||
}
|
||||
|
||||
public function provideDimensionsAndExpectedratio()
|
||||
{
|
||||
return array(
|
||||
//AR_5_4
|
||||
array(720, 576, false, 5/4, 400, 192),
|
||||
array(720, 577, false, 5/4, 400, 192),
|
||||
array(720, 620, false, 720/620, 372, 206),
|
||||
array(720, 576, true, 5/4, 400, 192),
|
||||
//AR_ROTATED_4_5
|
||||
array(576, 720, false, 4/5, 256, 300),
|
||||
array(576, 720, true, 4/5, 256, 300),
|
||||
//AR_4_3
|
||||
array(320, 240, false, 4/3, 426, 180),
|
||||
array(320, 240, true, 4/3, 426, 180),
|
||||
//AR_ROTATED_3_4
|
||||
array(240, 320, false, 3/4, 240, 320),
|
||||
array(240, 320, true, 3/4, 240, 320),
|
||||
//AR_16_9
|
||||
array(1920, 1080, false, 16/9, 568, 136),
|
||||
array(1920, 1080, true, 16/9, 568, 136),
|
||||
array(1280, 720, false, 16/9, 568, 136),
|
||||
array(1280, 720, true, 16/9, 568, 136),
|
||||
array(3840, 2160, false, 16/9, 568, 136),
|
||||
array(3840, 2160, true, 16/9, 568, 136),
|
||||
// modulus 4
|
||||
array(1920, 1080, false, 16/9, 568, 136, 4),
|
||||
array(1920, 1080, true, 16/9, 568, 136, 4),
|
||||
array(1280, 720, false, 16/9, 568, 136, 4),
|
||||
array(1280, 720, true, 16/9, 568, 136, 4),
|
||||
array(3840, 2160, false, 16/9, 568, 136, 4),
|
||||
array(3840, 2160, true, 16/9, 568, 136, 4),
|
||||
// modulus 16
|
||||
array(1920, 1080, false, 16/9, 576, 128, 16),
|
||||
array(1920, 1080, true, 16/9, 576, 128, 16),
|
||||
array(1280, 720, false, 16/9, 576, 128, 16),
|
||||
array(1280, 720, true, 16/9, 576, 128, 16),
|
||||
array(3840, 2160, false, 16/9, 576, 128, 16),
|
||||
array(3840, 2160, true, 16/9, 576, 128, 16),
|
||||
//AR_ROTATED_9_16
|
||||
array(1080, 1920, false, 9/16, 180, 426),
|
||||
array(1080, 1920, true, 9/16, 180, 426),
|
||||
array(720, 1280, false, 9/16, 180, 426),
|
||||
array(720, 1280, true, 9/16, 180, 426),
|
||||
array(2160, 3840, false, 9/16, 180, 426),
|
||||
array(2160, 3840, true, 9/16, 180, 426),
|
||||
//AR_3_2
|
||||
array(360, 240, false, 3/2, 480, 160),
|
||||
array(360, 240, true, 3/2, 480, 160),
|
||||
//AR_ROTATED_2_3
|
||||
array(240, 360, false, 2/3, 214, 360),
|
||||
array(240, 360, true, 2/3, 214, 360),
|
||||
//AR_5_3
|
||||
//AR_ROTATED_3_5
|
||||
//AR_1_1
|
||||
//AR_1_DOT_85_1
|
||||
//AR_ROTATED_1_DOT_85
|
||||
//AR_2_DOT_39_1
|
||||
//AR_ROTATED_2_DOT_39
|
||||
);
|
||||
}
|
||||
}
|
||||
38
tests/FFMpeg/Tests/Coordinate/DimensionTest.php
Normal file
38
tests/FFMpeg/Tests/Coordinate/DimensionTest.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace FFMpeg\Tests\Coordinate;
|
||||
|
||||
use FFMpeg\Tests\TestCase;
|
||||
use FFMpeg\Coordinate\Dimension;
|
||||
|
||||
class DimensionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideInvalidDimensions
|
||||
* @expectedException FFMpeg\Exception\InvalidArgumentException
|
||||
*/
|
||||
public function testInvalidDimensions($width, $height)
|
||||
{
|
||||
new Dimension($width, $height);
|
||||
}
|
||||
|
||||
public function provideInvalidDimensions()
|
||||
{
|
||||
return array(
|
||||
array(320, 0),
|
||||
array(320, -10),
|
||||
array(0, 240),
|
||||
array(-10, 240),
|
||||
array(0, 0),
|
||||
array(0, -10),
|
||||
array(-10, 0),
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetters()
|
||||
{
|
||||
$dimension = new Dimension(320, 240);
|
||||
$this->assertEquals(320, $dimension->getWidth());
|
||||
$this->assertEquals(240, $dimension->getHeight());
|
||||
}
|
||||
}
|
||||
31
tests/FFMpeg/Tests/Coordinate/FrameRateTest.php
Normal file
31
tests/FFMpeg/Tests/Coordinate/FrameRateTest.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace FFMpeg\Tests\Coordinate;
|
||||
|
||||
use FFMpeg\Tests\TestCase;
|
||||
use FFMpeg\Coordinate\FrameRate;
|
||||
|
||||
class FrameRateTest extends TestCase
|
||||
{
|
||||
public function testGetter()
|
||||
{
|
||||
$fr = new FrameRate(23.997);
|
||||
$this->assertEquals(23.997, $fr->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideInvalidFrameRates
|
||||
* @expectedException FFMpeg\Exception\InvalidArgumentException
|
||||
*/
|
||||
public function testInvalidFrameRate($value)
|
||||
{
|
||||
new FrameRate($value);
|
||||
}
|
||||
|
||||
public function provideInvalidFrameRates()
|
||||
{
|
||||
return array(
|
||||
array(0), array(-1.5), array(-2),
|
||||
);
|
||||
}
|
||||
}
|
||||
16
tests/FFMpeg/Tests/Coordinate/PointTest.php
Normal file
16
tests/FFMpeg/Tests/Coordinate/PointTest.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace FFMpeg\Tests\Coordinate;
|
||||
|
||||
use FFMpeg\Tests\TestCase;
|
||||
use FFMpeg\Coordinate\Point;
|
||||
|
||||
class PointTest extends TestCase
|
||||
{
|
||||
public function testGetters()
|
||||
{
|
||||
$point = new Point(4, 25);
|
||||
$this->assertEquals(4, $point->getX());
|
||||
$this->assertEquals(25, $point->getY());
|
||||
}
|
||||
}
|
||||
38
tests/FFMpeg/Tests/Coordinate/TimeCodeTest.php
Normal file
38
tests/FFMpeg/Tests/Coordinate/TimeCodeTest.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace FFMpeg\Tests\Coordinate;
|
||||
|
||||
use FFMpeg\Tests\TestCase;
|
||||
use FFMpeg\Coordinate\TimeCode;
|
||||
|
||||
class TimeCodeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTimecodes
|
||||
*/
|
||||
public function testFromString($timecode, $expected)
|
||||
{
|
||||
$tc = TimeCode::fromString($timecode);
|
||||
$this->assertEquals((string) $tc, $expected);
|
||||
}
|
||||
|
||||
public function provideTimeCodes()
|
||||
{
|
||||
return array(
|
||||
array('1:02:04:05:20', '26:04:05.20'),
|
||||
array('1:02:04:05.20', '26:04:05.20'),
|
||||
array('02:04:05:20', '02:04:05.20'),
|
||||
array('02:04:05.20', '02:04:05.20'),
|
||||
array('00:00:05.20', '00:00:05.20'),
|
||||
array('00:00:00.00', '00:00:00.00'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException FFMpeg\Exception\InvalidArgumentException
|
||||
*/
|
||||
public function testFromInvalidString()
|
||||
{
|
||||
TimeCode::fromString('lalali lala');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue