ffmpeg-mappable-media/tests/Unit/Format/Video/VideoTestCase.php
Ilya Chekalsky afffd627ff
Add ability to disable -b:v (#767)
* adds ability to disable -b:v

* Fixed a bug in the way the paths to the test files were defined in the AudioConcatenationTest.php file

* Added a test to make sure that a negative kilobit rate returns an exception

* Added a test to check that the -b:v options are not set if the kilo bitrate is set to 0

* Disable 2pass when -b:v is disabled

Co-Authored-By: Philipp Doblhofer <6283313+philipp-doblhofer@users.noreply.github.com>

* Changed the way we call the class FFMpeg\Exception\InvalidArgumentException in tests

* Changed the way we call the class FFMpeg\Exception\InvalidArgumentException in tests

* Updated the README to include this new option

Co-authored-by: Romain Biard <romain.biard@gmail.com>
Co-authored-by: Philipp Doblhofer <6283313+philipp-doblhofer@users.noreply.github.com>
2021-03-04 19:17:34 +01:00

90 lines
2.9 KiB
PHP

<?php
namespace Tests\FFMpeg\Unit\Format\Video;
use Tests\FFMpeg\Unit\Format\Audio\AudioTestCase;
abstract class VideoTestCase extends AudioTestCase
{
public function testGetVideoCodec()
{
$this->assertScalar($this->getFormat()->getVideoCodec());
$this->assertContains($this->getFormat()->getVideoCodec(), $this->getFormat()->getAvailableVideoCodecs());
}
public function testSupportBFrames()
{
$this->assertIsBool($this->getFormat()->supportBFrames());
}
public function testSetVideoCodec()
{
$format = $this->getFormat();
foreach ($format->getAvailableVideoCodecs() as $codec) {
$format->setVideoCodec($codec);
$this->assertEquals($codec, $format->getVideoCodec());
}
}
public function testGetKiloBitrate()
{
$this->assertIsInt($this->getFormat()->getKiloBitrate());
}
public function testSetKiloBitrate()
{
$format = $this->getFormat();
$format->setKiloBitrate(2560);
$this->assertEquals(2560, $format->getKiloBitrate());
}
public function testSetKiloBitrateBelowZero()
{
$this->expectException('FFMpeg\Exception\InvalidArgumentException');
$format = $this->getFormat();
$format->setKiloBitrate(-1);
}
public function testSetInvalidVideoCodec()
{
$this->expectException('FFMpeg\Exception\InvalidArgumentException');
$this->getFormat()->setVideoCodec('invalid-random-video-codec');
}
public function testGetAvailableVideoCodecs()
{
$this->assertGreaterThan(0, count($this->getFormat()->getAvailableVideoCodecs()));
}
public function testCreateProgressListener()
{
$media = $this->getMockBuilder('FFMpeg\Media\MediaTypeInterface')->getMock();
$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()
{
$this->assertIsInt($this->getFormat()->getPasses());
$this->assertGreaterThan(0, $this->getFormat()->getPasses());
}
public function testGetModulus()
{
$this->assertIsInt($this->getFormat()->getModulus());
$this->assertGreaterThan(0, $this->getFormat()->getModulus());
$this->assertEquals(0, $this->getFormat()->getModulus() % 2);
}
}