ffmpeg-mappable-media/tests/src/FFMpeg/FFMpegTest.php

135 lines
2.9 KiB
PHP
Raw Normal View History

2012-04-13 10:20:54 +02:00
<?php
namespace FFMpeg;
class FFMpegTest extends \PHPUnit_Framework_TestCase
{
/**
* @var FFMpeg
*/
protected $object;
2012-04-13 11:01:01 +02:00
/**
* @var FFProbe
*/
protected $probe;
public function setUp()
{
$this->object = FFMpeg::load();
$this->probe = FFProbe::load();
}
/**
* @covers FFMpeg\FFMpeg::open
* @expectedException \InvalidArgumentException
*/
public function testOpenInvalid()
{
$this->object->open(__DIR__ . '/invalid.files');
}
2012-04-13 10:20:54 +02:00
/**
* @covers FFMpeg\FFMpeg::open
*/
public function testOpen()
{
2012-04-13 11:01:01 +02:00
$this->object->open(__DIR__ . '/../../files/Test.ogv');
2012-04-13 10:20:54 +02:00
}
/**
* @covers FFMpeg\FFMpeg::extractImage
*/
public function testExtractImage()
{
2012-04-13 11:01:01 +02:00
$dest = __DIR__ . '/../../files/extract_Test.jpg';
$this->object->open(__DIR__ . '/../../files/Test.ogv');
$this->object->extractImage(2, $dest, 200, 200);
$this->probe->probeFormat($dest);
unlink($dest);
}
/**
* @covers FFMpeg\FFMpeg::extractImage
* @expectedException \RuntimeException
*/
public function testExtractImageNoMovie()
{
$this->object->extractImage(2, 'Path', 200, 200);
2012-04-13 10:20:54 +02:00
}
/**
* @covers FFMpeg\FFMpeg::encode
2012-04-13 11:01:01 +02:00
* @expectedException \RuntimeException
2012-04-13 10:20:54 +02:00
*/
2012-04-13 11:01:01 +02:00
public function testEncode()
2012-04-13 10:20:54 +02:00
{
2012-04-13 11:01:01 +02:00
$this->object->encode(new Format\WebM(32, 32), './invalid.file');
}
2012-04-13 10:20:54 +02:00
2012-04-13 11:01:01 +02:00
/**
* @covers FFMpeg\FFMpeg::encode
* @expectedException \RuntimeException
*/
public function testWrongBinary()
{
$logger = new \Monolog\Logger('test');
$logger->pushHandler(new \Monolog\Handler\NullHandler());
2012-04-13 10:20:54 +02:00
2012-04-13 11:01:01 +02:00
$ffmpeg = new FFMpeg('wrongbinary', $logger);
2012-04-13 10:20:54 +02:00
$ffmpeg->open(__DIR__ . '/../../files/Test.ogv');
2012-04-13 11:01:01 +02:00
$ffmpeg->encode(new Format\WebM(32, 32), './invalid.file');
}
/**
* @covers FFMpeg\FFMpeg::encode
*/
public function testEncodeWebm()
{
$dest = __DIR__ . '/../../files/encode_test.webm';
$this->object->open(__DIR__ . '/../../files/Test.ogv');
$this->object->encode(new Format\WebM(32, 32), $dest);
2012-04-13 10:20:54 +02:00
2012-04-13 11:01:01 +02:00
$this->probe->probeFormat($dest);
2012-04-13 10:20:54 +02:00
unlink($dest);
}
/**
* @covers FFMpeg\FFMpeg::encode
*/
public function testEncodeOgg()
{
$dest = __DIR__ . '/../../files/encode_test.ogv';
2012-04-13 11:01:01 +02:00
$this->object->open(__DIR__ . '/../../files/Test.ogv');
$this->object->encode(new Format\Ogg(32, 32), $dest);
2012-04-13 10:20:54 +02:00
2012-04-13 11:01:01 +02:00
$this->probe->probeFormat($dest);
2012-04-13 10:20:54 +02:00
unlink($dest);
}
/**
* @covers FFMpeg\FFMpeg::encode
*/
public function testEncodeX264()
{
$dest = __DIR__ . '/../../files/encode_test.mp4';
2012-04-13 11:01:01 +02:00
$this->object->open(__DIR__ . '/../../files/Test.ogv');
$this->object->encode(new Format\X264(32, 32), $dest);
2012-04-13 10:20:54 +02:00
2012-04-13 11:01:01 +02:00
$this->probe->probeFormat($dest);
2012-04-13 10:20:54 +02:00
unlink($dest);
}
}