Fix compatibility with avconv 0.9
This commit is contained in:
parent
fca866e1d8
commit
18abae55a9
4 changed files with 47 additions and 1 deletions
|
|
@ -10,12 +10,20 @@ Check another amazing repo : [PHP FFMpeg extras](https://github.com/alchemy-fr/P
|
||||||
|
|
||||||
## Your attention please
|
## Your attention please
|
||||||
|
|
||||||
|
### How this library works :
|
||||||
|
|
||||||
This library requires a working FFMpeg install. You will need both FFMpeg and FFProbe binaries to use it.
|
This library requires a working FFMpeg install. You will need both FFMpeg and FFProbe binaries to use it.
|
||||||
Be sure that these binaries can be located with system PATH to get the benefit of the binary detection,
|
Be sure that these binaries can be located with system PATH to get the benefit of the binary detection,
|
||||||
otherwise you should have to explicitely give the binaries path on load.
|
otherwise you should have to explicitely give the binaries path on load.
|
||||||
|
|
||||||
For Windows users : Please find the binaries at http://ffmpeg.zeranoe.com/builds/.
|
For Windows users : Please find the binaries at http://ffmpeg.zeranoe.com/builds/.
|
||||||
|
|
||||||
|
### Known issues :
|
||||||
|
|
||||||
|
- Using rotate and resize will produce a corrupted output when using
|
||||||
|
[libav](http://libav.org/) 0.8. The bug is fixed in version 9. This bug does not
|
||||||
|
appear in latest ffmpeg version.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
The recommended way to install PHP-FFMpeg is through [Composer](https://getcomposer.org).
|
The recommended way to install PHP-FFMpeg is through [Composer](https://getcomposer.org).
|
||||||
|
|
|
||||||
|
|
@ -226,8 +226,13 @@ class FFProbe
|
||||||
$parseIsToDo = false;
|
$parseIsToDo = false;
|
||||||
|
|
||||||
if ($allowJson && $this->optionsTester->has('-print_format')) {
|
if ($allowJson && $this->optionsTester->has('-print_format')) {
|
||||||
|
// allowed in latest PHP-FFmpeg version
|
||||||
$commands[] = '-print_format';
|
$commands[] = '-print_format';
|
||||||
$commands[] = 'json';
|
$commands[] = 'json';
|
||||||
|
} elseif ($allowJson && $this->optionsTester->has('-of')) {
|
||||||
|
// option has changed in avconv 9
|
||||||
|
$commands[] = '-of';
|
||||||
|
$commands[] = 'json';
|
||||||
} else {
|
} else {
|
||||||
$parseIsToDo = true;
|
$parseIsToDo = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@ use FFMpeg\FFMpeg;
|
||||||
|
|
||||||
abstract class FunctionalTestCase extends \PHPUnit_Framework_TestCase
|
abstract class FunctionalTestCase extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @return FFMpeg
|
||||||
|
*/
|
||||||
public function getFFMpeg()
|
public function getFFMpeg()
|
||||||
{
|
{
|
||||||
return FFMpeg::create(array('timeout' => 300));
|
return FFMpeg::create(array('timeout' => 300));
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,12 @@ class VideoTranscodeTest extends FunctionalTestCase
|
||||||
|
|
||||||
public function testTranscodePortraitVideo()
|
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';
|
$filename = __DIR__ . '/output/output-x264.mp4';
|
||||||
if (is_file($filename)) {
|
if (is_file($filename)) {
|
||||||
unlink(__DIR__ . '/output/output-x264.mp4');
|
unlink(__DIR__ . '/output/output-x264.mp4');
|
||||||
|
|
@ -85,4 +91,28 @@ class VideoTranscodeTest extends FunctionalTestCase
|
||||||
$this->assertFileExists($filename);
|
$this->assertFileExists($filename);
|
||||||
unlink($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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue