[BC] Upgraded dependencies, dropped support for anything below PHP 8.0. (#849)

* GitHub actions + style fixes + updated packages

* Fixed workflows dir

* Support for PHP 8.1 (#1)

* Update README.md

* Revert some changes from upstream
This commit is contained in:
Pascal Baljet 2022-02-09 14:32:43 +01:00 committed by GitHub
commit 111c153428
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
335 changed files with 4394 additions and 28116 deletions

View file

@ -0,0 +1,83 @@
<?php
namespace Tests\FFMpeg\Unit\Coordinate;
use FFMpeg\Coordinate\AspectRatio;
use FFMpeg\Coordinate\Dimension;
use Tests\FFMpeg\Unit\TestCase;
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 [
//AR_5_4
[720, 576, false, 5 / 4, 400, 192],
[720, 577, false, 5 / 4, 400, 192],
[720, 620, false, 720 / 620, 372, 206],
[720, 576, true, 5 / 4, 400, 192],
//AR_ROTATED_4_5
[576, 720, false, 4 / 5, 256, 300],
[576, 720, true, 4 / 5, 256, 300],
//AR_4_3
[320, 240, false, 4 / 3, 426, 180],
[320, 240, true, 4 / 3, 426, 180],
//AR_ROTATED_3_4
[240, 320, false, 3 / 4, 240, 320],
[240, 320, true, 3 / 4, 240, 320],
//AR_16_9
[1920, 1080, false, 16 / 9, 568, 136],
[1920, 1080, true, 16 / 9, 568, 136],
[1280, 720, false, 16 / 9, 568, 136],
[1280, 720, true, 16 / 9, 568, 136],
[3840, 2160, false, 16 / 9, 568, 136],
[3840, 2160, true, 16 / 9, 568, 136],
// modulus 4
[1920, 1080, false, 16 / 9, 568, 136, 4],
[1920, 1080, true, 16 / 9, 568, 136, 4],
[1280, 720, false, 16 / 9, 568, 136, 4],
[1280, 720, true, 16 / 9, 568, 136, 4],
[3840, 2160, false, 16 / 9, 568, 136, 4],
[3840, 2160, true, 16 / 9, 568, 136, 4],
// modulus 16
[1920, 1080, false, 16 / 9, 576, 128, 16],
[1920, 1080, true, 16 / 9, 576, 128, 16],
[1280, 720, false, 16 / 9, 576, 128, 16],
[1280, 720, true, 16 / 9, 576, 128, 16],
[3840, 2160, false, 16 / 9, 576, 128, 16],
[3840, 2160, true, 16 / 9, 576, 128, 16],
//AR_ROTATED_9_16
[1080, 1920, false, 9 / 16, 180, 426],
[1080, 1920, true, 9 / 16, 180, 426],
[720, 1280, false, 9 / 16, 180, 426],
[720, 1280, true, 9 / 16, 180, 426],
[2160, 3840, false, 9 / 16, 180, 426],
[2160, 3840, true, 9 / 16, 180, 426],
//AR_3_2
[360, 240, false, 3 / 2, 480, 160],
[360, 240, true, 3 / 2, 480, 160],
//AR_ROTATED_2_3
[240, 360, false, 2 / 3, 214, 360],
[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
];
}
}

View file

@ -0,0 +1,38 @@
<?php
namespace Tests\FFMpeg\Unit\Coordinate;
use FFMpeg\Coordinate\Dimension;
use Tests\FFMpeg\Unit\TestCase;
class DimensionTest extends TestCase
{
/**
* @dataProvider provideInvalidDimensions
*/
public function testInvalidDimensions($width, $height)
{
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
new Dimension($width, $height);
}
public function provideInvalidDimensions()
{
return [
[320, 0],
[320, -10],
[0, 240],
[-10, 240],
[0, 0],
[0, -10],
[-10, 0],
];
}
public function testGetters()
{
$dimension = new Dimension(320, 240);
$this->assertEquals(320, $dimension->getWidth());
$this->assertEquals(240, $dimension->getHeight());
}
}

View file

@ -0,0 +1,31 @@
<?php
namespace Tests\FFMpeg\Unit\Coordinate;
use FFMpeg\Coordinate\FrameRate;
use Tests\FFMpeg\Unit\TestCase;
class FrameRateTest extends TestCase
{
public function testGetter()
{
$fr = new FrameRate(23.997);
$this->assertEquals(23.997, $fr->getValue());
}
/**
* @dataProvider provideInvalidFrameRates
*/
public function testInvalidFrameRate($value)
{
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
new FrameRate($value);
}
public function provideInvalidFrameRates()
{
return [
[0], [-1.5], [-2],
];
}
}

View file

@ -0,0 +1,23 @@
<?php
namespace Tests\FFMpeg\Unit\Coordinate;
use FFMpeg\Coordinate\Point;
use Tests\FFMpeg\Unit\TestCase;
class PointTest extends TestCase
{
public function testGetters()
{
$point = new Point(4, 25);
$this->assertEquals(4, $point->getX());
$this->assertEquals(25, $point->getY());
}
public function testDynamicPointGetters()
{
$point = new Point('t*100', 't', true);
$this->assertEquals('t*100', $point->getX());
$this->assertEquals('t', $point->getY());
}
}

View file

@ -0,0 +1,58 @@
<?php
namespace Tests\FFMpeg\Unit\Coordinate;
use FFMpeg\Coordinate\TimeCode;
use Tests\FFMpeg\Unit\TestCase;
class TimeCodeTest extends TestCase
{
/**
* @dataProvider provideTimecodes
*/
public function testFromString($timecode, $expected)
{
$tc = TimeCode::fromString($timecode);
$this->assertEquals((string) $tc, $expected);
}
public function provideTimeCodes()
{
return [
['1:02:04:05:20', '26:04:05.20'],
['1:02:04:05.20', '26:04:05.20'],
['02:04:05:20', '02:04:05.20'],
['02:04:05.20', '02:04:05.20'],
['00:00:05.20', '00:00:05.20'],
['00:00:00.00', '00:00:00.00'],
];
}
public function testFromInvalidString()
{
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
TimeCode::fromString('lalali lala');
}
/**
* @dataProvider provideSeconds
*/
public function testFromSeconds($seconds, $expected)
{
$tc = TimeCode::fromSeconds($seconds);
$this->assertEquals($expected, (string) $tc);
}
public function provideSeconds()
{
return [
[0.467, '00:00:00.47'],
[12.467, '00:00:12.47'],
[59.867, '00:00:59.87'],
[72.467, '00:01:12.47'],
[3599.467, '00:59:59.47'],
[3600.467, '01:00:00.47'],
[86422.467, '24:00:22.47'],
];
}
}