2013-06-25 10:03:20 +02:00
|
|
|
<?php
|
|
|
|
|
|
2016-03-06 23:38:04 +01:00
|
|
|
namespace Tests\FFMpeg\Unit\Format\Video;
|
2013-06-25 10:03:20 +02:00
|
|
|
|
2016-03-06 23:38:04 +01:00
|
|
|
use Tests\FFMpeg\Unit\Format\Audio\AudioTestCase;
|
2013-06-25 10:03:20 +02:00
|
|
|
|
|
|
|
|
abstract class VideoTestCase extends AudioTestCase
|
|
|
|
|
{
|
|
|
|
|
public function testGetVideoCodec()
|
|
|
|
|
{
|
|
|
|
|
$this->assertScalar($this->getFormat()->getVideoCodec());
|
|
|
|
|
$this->assertContains($this->getFormat()->getVideoCodec(), $this->getFormat()->getAvailableVideoCodecs());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSupportBFrames()
|
|
|
|
|
{
|
2020-02-13 00:39:31 +01:00
|
|
|
$this->assertIsBool($this->getFormat()->supportBFrames());
|
2013-06-25 10:03:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSetVideoCodec()
|
|
|
|
|
{
|
|
|
|
|
$format = $this->getFormat();
|
|
|
|
|
|
|
|
|
|
foreach ($format->getAvailableVideoCodecs() as $codec) {
|
|
|
|
|
$format->setVideoCodec($codec);
|
|
|
|
|
$this->assertEquals($codec, $format->getVideoCodec());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetKiloBitrate()
|
|
|
|
|
{
|
2020-02-13 00:39:31 +01:00
|
|
|
$this->assertIsInt($this->getFormat()->getKiloBitrate());
|
2013-06-25 10:03:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSetKiloBitrate()
|
|
|
|
|
{
|
|
|
|
|
$format = $this->getFormat();
|
|
|
|
|
$format->setKiloBitrate(2560);
|
|
|
|
|
$this->assertEquals(2560, $format->getKiloBitrate());
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-04 19:17:34 +01:00
|
|
|
public function testSetKiloBitrateBelowZero()
|
|
|
|
|
{
|
|
|
|
|
$this->expectException('FFMpeg\Exception\InvalidArgumentException');
|
|
|
|
|
$format = $this->getFormat();
|
|
|
|
|
$format->setKiloBitrate(-1);
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-25 10:03:20 +02:00
|
|
|
public function testSetInvalidVideoCodec()
|
|
|
|
|
{
|
2021-03-04 19:17:34 +01:00
|
|
|
$this->expectException('FFMpeg\Exception\InvalidArgumentException');
|
2013-06-25 10:03:20 +02:00
|
|
|
$this->getFormat()->setVideoCodec('invalid-random-video-codec');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetAvailableVideoCodecs()
|
|
|
|
|
{
|
|
|
|
|
$this->assertGreaterThan(0, count($this->getFormat()->getAvailableVideoCodecs()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testCreateProgressListener()
|
|
|
|
|
{
|
2020-02-13 00:23:11 +01:00
|
|
|
$media = $this->getMockBuilder('FFMpeg\Media\MediaTypeInterface')->getMock();
|
2013-06-25 10:03:20 +02:00
|
|
|
$media->expects($this->any())
|
|
|
|
|
->method('getPathfile')
|
|
|
|
|
->will($this->returnValue(__FILE__));
|
|
|
|
|
$format = $this->getFormat();
|
|
|
|
|
$ffprobe = $this->getFFProbeMock();
|
|
|
|
|
|
|
|
|
|
foreach ($format->createProgressListener($media, $ffprobe, 1, 3) as $listener) {
|
|
|
|
|
$this->assertInstanceOf('FFMpeg\Format\ProgressListener\VideoProgressListener', $listener);
|
|
|
|
|
$this->assertSame($ffprobe, $listener->getFFProbe());
|
|
|
|
|
$this->assertSame(__FILE__, $listener->getPathfile());
|
|
|
|
|
$this->assertSame(1, $listener->getCurrentPass());
|
|
|
|
|
$this->assertSame(3, $listener->getTotalPass());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetPasses()
|
|
|
|
|
{
|
2020-02-13 00:39:31 +01:00
|
|
|
$this->assertIsInt($this->getFormat()->getPasses());
|
2013-06-25 10:03:20 +02:00
|
|
|
$this->assertGreaterThan(0, $this->getFormat()->getPasses());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetModulus()
|
|
|
|
|
{
|
2020-02-13 00:39:31 +01:00
|
|
|
$this->assertIsInt($this->getFormat()->getModulus());
|
2013-06-25 10:03:20 +02:00
|
|
|
$this->assertGreaterThan(0, $this->getFormat()->getModulus());
|
|
|
|
|
$this->assertEquals(0, $this->getFormat()->getModulus() % 2);
|
|
|
|
|
}
|
|
|
|
|
}
|