Fix compatibility with avconv 0.9

This commit is contained in:
Romain Neutron 2013-12-02 12:47:27 +01:00
commit 18abae55a9
4 changed files with 47 additions and 1 deletions

View file

@ -6,6 +6,9 @@ use FFMpeg\FFMpeg;
abstract class FunctionalTestCase extends \PHPUnit_Framework_TestCase
{
/**
* @return FFMpeg
*/
public function getFFMpeg()
{
return FFMpeg::create(array('timeout' => 300));

View file

@ -9,7 +9,7 @@ use FFMpeg\Format\Video\X264;
use FFMpeg\Media\Video;
class VideoTranscodeTest extends FunctionalTestCase
{
{
public function testSimpleTranscodeX264()
{
$filename = __DIR__ . '/output/output-x264.mp4';
@ -60,6 +60,12 @@ class VideoTranscodeTest extends FunctionalTestCase
public function testTranscodePortraitVideo()
{
$info = $this->getNameAndVersion();
if ($info['name'] === 'avconv' && version_compare($info['version'], '0.9', '<')) {
$this->markTestSkipped('This version of avconv is buggy and does not support this test.');
}
$filename = __DIR__ . '/output/output-x264.mp4';
if (is_file($filename)) {
unlink(__DIR__ . '/output/output-x264.mp4');
@ -85,4 +91,28 @@ class VideoTranscodeTest extends FunctionalTestCase
$this->assertFileExists($filename);
unlink($filename);
}
private function getNameAndVersion()
{
$binary = $this
->getFFMpeg()
->getFFMpegDriver()
->getProcessBuilderFactory()
->getBinary();
$output = $matches = null;
exec($binary . ' -version 2>&1', $output);
if (!isset($output[0])) {
return array('name' => null, 'version' => null);
}
preg_match('/^([a-z]+)\s+version\s+([0-9\.]+)/i', $output[0], $matches);
if (count($matches) > 0) {
return array('name' => $matches[1], 'version' => $matches[2]);
}
return array('name' => null, 'version' => null);
}
}