[BC] Upgraded dependencies, dropped support for anything below PHP 8.0. (#849)
* GitHub actions + style fixes + updated packages * Fixed workflows dir * Support for PHP 8.1 (#1) * Update README.md * Revert some changes from upstream
This commit is contained in:
parent
72c946dc7d
commit
111c153428
335 changed files with 4394 additions and 28116 deletions
300
tests/Alchemy/BinaryDriver/AbstractBinaryTest.php
Normal file
300
tests/Alchemy/BinaryDriver/AbstractBinaryTest.php
Normal file
|
|
@ -0,0 +1,300 @@
|
|||
<?php
|
||||
|
||||
namespace Alchemy\Tests\BinaryDriver;
|
||||
|
||||
use Alchemy\BinaryDriver\AbstractBinary;
|
||||
use Alchemy\BinaryDriver\BinaryDriverTestCase;
|
||||
use Alchemy\BinaryDriver\Configuration;
|
||||
use Alchemy\BinaryDriver\Exception\ExecutableNotFoundException;
|
||||
use Alchemy\BinaryDriver\Listeners\ListenerInterface;
|
||||
use Symfony\Component\Process\ExecutableFinder;
|
||||
|
||||
class AbstractBinaryTest extends BinaryDriverTestCase
|
||||
{
|
||||
protected function getPhpBinary()
|
||||
{
|
||||
$finder = new ExecutableFinder();
|
||||
$php = $finder->find('php');
|
||||
|
||||
if (null === $php) {
|
||||
$this->markTestSkipped('Unable to find a php binary');
|
||||
}
|
||||
|
||||
return $php;
|
||||
}
|
||||
|
||||
public function testSimpleLoadWithBinaryPath()
|
||||
{
|
||||
$php = $this->getPhpBinary();
|
||||
$imp = Implementation::load($php);
|
||||
$this->assertInstanceOf('Alchemy\Tests\BinaryDriver\Implementation', $imp);
|
||||
|
||||
$this->assertEquals($php, $imp->getProcessBuilderFactory()->getBinary());
|
||||
}
|
||||
|
||||
public function testMultipleLoadWithBinaryPath()
|
||||
{
|
||||
$php = $this->getPhpBinary();
|
||||
$imp = Implementation::load(['/zz/path/to/unexisting/command', $php]);
|
||||
$this->assertInstanceOf('Alchemy\Tests\BinaryDriver\Implementation', $imp);
|
||||
|
||||
$this->assertEquals($php, $imp->getProcessBuilderFactory()->getBinary());
|
||||
}
|
||||
|
||||
public function testSimpleLoadWithBinaryName()
|
||||
{
|
||||
$php = $this->getPhpBinary();
|
||||
$imp = Implementation::load('php');
|
||||
$this->assertInstanceOf('Alchemy\Tests\BinaryDriver\Implementation', $imp);
|
||||
|
||||
$this->assertEquals($php, $imp->getProcessBuilderFactory()->getBinary());
|
||||
}
|
||||
|
||||
public function testMultipleLoadWithBinaryName()
|
||||
{
|
||||
$php = $this->getPhpBinary();
|
||||
$imp = Implementation::load(['bachibouzouk', 'php']);
|
||||
$this->assertInstanceOf('Alchemy\Tests\BinaryDriver\Implementation', $imp);
|
||||
|
||||
$this->assertEquals($php, $imp->getProcessBuilderFactory()->getBinary());
|
||||
}
|
||||
|
||||
public function testLoadWithMultiplePathExpectingAFailure()
|
||||
{
|
||||
$this->expectException(ExecutableNotFoundException::class);
|
||||
|
||||
Implementation::load(['bachibouzouk', 'moribon']);
|
||||
}
|
||||
|
||||
public function testLoadWithUniquePathExpectingAFailure()
|
||||
{
|
||||
$this->expectException(ExecutableNotFoundException::class);
|
||||
|
||||
Implementation::load('bachibouzouk');
|
||||
}
|
||||
|
||||
public function testLoadWithCustomLogger()
|
||||
{
|
||||
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
|
||||
$imp = Implementation::load('php', $logger);
|
||||
|
||||
$this->assertEquals($logger, $imp->getProcessRunner()->getLogger());
|
||||
}
|
||||
|
||||
public function testLoadWithCustomConfigurationAsArray()
|
||||
{
|
||||
$conf = ['timeout' => 200];
|
||||
$imp = Implementation::load('php', null, $conf);
|
||||
|
||||
$this->assertEquals($conf, $imp->getConfiguration()->all());
|
||||
}
|
||||
|
||||
public function testLoadWithCustomConfigurationAsObject()
|
||||
{
|
||||
$conf = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock();
|
||||
$imp = Implementation::load('php', null, $conf);
|
||||
|
||||
$this->assertEquals($conf, $imp->getConfiguration());
|
||||
}
|
||||
|
||||
public function testProcessBuilderFactoryGetterAndSetters()
|
||||
{
|
||||
$imp = Implementation::load('php');
|
||||
$factory = $this->getMockBuilder('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface')->getMock();
|
||||
|
||||
$imp->setProcessBuilderFactory($factory);
|
||||
$this->assertEquals($factory, $imp->getProcessBuilderFactory());
|
||||
}
|
||||
|
||||
public function testConfigurationGetterAndSetters()
|
||||
{
|
||||
$imp = Implementation::load('php');
|
||||
$conf = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock();
|
||||
|
||||
$imp->setConfiguration($conf);
|
||||
$this->assertEquals($conf, $imp->getConfiguration());
|
||||
}
|
||||
|
||||
public function testTimeoutIsSetOnConstruction()
|
||||
{
|
||||
$imp = Implementation::load('php', null, ['timeout' => 42]);
|
||||
$this->assertEquals(42, $imp->getProcessBuilderFactory()->getTimeout());
|
||||
}
|
||||
|
||||
public function testTimeoutIsSetOnConfigurationSetting()
|
||||
{
|
||||
$imp = Implementation::load('php', null);
|
||||
$imp->setConfiguration(new Configuration(['timeout' => 42]));
|
||||
$this->assertEquals(42, $imp->getProcessBuilderFactory()->getTimeout());
|
||||
}
|
||||
|
||||
public function testTimeoutIsSetOnProcessBuilderSetting()
|
||||
{
|
||||
$imp = Implementation::load('php', null, ['timeout' => 42]);
|
||||
|
||||
$factory = $this->getMockBuilder('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface')->getMock();
|
||||
$factory->expects($this->once())
|
||||
->method('setTimeout')
|
||||
->with(42);
|
||||
|
||||
$imp->setProcessBuilderFactory($factory);
|
||||
}
|
||||
|
||||
public function testListenRegistersAListener()
|
||||
{
|
||||
$imp = Implementation::load('php');
|
||||
|
||||
$listeners = $this->getMockBuilder('Alchemy\BinaryDriver\Listeners\Listeners')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$listener = $this->getMockBuilder('Alchemy\BinaryDriver\Listeners\ListenerInterface')->getMock();
|
||||
|
||||
$listeners->expects($this->once())
|
||||
->method('register')
|
||||
->with($this->equalTo($listener), $this->equalTo($imp));
|
||||
|
||||
$reflexion = new \ReflectionClass('Alchemy\BinaryDriver\AbstractBinary');
|
||||
$prop = $reflexion->getProperty('listenersManager');
|
||||
$prop->setAccessible(true);
|
||||
$prop->setValue($imp, $listeners);
|
||||
|
||||
$imp->listen($listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideCommandParameters
|
||||
*/
|
||||
public function testCommandRunsAProcess($parameters, $bypassErrors, $expectedParameters, $output)
|
||||
{
|
||||
$imp = Implementation::load('php');
|
||||
$factory = $this->getMockBuilder('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface')->getMock();
|
||||
$processRunner = $this->getMockBuilder('Alchemy\BinaryDriver\ProcessRunnerInterface')->getMock();
|
||||
|
||||
$process = $this->getMockBuilder('Symfony\Component\Process\Process')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$processRunner->expects($this->once())
|
||||
->method('run')
|
||||
->with($this->equalTo($process), $this->isInstanceOf('SplObjectStorage'), $this->equalTo($bypassErrors))
|
||||
->will($this->returnValue($output));
|
||||
|
||||
$factory->expects($this->once())
|
||||
->method('create')
|
||||
->with($expectedParameters)
|
||||
->will($this->returnValue($process));
|
||||
|
||||
$imp->setProcessBuilderFactory($factory);
|
||||
$imp->setProcessRunner($processRunner);
|
||||
|
||||
$this->assertEquals($output, $imp->command($parameters, $bypassErrors));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideCommandWithListenersParameters
|
||||
*/
|
||||
public function testCommandWithTemporaryListeners($parameters, $bypassErrors, $expectedParameters, $output, $count, $listeners)
|
||||
{
|
||||
$imp = Implementation::load('php');
|
||||
$factory = $this->getMockBuilder('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface')->getMock();
|
||||
$processRunner = $this->getMockBuilder('Alchemy\BinaryDriver\ProcessRunnerInterface')->getMock();
|
||||
|
||||
$process = $this->getMockBuilder('Symfony\Component\Process\Process')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$firstStorage = $secondStorage = null;
|
||||
|
||||
$processRunner->expects($this->exactly(2))
|
||||
->method('run')
|
||||
->with($this->equalTo($process), $this->isInstanceOf('SplObjectStorage'), $this->equalTo($bypassErrors))
|
||||
->will($this->returnCallback(function ($process, $storage, $errors) use ($output, &$firstStorage, &$secondStorage) {
|
||||
if (null === $firstStorage) {
|
||||
$firstStorage = $storage;
|
||||
} else {
|
||||
$secondStorage = $storage;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}));
|
||||
|
||||
$factory->expects($this->exactly(2))
|
||||
->method('create')
|
||||
->with($expectedParameters)
|
||||
->will($this->returnValue($process));
|
||||
|
||||
$imp->setProcessBuilderFactory($factory);
|
||||
$imp->setProcessRunner($processRunner);
|
||||
|
||||
$this->assertEquals($output, $imp->command($parameters, $bypassErrors, $listeners));
|
||||
$this->assertCount($count, $firstStorage);
|
||||
$this->assertEquals($output, $imp->command($parameters, $bypassErrors));
|
||||
$this->assertCount(0, $secondStorage);
|
||||
}
|
||||
|
||||
public function provideCommandWithListenersParameters()
|
||||
{
|
||||
return [
|
||||
['-a', false, ['-a'], 'loubda', 2, [$this->getMockListener(), $this->getMockListener()]],
|
||||
['-a', false, ['-a'], 'loubda', 1, [$this->getMockListener()]],
|
||||
['-a', false, ['-a'], 'loubda', 1, $this->getMockListener()],
|
||||
['-a', false, ['-a'], 'loubda', 0, []],
|
||||
];
|
||||
}
|
||||
|
||||
public function provideCommandParameters()
|
||||
{
|
||||
return [
|
||||
['-a', false, ['-a'], 'loubda'],
|
||||
['-a', true, ['-a'], 'loubda'],
|
||||
['-a -b', false, ['-a -b'], 'loubda'],
|
||||
[['-a'], false, ['-a'], 'loubda'],
|
||||
[['-a'], true, ['-a'], 'loubda'],
|
||||
[['-a', '-b'], false, ['-a', '-b'], 'loubda'],
|
||||
];
|
||||
}
|
||||
|
||||
public function testUnlistenUnregistersAListener()
|
||||
{
|
||||
$imp = Implementation::load('php');
|
||||
|
||||
$listeners = $this->getMockBuilder('Alchemy\BinaryDriver\Listeners\Listeners')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$listener = $this->getMockBuilder('Alchemy\BinaryDriver\Listeners\ListenerInterface')->getMock();
|
||||
|
||||
$listeners->expects($this->once())
|
||||
->method('unregister')
|
||||
->with($this->equalTo($listener), $this->equalTo($imp));
|
||||
|
||||
$reflexion = new \ReflectionClass('Alchemy\BinaryDriver\AbstractBinary');
|
||||
$prop = $reflexion->getProperty('listenersManager');
|
||||
$prop->setAccessible(true);
|
||||
$prop->setValue($imp, $listeners);
|
||||
|
||||
$imp->unlisten($listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
private function getMockListener()
|
||||
{
|
||||
$listener = $this->getMockBuilder(ListenerInterface::class)->getMock();
|
||||
$listener->expects($this->any())
|
||||
->method('forwardedEvents')
|
||||
->willReturn([]);
|
||||
|
||||
return $listener;
|
||||
}
|
||||
}
|
||||
|
||||
class Implementation extends AbstractBinary
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'Implementation';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
|
||||
namespace Alchemy\Tests\BinaryDriver;
|
||||
|
||||
use Alchemy\BinaryDriver\Exception\InvalidArgumentException;
|
||||
use Alchemy\BinaryDriver\ProcessBuilderFactory;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Process\ExecutableFinder;
|
||||
|
||||
abstract class AbstractProcessBuilderFactoryTest extends TestCase
|
||||
{
|
||||
public static $phpBinary;
|
||||
|
||||
private $original;
|
||||
/**
|
||||
* @return ProcessBuilderFactory
|
||||
*/
|
||||
abstract protected function getProcessBuilderFactory($binary);
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
ProcessBuilderFactory::$emulateSfLTS = null;
|
||||
if (null === static::$phpBinary) {
|
||||
$this->markTestSkipped('Unable to detect php binary, skipping');
|
||||
}
|
||||
}
|
||||
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
$finder = new ExecutableFinder();
|
||||
static::$phpBinary = $finder->find('php');
|
||||
}
|
||||
|
||||
public function testThatBinaryIsSetOnConstruction()
|
||||
{
|
||||
$factory = $this->getProcessBuilderFactory(static::$phpBinary);
|
||||
$this->assertEquals(static::$phpBinary, $factory->getBinary());
|
||||
}
|
||||
|
||||
public function testGetSetBinary()
|
||||
{
|
||||
$finder = new ExecutableFinder();
|
||||
$phpUnit = $finder->find('phpunit');
|
||||
|
||||
if (null === $phpUnit) {
|
||||
$this->markTestSkipped('Unable to detect phpunit binary, skipping');
|
||||
}
|
||||
|
||||
$factory = $this->getProcessBuilderFactory(static::$phpBinary);
|
||||
$factory->useBinary($phpUnit);
|
||||
$this->assertEquals($phpUnit, $factory->getBinary());
|
||||
}
|
||||
|
||||
public function testUseNonExistantBinary()
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
|
||||
$factory = $this->getProcessBuilderFactory(static::$phpBinary);
|
||||
$factory->useBinary('itissureitdoesnotexist');
|
||||
}
|
||||
|
||||
public function testCreateShouldReturnAProcess()
|
||||
{
|
||||
$factory = $this->getProcessBuilderFactory(static::$phpBinary);
|
||||
$process = $factory->create();
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\Process\Process', $process);
|
||||
$this->assertEquals("'" . static::$phpBinary . "'", $process->getCommandLine());
|
||||
}
|
||||
|
||||
public function testCreateWithStringArgument()
|
||||
{
|
||||
$factory = $this->getProcessBuilderFactory(static::$phpBinary);
|
||||
$process = $factory->create('-v');
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\Process\Process', $process);
|
||||
$this->assertEquals("'" . static::$phpBinary . "' '-v'", $process->getCommandLine());
|
||||
}
|
||||
|
||||
public function testCreateWithArrayArgument()
|
||||
{
|
||||
$factory = $this->getProcessBuilderFactory(static::$phpBinary);
|
||||
$process = $factory->create(['-r', 'echo "Hello !";']);
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\Process\Process', $process);
|
||||
$this->assertEquals("'" . static::$phpBinary . "' '-r' 'echo \"Hello !\";'", $process->getCommandLine());
|
||||
}
|
||||
|
||||
public function testCreateWithTimeout()
|
||||
{
|
||||
$factory = $this->getProcessBuilderFactory(static::$phpBinary);
|
||||
$factory->setTimeout(200);
|
||||
$process = $factory->create(['-i']);
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\Process\Process', $process);
|
||||
$this->assertEquals(200, $process->getTimeout());
|
||||
}
|
||||
}
|
||||
78
tests/Alchemy/BinaryDriver/ConfigurationTest.php
Normal file
78
tests/Alchemy/BinaryDriver/ConfigurationTest.php
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
namespace Alchemy\Tests\BinaryDriver;
|
||||
|
||||
use Alchemy\BinaryDriver\Configuration;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ConfigurationTest extends TestCase
|
||||
{
|
||||
public function testArrayAccessImplementation()
|
||||
{
|
||||
$configuration = new Configuration(['key' => 'value']);
|
||||
|
||||
$this->assertTrue(isset($configuration['key']));
|
||||
$this->assertEquals('value', $configuration['key']);
|
||||
|
||||
$this->assertFalse(isset($configuration['key2']));
|
||||
unset($configuration['key']);
|
||||
$this->assertFalse(isset($configuration['key']));
|
||||
|
||||
$configuration['key2'] = 'value2';
|
||||
$this->assertTrue(isset($configuration['key2']));
|
||||
$this->assertEquals('value2', $configuration['key2']);
|
||||
}
|
||||
|
||||
public function testGetOnNonExistentKeyShouldReturnDefaultValue()
|
||||
{
|
||||
$conf = new Configuration();
|
||||
$this->assertEquals('booba', $conf->get('hooba', 'booba'));
|
||||
$this->assertEquals(null, $conf->get('hooba'));
|
||||
}
|
||||
|
||||
public function testSetHasGetRemove()
|
||||
{
|
||||
$configuration = new Configuration(['key' => 'value']);
|
||||
|
||||
$this->assertTrue($configuration->has('key'));
|
||||
$this->assertEquals('value', $configuration->get('key'));
|
||||
|
||||
$this->assertFalse($configuration->has('key2'));
|
||||
$configuration->remove('key');
|
||||
$this->assertFalse($configuration->has('key'));
|
||||
|
||||
$configuration->set('key2', 'value2');
|
||||
$this->assertTrue($configuration->has('key2'));
|
||||
$this->assertEquals('value2', $configuration->get('key2'));
|
||||
}
|
||||
|
||||
public function testIterator()
|
||||
{
|
||||
$data = [
|
||||
'key1' => 'value1',
|
||||
'key2' => 'value2',
|
||||
'key3' => 'value3',
|
||||
];
|
||||
|
||||
$captured = [];
|
||||
$conf = new Configuration($data);
|
||||
|
||||
foreach ($conf as $key => $value) {
|
||||
$captured[$key] = $value;
|
||||
}
|
||||
|
||||
$this->assertEquals($data, $captured);
|
||||
}
|
||||
|
||||
public function testAll()
|
||||
{
|
||||
$data = [
|
||||
'key1' => 'value1',
|
||||
'key2' => 'value2',
|
||||
'key3' => 'value3',
|
||||
];
|
||||
|
||||
$conf = new Configuration($data);
|
||||
$this->assertEquals($data, $conf->all());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Alchemy\Tests\BinaryDriver\Exceptions;
|
||||
|
||||
use Alchemy\BinaryDriver\BinaryDriverTestCase;
|
||||
use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
|
||||
use Alchemy\BinaryDriver\ProcessRunner;
|
||||
|
||||
class ExecutionFailureExceptionTest extends BinaryDriverTestCase
|
||||
{
|
||||
public function getProcessRunner($logger)
|
||||
{
|
||||
return new ProcessRunner($logger, 'test-runner');
|
||||
}
|
||||
|
||||
public function testGetExceptionInfo(){
|
||||
|
||||
$logger = $this->createLoggerMock();
|
||||
$runner = $this->getProcessRunner($logger);
|
||||
|
||||
$process = $this->createProcessMock(1, false, '--helloworld--', null, "Error Output", true);
|
||||
try{
|
||||
$runner->run($process, new \SplObjectStorage(), false);
|
||||
$this->fail('An exception should have been raised');
|
||||
}
|
||||
catch (ExecutionFailureException $e){
|
||||
$this->assertEquals("--helloworld--", $e->getCommand());
|
||||
$this->assertEquals("Error Output", $e->getErrorOutput());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
54
tests/Alchemy/BinaryDriver/LTSProcessBuilder.php
Normal file
54
tests/Alchemy/BinaryDriver/LTSProcessBuilder.php
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace Alchemy\Tests\BinaryDriver;
|
||||
|
||||
use Alchemy\BinaryDriver\ProcessBuilderFactory;
|
||||
use LogicException;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Symfony\Component\Process\ProcessBuilder;
|
||||
|
||||
class LTSProcessBuilder extends ProcessBuilder
|
||||
{
|
||||
private $arguments;
|
||||
private $prefix;
|
||||
private $timeout;
|
||||
|
||||
public function __construct(array $arguments = array())
|
||||
{
|
||||
$this->arguments = $arguments;
|
||||
parent::__construct($arguments);
|
||||
}
|
||||
|
||||
public function setArguments(array $arguments)
|
||||
{
|
||||
$this->arguments = $arguments;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPrefix($prefix)
|
||||
{
|
||||
$this->prefix = $prefix;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTimeout($timeout)
|
||||
{
|
||||
$this->timeout = $timeout;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getProcess()
|
||||
{
|
||||
if (!$this->prefix && !count($this->arguments)) {
|
||||
throw new LogicException('You must add() command arguments before calling getProcess().');
|
||||
}
|
||||
|
||||
$args = $this->prefix ? array_merge(array($this->prefix), $this->arguments) : $this->arguments;
|
||||
$script = implode(' ', array_map('escapeshellarg', $args));
|
||||
|
||||
return new Process($script, null, null, null, $this->timeout);
|
||||
}
|
||||
}
|
||||
28
tests/Alchemy/BinaryDriver/LTSProcessBuilderFactoryTest.php
Normal file
28
tests/Alchemy/BinaryDriver/LTSProcessBuilderFactoryTest.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Alchemy\Tests\BinaryDriver;
|
||||
|
||||
use Alchemy\BinaryDriver\ProcessBuilderFactory;
|
||||
|
||||
class LTSProcessBuilderFactoryTest extends AbstractProcessBuilderFactoryTest
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
if (!class_exists('Symfony\Component\Process\ProcessBuilder')) {
|
||||
$this->markTestSkipped('ProcessBuilder is not available.');
|
||||
return;
|
||||
}
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
protected function getProcessBuilderFactory($binary)
|
||||
{
|
||||
$factory = new ProcessBuilderFactory($binary);
|
||||
$factory->setBuilder(new LTSProcessBuilder());
|
||||
ProcessBuilderFactory::$emulateSfLTS = false;
|
||||
$factory->useBinary($binary);
|
||||
|
||||
return $factory;
|
||||
}
|
||||
}
|
||||
34
tests/Alchemy/BinaryDriver/Listeners/DebugListenerTest.php
Normal file
34
tests/Alchemy/BinaryDriver/Listeners/DebugListenerTest.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Alchemy\Tests\BinaryDriver\Listeners;
|
||||
|
||||
use Alchemy\BinaryDriver\Listeners\DebugListener;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class DebugListenerTest extends TestCase
|
||||
{
|
||||
public function testHandle()
|
||||
{
|
||||
$listener = new DebugListener();
|
||||
|
||||
$lines = [];
|
||||
$listener->on('debug', function ($line) use (&$lines) {
|
||||
$lines[] = $line;
|
||||
});
|
||||
$listener->handle(Process::ERR, "first line\nsecond line");
|
||||
$listener->handle(Process::OUT, "cool output");
|
||||
$listener->handle('unknown', "lalala");
|
||||
$listener->handle(Process::OUT, "another output\n");
|
||||
|
||||
$expected = [
|
||||
'[ERROR] first line',
|
||||
'[ERROR] second line',
|
||||
'[OUT] cool output',
|
||||
'[OUT] another output',
|
||||
'[OUT] ',
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $lines);
|
||||
}
|
||||
}
|
||||
93
tests/Alchemy/BinaryDriver/Listeners/ListenersTest.php
Normal file
93
tests/Alchemy/BinaryDriver/Listeners/ListenersTest.php
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
|
||||
namespace Alchemy\Tests\BinaryDriver\Listeners;
|
||||
|
||||
use Alchemy\BinaryDriver\Listeners\ListenerInterface;
|
||||
use Alchemy\BinaryDriver\Listeners\Listeners;
|
||||
use Evenement\EventEmitter;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ListenersTest extends TestCase
|
||||
{
|
||||
public function testRegister()
|
||||
{
|
||||
$listener = new MockListener();
|
||||
|
||||
$listeners = new Listeners();
|
||||
$listeners->register($listener);
|
||||
|
||||
$n = 0;
|
||||
$listener->on('received', function ($type, $data) use (&$n, &$capturedType, &$capturedData) {
|
||||
$n++;
|
||||
$capturedData = $data;
|
||||
$capturedType = $type;
|
||||
});
|
||||
|
||||
$type = 'type';
|
||||
$data = 'data';
|
||||
|
||||
$listener->handle($type, $data);
|
||||
$listener->handle($type, $data);
|
||||
|
||||
$listeners->unregister($listener);
|
||||
|
||||
$listener->handle($type, $data);
|
||||
|
||||
$this->assertEquals(3, $n);
|
||||
$this->assertEquals($type, $capturedType);
|
||||
$this->assertEquals($data, $capturedData);
|
||||
}
|
||||
|
||||
public function testRegisterAndForwardThenUnregister()
|
||||
{
|
||||
$listener = new MockListener();
|
||||
$target = new EventEmitter();
|
||||
|
||||
$n = 0;
|
||||
$target->on('received', function ($type, $data) use (&$n, &$capturedType, &$capturedData) {
|
||||
$n++;
|
||||
$capturedData = $data;
|
||||
$capturedType = $type;
|
||||
});
|
||||
|
||||
$m = 0;
|
||||
$listener->on('received', function ($type, $data) use (&$m, &$capturedType2, &$capturedData2) {
|
||||
$m++;
|
||||
$capturedData2 = $data;
|
||||
$capturedType2 = $type;
|
||||
});
|
||||
|
||||
$listeners = new Listeners();
|
||||
$listeners->register($listener, $target);
|
||||
|
||||
$type = 'type';
|
||||
$data = 'data';
|
||||
|
||||
$listener->handle($type, $data);
|
||||
$listener->handle($type, $data);
|
||||
|
||||
$listeners->unregister($listener, $target);
|
||||
|
||||
$listener->handle($type, $data);
|
||||
|
||||
$this->assertEquals(2, $n);
|
||||
$this->assertEquals(3, $m);
|
||||
$this->assertEquals($type, $capturedType);
|
||||
$this->assertEquals($data, $capturedData);
|
||||
$this->assertEquals($type, $capturedType2);
|
||||
$this->assertEquals($data, $capturedData2);
|
||||
}
|
||||
}
|
||||
|
||||
class MockListener extends EventEmitter implements ListenerInterface
|
||||
{
|
||||
public function handle($type, $data)
|
||||
{
|
||||
$this->emit('received', [$type, $data]);
|
||||
}
|
||||
|
||||
public function forwardedEvents()
|
||||
{
|
||||
return ['received'];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace Alchemy\Tests\BinaryDriver;
|
||||
|
||||
use Alchemy\BinaryDriver\ProcessBuilderFactory;
|
||||
|
||||
class NONLTSProcessBuilderFactoryTest extends AbstractProcessBuilderFactoryTest
|
||||
{
|
||||
protected function getProcessBuilderFactory($binary)
|
||||
{
|
||||
ProcessBuilderFactory::$emulateSfLTS = true;
|
||||
|
||||
return new ProcessBuilderFactory($binary);
|
||||
}
|
||||
}
|
||||
208
tests/Alchemy/BinaryDriver/ProcessRunnerTest.php
Normal file
208
tests/Alchemy/BinaryDriver/ProcessRunnerTest.php
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Alchemy\BinaryDriver.
|
||||
*
|
||||
* (c) Alchemy <info@alchemy.fr>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Tests\BinaryDriver;
|
||||
|
||||
use Alchemy\BinaryDriver\ProcessRunner;
|
||||
use Alchemy\BinaryDriver\BinaryDriverTestCase;
|
||||
use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
|
||||
use Alchemy\BinaryDriver\Listeners\ListenerInterface;
|
||||
use Evenement\EventEmitter;
|
||||
use Symfony\Component\Process\Exception\RuntimeException as ProcessRuntimeException;
|
||||
|
||||
class ProcessRunnerTest extends BinaryDriverTestCase
|
||||
{
|
||||
public function getProcessRunner($logger)
|
||||
{
|
||||
return new ProcessRunner($logger, 'test-runner');
|
||||
}
|
||||
|
||||
public function testRunSuccessFullProcess()
|
||||
{
|
||||
$logger = $this->createLoggerMock();
|
||||
$runner = $this->getProcessRunner($logger);
|
||||
|
||||
$process = $this->createProcessMock(1, true, '--helloworld--', "Kikoo Romain", null, true);
|
||||
|
||||
$logger
|
||||
->expects($this->never())
|
||||
->method('error');
|
||||
$logger
|
||||
->expects($this->exactly(2))
|
||||
->method('info');
|
||||
|
||||
$this->assertEquals('Kikoo Romain', $runner->run($process, new \SplObjectStorage(), false));
|
||||
}
|
||||
|
||||
public function testRunSuccessFullProcessBypassingErrors()
|
||||
{
|
||||
$logger = $this->createLoggerMock();
|
||||
$runner = $this->getProcessRunner($logger);
|
||||
|
||||
$process = $this->createProcessMock(1, true, '--helloworld--', "Kikoo Romain", null, true);
|
||||
|
||||
$logger
|
||||
->expects($this->never())
|
||||
->method('error');
|
||||
$logger
|
||||
->expects($this->exactly(2))
|
||||
->method('info');
|
||||
|
||||
$this->assertEquals('Kikoo Romain', $runner->run($process, new \SplObjectStorage(), true));
|
||||
}
|
||||
|
||||
public function testRunFailingProcess()
|
||||
{
|
||||
$logger = $this->createLoggerMock();
|
||||
$runner = $this->getProcessRunner($logger);
|
||||
|
||||
$process = $this->createProcessMock(1, false, '--helloworld--', null, null, true);
|
||||
|
||||
$logger
|
||||
->expects($this->once())
|
||||
->method('error');
|
||||
$logger
|
||||
->expects($this->once())
|
||||
->method('info');
|
||||
|
||||
try {
|
||||
$runner->run($process, new \SplObjectStorage(), false);
|
||||
$this->fail('An exception should have been raised');
|
||||
} catch (ExecutionFailureException $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function testRunFailingProcessWithException()
|
||||
{
|
||||
$logger = $this->createLoggerMock();
|
||||
$runner = $this->getProcessRunner($logger);
|
||||
|
||||
$exception = new ProcessRuntimeException('Process Failed');
|
||||
$process = $this->getMockBuilder('Symfony\Component\Process\Process')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$process->expects($this->once())
|
||||
->method('run')
|
||||
->will($this->throwException($exception));
|
||||
|
||||
$logger
|
||||
->expects($this->once())
|
||||
->method('error');
|
||||
$logger
|
||||
->expects($this->once())
|
||||
->method('info');
|
||||
|
||||
try {
|
||||
$runner->run($process, new \SplObjectStorage(), false);
|
||||
$this->fail('An exception should have been raised');
|
||||
} catch (ExecutionFailureException $e) {
|
||||
$this->assertEquals($exception, $e->getPrevious());
|
||||
}
|
||||
}
|
||||
|
||||
public function testRunfailingProcessBypassingErrors()
|
||||
{
|
||||
$logger = $this->createLoggerMock();
|
||||
$runner = $this->getProcessRunner($logger);
|
||||
|
||||
$process = $this->createProcessMock(1, false, '--helloworld--', 'Hello output', null, true);
|
||||
|
||||
$logger
|
||||
->expects($this->once())
|
||||
->method('error');
|
||||
$logger
|
||||
->expects($this->once())
|
||||
->method('info');
|
||||
|
||||
$this->assertNull($runner->run($process, new \SplObjectStorage(), true));
|
||||
}
|
||||
|
||||
public function testRunFailingProcessWithExceptionBypassingErrors()
|
||||
{
|
||||
$logger = $this->createLoggerMock();
|
||||
$runner = $this->getProcessRunner($logger);
|
||||
|
||||
$exception = new ProcessRuntimeException('Process Failed');
|
||||
$process = $this->getMockBuilder('Symfony\Component\Process\Process')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$process->expects($this->once())
|
||||
->method('run')
|
||||
->will($this->throwException($exception));
|
||||
|
||||
$logger
|
||||
->expects($this->once())
|
||||
->method('error');
|
||||
$logger
|
||||
->expects($this->once())
|
||||
->method('info');
|
||||
|
||||
$this->assertNull($runner->run($process, new \SplObjectStorage(), true));
|
||||
}
|
||||
|
||||
public function testRunSuccessFullProcessWithHandlers()
|
||||
{
|
||||
$logger = $this->createLoggerMock();
|
||||
$runner = $this->getProcessRunner($logger);
|
||||
|
||||
$capturedCallback = null;
|
||||
|
||||
$process = $this->createProcessMock(1, true, '--helloworld--', "Kikoo Romain", null, true);
|
||||
$process->expects($this->once())
|
||||
->method('run')
|
||||
->with($this->isInstanceOf('Closure'))
|
||||
->will($this->returnCallback(function ($callback) use (&$capturedCallback) {
|
||||
$capturedCallback = $callback;
|
||||
}));
|
||||
|
||||
$logger
|
||||
->expects($this->never())
|
||||
->method('error');
|
||||
$logger
|
||||
->expects($this->exactly(2))
|
||||
->method('info');
|
||||
|
||||
$listener = new TestListener();
|
||||
$storage = new \SplObjectStorage();
|
||||
$storage->attach($listener);
|
||||
|
||||
$capturedType = $capturedData = null;
|
||||
|
||||
$listener->on('received', function ($type, $data) use (&$capturedType, &$capturedData) {
|
||||
$capturedData = $data;
|
||||
$capturedType = $type;
|
||||
});
|
||||
|
||||
$this->assertEquals('Kikoo Romain', $runner->run($process, $storage, false));
|
||||
|
||||
$type = 'err';
|
||||
$data = 'data';
|
||||
|
||||
$capturedCallback($type, $data);
|
||||
|
||||
$this->assertEquals($data, $capturedData);
|
||||
$this->assertEquals($type, $capturedType);
|
||||
}
|
||||
}
|
||||
|
||||
class TestListener extends EventEmitter implements ListenerInterface
|
||||
{
|
||||
public function handle($type, $data)
|
||||
{
|
||||
return $this->emit('received', array($type, $data));
|
||||
}
|
||||
|
||||
public function forwardedEvents()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\FFMpeg;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* This is a BC Layer to support phpunit 4.8 needed for php <= 5.5.
|
||||
*/
|
||||
if (class_exists('PHPUnit_Runner_Version')
|
||||
&& version_compare(\PHPUnit_Runner_Version::id(), '5', '<')
|
||||
) {
|
||||
class BaseTestCase extends TestCase
|
||||
{
|
||||
public static function assertScalar($value, $message = '')
|
||||
{
|
||||
self::assertTrue(is_scalar($value), $message);
|
||||
}
|
||||
|
||||
public static function assertIsArray($value, $message = '')
|
||||
{
|
||||
self::assertTrue(is_array($value), $message);
|
||||
}
|
||||
|
||||
public static function assertIsInt($value, $message = '')
|
||||
{
|
||||
self::assertTrue(is_int($value), $message);
|
||||
}
|
||||
|
||||
public static function assertIsBool($value, $message = '')
|
||||
{
|
||||
self::assertTrue(is_bool($value), $message);
|
||||
}
|
||||
|
||||
public static function assertIsString($value, $message = '')
|
||||
{
|
||||
self::assertTrue(is_string($value), $message);
|
||||
}
|
||||
|
||||
public function expectException($exception, $message = null)
|
||||
{
|
||||
$this->setExpectedException($exception, $message);
|
||||
}
|
||||
|
||||
public static function assertStringContainsString($needle, $haystack, $message = '')
|
||||
{
|
||||
self::assertContains($needle, $haystack, $message);
|
||||
}
|
||||
|
||||
public static function assertStringNotContainsString($needle, $haystack, $message = '')
|
||||
{
|
||||
self::assertNotContains($needle, $haystack, $message);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
class BaseTestCase extends TestCase
|
||||
{
|
||||
public function assertScalar($value, $message = '')
|
||||
{
|
||||
$this->assertTrue(is_scalar($value), $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
13
tests/FFMpeg/BaseTestCase.php
Normal file
13
tests/FFMpeg/BaseTestCase.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\FFMpeg;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BaseTestCase extends TestCase
|
||||
{
|
||||
public function assertScalar($value, $message = '')
|
||||
{
|
||||
$this->assertTrue(is_scalar($value), $message);
|
||||
}
|
||||
}
|
||||
|
|
@ -13,66 +13,72 @@ class AdvancedMediaTest extends FunctionalTestCase
|
|||
/**
|
||||
* Path prefix to avoid conflicts with another tests.
|
||||
*/
|
||||
const OUTPUT_PATH_PREFIX = 'output/advanced_media_';
|
||||
public const OUTPUT_PATH_PREFIX = 'output/advanced_media_';
|
||||
|
||||
public function testRunWithoutComplexFilterTestExtractAudio()
|
||||
{
|
||||
$ffmpeg = $this->getFFMpeg();
|
||||
$inputs = array(realpath(__DIR__ . '/../files/Test.ogv'));
|
||||
$inputs = [realpath(__DIR__.'/../files/Test.ogv')];
|
||||
$format = new Mp3();
|
||||
$output = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'extracted_with_map.mp3';
|
||||
$output = __DIR__.'/'.self::OUTPUT_PATH_PREFIX.'extracted_with_map.mp3';
|
||||
|
||||
// You can run it without -filter_complex, just using -map.
|
||||
$advancedMedia = $ffmpeg->openAdvanced($inputs);
|
||||
$advancedMedia
|
||||
->map(array('0:a'), $format, $output)
|
||||
->map(['0:a'], $format, $output)
|
||||
->save();
|
||||
|
||||
$this->assertFileExists($output);
|
||||
$this->assertEquals('MP2/3 (MPEG audio layer 2/3)',
|
||||
$ffmpeg->open($output)->getFormat()->get('format_long_name'));
|
||||
$this->assertEquals(
|
||||
'MP2/3 (MPEG audio layer 2/3)',
|
||||
$ffmpeg->open($output)->getFormat()->get('format_long_name')
|
||||
);
|
||||
unlink($output);
|
||||
}
|
||||
|
||||
public function testAudio()
|
||||
{
|
||||
$ffmpeg = $this->getFFMpeg();
|
||||
$inputs = array(realpath(__DIR__ . '/../files/Audio.mp3'));
|
||||
$inputs = [realpath(__DIR__.'/../files/Audio.mp3')];
|
||||
$format = new Mp3();
|
||||
$format->setAudioKiloBitrate(30);
|
||||
$output = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'audio_test.mp3';
|
||||
$output = __DIR__.'/'.self::OUTPUT_PATH_PREFIX.'audio_test.mp3';
|
||||
|
||||
$advancedMedia = $ffmpeg->openAdvanced($inputs);
|
||||
$advancedMedia
|
||||
->map(array('0:a'), $format, $output)
|
||||
->map(['0:a'], $format, $output)
|
||||
->save();
|
||||
|
||||
$this->assertFileExists($output);
|
||||
$this->assertEquals('MP2/3 (MPEG audio layer 2/3)',
|
||||
$ffmpeg->open($output)->getFormat()->get('format_long_name'));
|
||||
$this->assertEquals(
|
||||
'MP2/3 (MPEG audio layer 2/3)',
|
||||
$ffmpeg->open($output)->getFormat()->get('format_long_name')
|
||||
);
|
||||
unlink($output);
|
||||
}
|
||||
|
||||
public function testMultipleInputs()
|
||||
{
|
||||
$ffmpeg = $this->getFFMpeg();
|
||||
$inputs = array(
|
||||
realpath(__DIR__ . '/../files/portrait.MOV'),
|
||||
realpath(__DIR__ . '/../files/portrait.MOV')
|
||||
);
|
||||
$inputs = [
|
||||
realpath(__DIR__.'/../files/portrait.MOV'),
|
||||
realpath(__DIR__.'/../files/portrait.MOV'),
|
||||
];
|
||||
$format = new X264('aac', 'libx264');
|
||||
$output = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'multiple_inputs_test.mp4';
|
||||
$output = __DIR__.'/'.self::OUTPUT_PATH_PREFIX.'multiple_inputs_test.mp4';
|
||||
|
||||
$advancedMedia = $ffmpeg->openAdvanced($inputs);
|
||||
$advancedMedia->filters()
|
||||
->custom('[0:v][1:v]', 'hstack', '[v]');
|
||||
$advancedMedia
|
||||
->map(array('0:a', '[v]'), $format, $output)
|
||||
->map(['0:a', '[v]'], $format, $output)
|
||||
->save();
|
||||
|
||||
$this->assertFileExists($output);
|
||||
$this->assertEquals('QuickTime / MOV',
|
||||
$ffmpeg->open($output)->getFormat()->get('format_long_name'));
|
||||
$this->assertEquals(
|
||||
'QuickTime / MOV',
|
||||
$ffmpeg->open($output)->getFormat()->get('format_long_name')
|
||||
);
|
||||
unlink($output);
|
||||
}
|
||||
|
||||
|
|
@ -84,13 +90,13 @@ class AdvancedMediaTest extends FunctionalTestCase
|
|||
$ffmpeg = $this->getFFMpeg();
|
||||
// in this test we use only computed inputs
|
||||
// and can ignore -i part of the command, pass empty inputs array.
|
||||
$inputs = array();
|
||||
$inputs = [];
|
||||
$formatX264 = new X264('aac', 'libx264');
|
||||
$formatMp3 = new Mp3();
|
||||
|
||||
$outputMp3 = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'test_multiple_outputs.mp3';
|
||||
$outputVideo1 = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'test_multiple_outputs_v1.mp4';
|
||||
$outputVideo2 = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'test_multiple_outputs_v2.mp4';
|
||||
$outputMp3 = __DIR__.'/'.self::OUTPUT_PATH_PREFIX.'test_multiple_outputs.mp3';
|
||||
$outputVideo1 = __DIR__.'/'.self::OUTPUT_PATH_PREFIX.'test_multiple_outputs_v1.mp4';
|
||||
$outputVideo2 = __DIR__.'/'.self::OUTPUT_PATH_PREFIX.'test_multiple_outputs_v2.mp4';
|
||||
|
||||
$advancedMedia = $ffmpeg->openAdvanced($inputs);
|
||||
$advancedMedia->filters()
|
||||
|
|
@ -100,25 +106,30 @@ class AdvancedMediaTest extends FunctionalTestCase
|
|||
->custom('[v1]', 'negate', '[v1negate]')
|
||||
->custom('[v2]', 'edgedetect', '[v2edgedetect]');
|
||||
$advancedMedia
|
||||
->map(array('[a]'), $formatMp3, $outputMp3)
|
||||
->map(array('[v1negate]'), $formatX264, $outputVideo1)
|
||||
->map(array('[v2edgedetect]'), $formatX264, $outputVideo2)
|
||||
->map(['[a]'], $formatMp3, $outputMp3)
|
||||
->map(['[v1negate]'], $formatX264, $outputVideo1)
|
||||
->map(['[v2edgedetect]'], $formatX264, $outputVideo2)
|
||||
->save();
|
||||
|
||||
|
||||
$this->assertFileExists($outputMp3);
|
||||
$this->assertEquals('MP2/3 (MPEG audio layer 2/3)',
|
||||
$ffmpeg->open($outputMp3)->getFormat()->get('format_long_name'));
|
||||
$this->assertEquals(
|
||||
'MP2/3 (MPEG audio layer 2/3)',
|
||||
$ffmpeg->open($outputMp3)->getFormat()->get('format_long_name')
|
||||
);
|
||||
unlink($outputMp3);
|
||||
|
||||
$this->assertFileExists($outputVideo1);
|
||||
$this->assertEquals('QuickTime / MOV',
|
||||
$ffmpeg->open($outputVideo1)->getFormat()->get('format_long_name'));
|
||||
$this->assertEquals(
|
||||
'QuickTime / MOV',
|
||||
$ffmpeg->open($outputVideo1)->getFormat()->get('format_long_name')
|
||||
);
|
||||
unlink($outputVideo1);
|
||||
|
||||
$this->assertFileExists($outputVideo2);
|
||||
$this->assertEquals('QuickTime / MOV',
|
||||
$ffmpeg->open($outputVideo2)->getFormat()->get('format_long_name'));
|
||||
$this->assertEquals(
|
||||
'QuickTime / MOV',
|
||||
$ffmpeg->open($outputVideo2)->getFormat()->get('format_long_name')
|
||||
);
|
||||
unlink($outputVideo2);
|
||||
}
|
||||
|
||||
|
|
@ -129,21 +140,23 @@ class AdvancedMediaTest extends FunctionalTestCase
|
|||
public function testTestSrcFilterTestSineFilter()
|
||||
{
|
||||
$ffmpeg = $this->getFFMpeg();
|
||||
$inputs = array(realpath(__DIR__ . '/../files/Test.ogv'));
|
||||
$inputs = [realpath(__DIR__.'/../files/Test.ogv')];
|
||||
$format = new X264('aac', 'libx264');
|
||||
$output = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'testsrc.mp4';
|
||||
$output = __DIR__.'/'.self::OUTPUT_PATH_PREFIX.'testsrc.mp4';
|
||||
|
||||
$advancedMedia = $ffmpeg->openAdvanced($inputs);
|
||||
$advancedMedia->filters()
|
||||
->sine('[a]', 10)
|
||||
->testSrc('[v]', TestSrcFilter::TESTSRC, '160x120', 10);
|
||||
$advancedMedia
|
||||
->map(array('[a]', '[v]'), $format, $output)
|
||||
->map(['[a]', '[v]'], $format, $output)
|
||||
->save();
|
||||
|
||||
$this->assertFileExists($output);
|
||||
$this->assertEquals('QuickTime / MOV',
|
||||
$ffmpeg->open($output)->getFormat()->get('format_long_name'));
|
||||
$this->assertEquals(
|
||||
'QuickTime / MOV',
|
||||
$ffmpeg->open($output)->getFormat()->get('format_long_name')
|
||||
);
|
||||
unlink($output);
|
||||
}
|
||||
|
||||
|
|
@ -160,14 +173,15 @@ class AdvancedMediaTest extends FunctionalTestCase
|
|||
$ffmpegVersion = $ffmpeg->getFFMpegDriver()->getVersion();
|
||||
if (version_compare($ffmpegVersion, $xStack->getMinimalFFMpegVersion(), '<')) {
|
||||
$this->markTestSkipped('XStack filter is supported starting from ffmpeg version '
|
||||
. $xStack->getMinimalFFMpegVersion() . ', your version is '
|
||||
. $ffmpegVersion);
|
||||
.$xStack->getMinimalFFMpegVersion().', your version is '
|
||||
.$ffmpegVersion);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$inputs = array(realpath(__DIR__ . '/../files/Test.ogv'));
|
||||
$inputs = [realpath(__DIR__.'/../files/Test.ogv')];
|
||||
$format = new X264('aac', 'libx264');
|
||||
$output = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'xstack_test.mp4';
|
||||
$output = __DIR__.'/'.self::OUTPUT_PATH_PREFIX.'xstack_test.mp4';
|
||||
|
||||
$advancedMedia = $ffmpeg->openAdvanced($inputs);
|
||||
$advancedMedia->filters()
|
||||
|
|
@ -176,25 +190,31 @@ class AdvancedMediaTest extends FunctionalTestCase
|
|||
->testSrc('[v2]', TestSrcFilter::TESTSRC, '160x120', 5)
|
||||
->testSrc('[v3]', TestSrcFilter::TESTSRC, '160x120', 5)
|
||||
->testSrc('[v4]', TestSrcFilter::TESTSRC, '160x120', 5)
|
||||
->xStack('[v1][v2][v3][v4]',
|
||||
XStackFilter::LAYOUT_2X2, 4, '[v]');
|
||||
->xStack(
|
||||
'[v1][v2][v3][v4]',
|
||||
XStackFilter::LAYOUT_2X2,
|
||||
4,
|
||||
'[v]'
|
||||
);
|
||||
$advancedMedia
|
||||
->map(array('[a]', '[v]'), $format, $output)
|
||||
->map(['[a]', '[v]'], $format, $output)
|
||||
->save();
|
||||
|
||||
$this->assertFileExists($output);
|
||||
$this->assertEquals('QuickTime / MOV',
|
||||
$ffmpeg->open($output)->getFormat()->get('format_long_name'));
|
||||
$this->assertEquals(
|
||||
'QuickTime / MOV',
|
||||
$ffmpeg->open($output)->getFormat()->get('format_long_name')
|
||||
);
|
||||
unlink($output);
|
||||
}
|
||||
|
||||
public function testOfCompatibilityWithExistedFilters()
|
||||
{
|
||||
$ffmpeg = $this->getFFMpeg();
|
||||
$inputs = array(realpath(__DIR__ . '/../files/Test.ogv'));
|
||||
$watermark = realpath(__DIR__ . '/../files/watermark.png');
|
||||
$inputs = [realpath(__DIR__.'/../files/Test.ogv')];
|
||||
$watermark = realpath(__DIR__.'/../files/watermark.png');
|
||||
$format = new X264('aac', 'libx264');
|
||||
$output = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'test_of_compatibility_with_existed_filters.mp4';
|
||||
$output = __DIR__.'/'.self::OUTPUT_PATH_PREFIX.'test_of_compatibility_with_existed_filters.mp4';
|
||||
|
||||
$advancedMedia = $ffmpeg->openAdvanced($inputs);
|
||||
$advancedMedia->filters()
|
||||
|
|
@ -207,12 +227,14 @@ class AdvancedMediaTest extends FunctionalTestCase
|
|||
//->watermark('[0:v]', $watermark, '[v]')
|
||||
->pad('[0:v]', new Dimension(300, 100), '[v]');
|
||||
$advancedMedia
|
||||
->map(array('0:a', '[v]'), $format, $output)
|
||||
->map(['0:a', '[v]'], $format, $output)
|
||||
->save();
|
||||
|
||||
$this->assertFileExists($output);
|
||||
$this->assertEquals('QuickTime / MOV',
|
||||
$ffmpeg->open($output)->getFormat()->get('format_long_name'));
|
||||
$this->assertEquals(
|
||||
'QuickTime / MOV',
|
||||
$ffmpeg->open($output)->getFormat()->get('format_long_name')
|
||||
);
|
||||
unlink($output);
|
||||
}
|
||||
|
||||
|
|
@ -221,14 +243,14 @@ class AdvancedMediaTest extends FunctionalTestCase
|
|||
$ffmpeg = $this->getFFMpeg();
|
||||
$format = new X264();
|
||||
|
||||
$advancedMedia1 = $ffmpeg->openAdvanced(array(__FILE__));
|
||||
$advancedMedia1 = $ffmpeg->openAdvanced([__FILE__]);
|
||||
$advancedMedia1
|
||||
->map(array('test'), $format, 'outputFile.mp4', false);
|
||||
->map(['test'], $format, 'outputFile.mp4', false);
|
||||
$this->assertStringContainsString('acodec', $advancedMedia1->getFinalCommand());
|
||||
|
||||
$advancedMedia2 = $ffmpeg->openAdvanced(array(__FILE__));
|
||||
$advancedMedia2 = $ffmpeg->openAdvanced([__FILE__]);
|
||||
$advancedMedia2
|
||||
->map(array('test'), $format, 'outputFile.mp4', true);
|
||||
->map(['test'], $format, 'outputFile.mp4', true);
|
||||
$this->assertStringNotContainsString('acodec', $advancedMedia2->getFinalCommand());
|
||||
}
|
||||
|
||||
|
|
@ -237,32 +259,42 @@ class AdvancedMediaTest extends FunctionalTestCase
|
|||
$ffmpeg = $this->getFFMpeg();
|
||||
$format = new X264();
|
||||
|
||||
$advancedMedia1 = $ffmpeg->openAdvanced(array(__FILE__));
|
||||
$advancedMedia1->map(array('test'), $format,
|
||||
'outputFile.mp4', false, false);
|
||||
$advancedMedia1 = $ffmpeg->openAdvanced([__FILE__]);
|
||||
$advancedMedia1->map(
|
||||
['test'],
|
||||
$format,
|
||||
'outputFile.mp4',
|
||||
false,
|
||||
false
|
||||
);
|
||||
$this->assertStringContainsString('vcodec', $advancedMedia1->getFinalCommand());
|
||||
|
||||
$advancedMedia2 = $ffmpeg->openAdvanced(array(__FILE__));
|
||||
$advancedMedia2->map(array('test'), $format,
|
||||
'outputFile.mp4', false, true);
|
||||
$advancedMedia2 = $ffmpeg->openAdvanced([__FILE__]);
|
||||
$advancedMedia2->map(
|
||||
['test'],
|
||||
$format,
|
||||
'outputFile.mp4',
|
||||
false,
|
||||
true
|
||||
);
|
||||
$this->assertStringNotContainsString('vcodec', $advancedMedia2->getFinalCommand());
|
||||
}
|
||||
|
||||
public function testGlobalOptions()
|
||||
{
|
||||
$configuration = array(
|
||||
$configuration = [
|
||||
'ffmpeg.threads' => 3,
|
||||
'ffmpeg.filter_threads' => 13,
|
||||
'ffmpeg.filter_complex_threads' => 24,
|
||||
);
|
||||
];
|
||||
|
||||
$ffmpeg = $this->getFFMpeg($configuration);
|
||||
$advancedMedia = $ffmpeg->openAdvanced(array(__FILE__));
|
||||
$advancedMedia = $ffmpeg->openAdvanced([__FILE__]);
|
||||
$command = $advancedMedia->getFinalCommand();
|
||||
|
||||
foreach ($configuration as $optionName => $optionValue) {
|
||||
$optionName = str_replace('ffmpeg.', '', $optionName);
|
||||
$this->assertStringContainsString('-' . $optionName . ' ' . $optionValue, $command);
|
||||
$this->assertStringContainsString('-'.$optionName.' '.$optionValue, $command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,19 +2,16 @@
|
|||
|
||||
namespace Tests\FFMpeg\Functional;
|
||||
|
||||
use FFMpeg\Format\Audio\Mp3;
|
||||
use FFMpeg\Media\Audio;
|
||||
|
||||
class AudioConcatenationTest extends FunctionalTestCase
|
||||
{
|
||||
public function testSimpleAudioFileConcatTest()
|
||||
{
|
||||
$ffmpeg = $this->getFFMpeg();
|
||||
|
||||
$files = array(
|
||||
$files = [
|
||||
realpath(__DIR__ . '/../files/Jahzzar_-_05_-_Siesta.mp3'),
|
||||
realpath(__DIR__ . '/../files/02_-_Favorite_Secrets.mp3'),
|
||||
);
|
||||
];
|
||||
|
||||
$audio = $ffmpeg->open(reset($files));
|
||||
|
||||
|
|
@ -23,7 +20,7 @@ class AudioConcatenationTest extends FunctionalTestCase
|
|||
clearstatcache();
|
||||
$filename = __DIR__ . '/output/concat-output.mp3';
|
||||
|
||||
$audio->concat($files)->saveFromSameCodecs($filename, TRUE);
|
||||
$audio->concat($files)->saveFromSameCodecs($filename, true);
|
||||
|
||||
$this->assertFileExists($filename);
|
||||
unlink($filename);
|
||||
|
|
@ -9,20 +9,19 @@ class FFProbeTest extends FunctionalTestCase
|
|||
public function testProbeOnFile()
|
||||
{
|
||||
$ffprobe = FFProbe::create();
|
||||
$this->assertGreaterThan(0, count($ffprobe->streams(__DIR__ . '/../files/Audio.mp3')));
|
||||
$this->assertGreaterThan(0, count($ffprobe->streams(__DIR__.'/../files/Audio.mp3')));
|
||||
}
|
||||
|
||||
public function testValidateExistingFile()
|
||||
{
|
||||
$ffprobe = FFProbe::create();
|
||||
$this->assertTrue($ffprobe->isValid(__DIR__ . '/../files/sample.3gp'));
|
||||
$this->assertTrue($ffprobe->isValid(__DIR__.'/../files/sample.3gp'));
|
||||
}
|
||||
|
||||
|
||||
public function testValidateNonExistingFile()
|
||||
{
|
||||
$ffprobe = FFProbe::create();
|
||||
$this->assertFalse($ffprobe->isValid(__DIR__ . '/../files/WrongFile.mp4'));
|
||||
$this->assertFalse($ffprobe->isValid(__DIR__.'/../files/WrongFile.mp4'));
|
||||
}
|
||||
|
||||
public function testProbeOnNonExistantFile()
|
||||
|
|
@ -12,8 +12,8 @@ abstract class FunctionalTestCase extends BaseTestCase
|
|||
*
|
||||
* @return FFMpeg
|
||||
*/
|
||||
public function getFFMpeg($configuration = array())
|
||||
public function getFFMpeg($configuration = [])
|
||||
{
|
||||
return FFMpeg::create(array_merge(array('timeout' => 300), $configuration));
|
||||
return FFMpeg::create(array_merge(['timeout' => 300], $configuration));
|
||||
}
|
||||
}
|
||||
|
|
@ -12,13 +12,13 @@ class VideoTranscodeTest extends FunctionalTestCase
|
|||
{
|
||||
public function testSimpleTranscodeX264()
|
||||
{
|
||||
$filename = __DIR__ . '/output/output-x264.mp4';
|
||||
$filename = __DIR__.'/output/output-x264.mp4';
|
||||
if (is_file($filename)) {
|
||||
unlink(__DIR__ . '/output/output-x264.mp4');
|
||||
unlink(__DIR__.'/output/output-x264.mp4');
|
||||
}
|
||||
|
||||
$ffmpeg = $this->getFFMpeg();
|
||||
$video = $ffmpeg->open(__DIR__ . '/../files/Test.ogv');
|
||||
$video = $ffmpeg->open(__DIR__.'/../files/Test.ogv');
|
||||
|
||||
$this->assertInstanceOf('FFMpeg\Media\Video', $video);
|
||||
|
||||
|
|
@ -42,13 +42,13 @@ class VideoTranscodeTest extends FunctionalTestCase
|
|||
|
||||
public function testAacTranscodeX264()
|
||||
{
|
||||
$filename = __DIR__ . '/output/output-x264_2.mp4';
|
||||
$filename = __DIR__.'/output/output-x264_2.mp4';
|
||||
if (is_file($filename)) {
|
||||
unlink(__DIR__ . '/output/output-x264_2.mp4');
|
||||
unlink(__DIR__.'/output/output-x264_2.mp4');
|
||||
}
|
||||
|
||||
$ffmpeg = $this->getFFMpeg();
|
||||
$video = $ffmpeg->open(__DIR__ . '/../files/sample.3gp');
|
||||
$video = $ffmpeg->open(__DIR__.'/../files/sample.3gp');
|
||||
|
||||
$this->assertInstanceOf('FFMpeg\Media\Video', $video);
|
||||
|
||||
|
|
@ -70,39 +70,37 @@ class VideoTranscodeTest extends FunctionalTestCase
|
|||
unlink($filename);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function testTranscodeInvalidFile()
|
||||
{
|
||||
$this->expectException('\FFMpeg\Exception\RuntimeException');
|
||||
$ffmpeg = $this->getFFMpeg();
|
||||
$ffmpeg->open(__DIR__ . '/../files/UnknownFileTest.ogv');
|
||||
$ffmpeg->open(__DIR__.'/../files/UnknownFileTest.ogv');
|
||||
}
|
||||
|
||||
public function testSaveInvalidForgedVideo()
|
||||
{
|
||||
$ffmpeg = $this->getFFMpeg();
|
||||
$video = new Video(__DIR__ . '/../files/UnknownFileTest.ogv', $ffmpeg->getFFMpegDriver(), $ffmpeg->getFFProbe());
|
||||
$video = new Video(__DIR__.'/../files/UnknownFileTest.ogv', $ffmpeg->getFFMpegDriver(), $ffmpeg->getFFProbe());
|
||||
|
||||
$this->expectException('\FFMpeg\Exception\RuntimeException');
|
||||
$video->save(new X264('aac'), __DIR__ . '/output/output-x264.mp4');
|
||||
$video->save(new X264('aac'), __DIR__.'/output/output-x264.mp4');
|
||||
}
|
||||
|
||||
public function testTranscodePortraitVideo()
|
||||
{
|
||||
$info = $this->getNameAndVersion();
|
||||
|
||||
if ($info['name'] === 'avconv' && version_compare($info['version'], '0.9', '<')) {
|
||||
if ('avconv' === $info['name'] && 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)) {
|
||||
unlink(__DIR__ . '/output/output-x264.mp4');
|
||||
unlink(__DIR__.'/output/output-x264.mp4');
|
||||
}
|
||||
|
||||
$ffmpeg = $this->getFFMpeg();
|
||||
$video = $ffmpeg->open(__DIR__ . '/../files/portrait.MOV');
|
||||
$video = $ffmpeg->open(__DIR__.'/../files/portrait.MOV');
|
||||
|
||||
$video->filters()
|
||||
->resize(new Dimension(320, 240), ResizeFilter::RESIZEMODE_INSET)
|
||||
|
|
@ -131,18 +129,18 @@ class VideoTranscodeTest extends FunctionalTestCase
|
|||
->getBinary();
|
||||
|
||||
$output = $matches = null;
|
||||
exec($binary . ' -version 2>&1', $output);
|
||||
exec($binary.' -version 2>&1', $output);
|
||||
|
||||
if (!isset($output[0])) {
|
||||
return array('name' => null, 'version' => null);
|
||||
return ['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 ['name' => $matches[1], 'version' => $matches[2]];
|
||||
}
|
||||
|
||||
return array('name' => null, 'version' => null);
|
||||
return ['name' => null, 'version' => null];
|
||||
}
|
||||
}
|
||||
83
tests/FFMpeg/Unit/Coordinate/AspectRatioTest.php
Normal file
83
tests/FFMpeg/Unit/Coordinate/AspectRatioTest.php
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\FFMpeg\Unit\Coordinate;
|
||||
|
||||
use FFMpeg\Coordinate\AspectRatio;
|
||||
use FFMpeg\Coordinate\Dimension;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class AspectRatioTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideDimensionsAndExpectedratio
|
||||
*/
|
||||
public function testFromDimensions($width, $height, $strategy, $expected, $calculatedWidth, $calculatedHeight, $modulus = 2)
|
||||
{
|
||||
$ratio = AspectRatio::create(new Dimension($width, $height), $strategy);
|
||||
$this->assertEquals($expected, $ratio->getValue());
|
||||
|
||||
$this->assertEquals($calculatedHeight, $ratio->calculateHeight(240, $modulus));
|
||||
$this->assertEquals($calculatedWidth, $ratio->calculateWidth(320, $modulus));
|
||||
}
|
||||
|
||||
public function provideDimensionsAndExpectedratio()
|
||||
{
|
||||
return [
|
||||
//AR_5_4
|
||||
[720, 576, false, 5 / 4, 400, 192],
|
||||
[720, 577, false, 5 / 4, 400, 192],
|
||||
[720, 620, false, 720 / 620, 372, 206],
|
||||
[720, 576, true, 5 / 4, 400, 192],
|
||||
//AR_ROTATED_4_5
|
||||
[576, 720, false, 4 / 5, 256, 300],
|
||||
[576, 720, true, 4 / 5, 256, 300],
|
||||
//AR_4_3
|
||||
[320, 240, false, 4 / 3, 426, 180],
|
||||
[320, 240, true, 4 / 3, 426, 180],
|
||||
//AR_ROTATED_3_4
|
||||
[240, 320, false, 3 / 4, 240, 320],
|
||||
[240, 320, true, 3 / 4, 240, 320],
|
||||
//AR_16_9
|
||||
[1920, 1080, false, 16 / 9, 568, 136],
|
||||
[1920, 1080, true, 16 / 9, 568, 136],
|
||||
[1280, 720, false, 16 / 9, 568, 136],
|
||||
[1280, 720, true, 16 / 9, 568, 136],
|
||||
[3840, 2160, false, 16 / 9, 568, 136],
|
||||
[3840, 2160, true, 16 / 9, 568, 136],
|
||||
// modulus 4
|
||||
[1920, 1080, false, 16 / 9, 568, 136, 4],
|
||||
[1920, 1080, true, 16 / 9, 568, 136, 4],
|
||||
[1280, 720, false, 16 / 9, 568, 136, 4],
|
||||
[1280, 720, true, 16 / 9, 568, 136, 4],
|
||||
[3840, 2160, false, 16 / 9, 568, 136, 4],
|
||||
[3840, 2160, true, 16 / 9, 568, 136, 4],
|
||||
// modulus 16
|
||||
[1920, 1080, false, 16 / 9, 576, 128, 16],
|
||||
[1920, 1080, true, 16 / 9, 576, 128, 16],
|
||||
[1280, 720, false, 16 / 9, 576, 128, 16],
|
||||
[1280, 720, true, 16 / 9, 576, 128, 16],
|
||||
[3840, 2160, false, 16 / 9, 576, 128, 16],
|
||||
[3840, 2160, true, 16 / 9, 576, 128, 16],
|
||||
//AR_ROTATED_9_16
|
||||
[1080, 1920, false, 9 / 16, 180, 426],
|
||||
[1080, 1920, true, 9 / 16, 180, 426],
|
||||
[720, 1280, false, 9 / 16, 180, 426],
|
||||
[720, 1280, true, 9 / 16, 180, 426],
|
||||
[2160, 3840, false, 9 / 16, 180, 426],
|
||||
[2160, 3840, true, 9 / 16, 180, 426],
|
||||
//AR_3_2
|
||||
[360, 240, false, 3 / 2, 480, 160],
|
||||
[360, 240, true, 3 / 2, 480, 160],
|
||||
//AR_ROTATED_2_3
|
||||
[240, 360, false, 2 / 3, 214, 360],
|
||||
[240, 360, true, 2 / 3, 214, 360],
|
||||
//AR_5_3
|
||||
//AR_ROTATED_3_5
|
||||
//AR_1_1
|
||||
//AR_1_DOT_85_1
|
||||
//AR_ROTATED_1_DOT_85
|
||||
//AR_2_DOT_39_1
|
||||
//AR_ROTATED_2_DOT_39
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\Coordinate;
|
||||
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\Coordinate\Dimension;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class DimensionTest extends TestCase
|
||||
{
|
||||
|
|
@ -18,15 +18,15 @@ class DimensionTest extends TestCase
|
|||
|
||||
public function provideInvalidDimensions()
|
||||
{
|
||||
return array(
|
||||
array(320, 0),
|
||||
array(320, -10),
|
||||
array(0, 240),
|
||||
array(-10, 240),
|
||||
array(0, 0),
|
||||
array(0, -10),
|
||||
array(-10, 0),
|
||||
);
|
||||
return [
|
||||
[320, 0],
|
||||
[320, -10],
|
||||
[0, 240],
|
||||
[-10, 240],
|
||||
[0, 0],
|
||||
[0, -10],
|
||||
[-10, 0],
|
||||
];
|
||||
}
|
||||
|
||||
public function testGetters()
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\Coordinate;
|
||||
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\Coordinate\FrameRate;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class FrameRateTest extends TestCase
|
||||
{
|
||||
|
|
@ -24,8 +24,8 @@ class FrameRateTest extends TestCase
|
|||
|
||||
public function provideInvalidFrameRates()
|
||||
{
|
||||
return array(
|
||||
array(0), array(-1.5), array(-2),
|
||||
);
|
||||
return [
|
||||
[0], [-1.5], [-2],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\Coordinate;
|
||||
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\Coordinate\Point;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class PointTest extends TestCase
|
||||
{
|
||||
|
|
@ -16,8 +16,8 @@ class PointTest extends TestCase
|
|||
|
||||
public function testDynamicPointGetters()
|
||||
{
|
||||
$point = new Point("t*100", "t", true);
|
||||
$this->assertEquals("t*100", $point->getX());
|
||||
$this->assertEquals("t", $point->getY());
|
||||
$point = new Point('t*100', 't', true);
|
||||
$this->assertEquals('t*100', $point->getX());
|
||||
$this->assertEquals('t', $point->getY());
|
||||
}
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\Coordinate;
|
||||
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\Coordinate\TimeCode;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class TimeCodeTest extends TestCase
|
||||
{
|
||||
|
|
@ -18,14 +18,14 @@ class TimeCodeTest extends TestCase
|
|||
|
||||
public function provideTimeCodes()
|
||||
{
|
||||
return array(
|
||||
array('1:02:04:05:20', '26:04:05.20'),
|
||||
array('1:02:04:05.20', '26:04:05.20'),
|
||||
array('02:04:05:20', '02:04:05.20'),
|
||||
array('02:04:05.20', '02:04:05.20'),
|
||||
array('00:00:05.20', '00:00:05.20'),
|
||||
array('00:00:00.00', '00:00:00.00'),
|
||||
);
|
||||
return [
|
||||
['1:02:04:05:20', '26:04:05.20'],
|
||||
['1:02:04:05.20', '26:04:05.20'],
|
||||
['02:04:05:20', '02:04:05.20'],
|
||||
['02:04:05.20', '02:04:05.20'],
|
||||
['00:00:05.20', '00:00:05.20'],
|
||||
['00:00:00.00', '00:00:00.00'],
|
||||
];
|
||||
}
|
||||
|
||||
public function testFromInvalidString()
|
||||
|
|
@ -45,14 +45,14 @@ class TimeCodeTest extends TestCase
|
|||
|
||||
public function provideSeconds()
|
||||
{
|
||||
return array(
|
||||
array(0.467, '00:00:00.47'),
|
||||
array(12.467, '00:00:12.47'),
|
||||
array(59.867, '00:00:59.87'),
|
||||
array(72.467, '00:01:12.47'),
|
||||
array(3599.467, '00:59:59.47'),
|
||||
array(3600.467, '01:00:00.47'),
|
||||
array(86422.467, '24:00:22.47'),
|
||||
);
|
||||
return [
|
||||
[0.467, '00:00:00.47'],
|
||||
[12.467, '00:00:12.47'],
|
||||
[59.867, '00:00:59.87'],
|
||||
[72.467, '00:01:12.47'],
|
||||
[3599.467, '00:59:59.47'],
|
||||
[3600.467, '01:00:00.47'],
|
||||
[86422.467, '24:00:22.47'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -4,17 +4,17 @@ namespace Tests\FFMpeg\Unit\Driver;
|
|||
|
||||
use Alchemy\BinaryDriver\Configuration;
|
||||
use FFMpeg\Driver\FFMpegDriver;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use Symfony\Component\Process\ExecutableFinder;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class FFMpegDriverTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$executableFinder = new ExecutableFinder();
|
||||
|
||||
$found = false;
|
||||
foreach (array('avconv', 'ffmpeg') as $name) {
|
||||
foreach (['avconv', 'ffmpeg'] as $name) {
|
||||
if (null !== $executableFinder->find($name)) {
|
||||
$found = true;
|
||||
break;
|
||||
|
|
@ -29,7 +29,7 @@ class FFMpegDriverTest extends TestCase
|
|||
public function testCreate()
|
||||
{
|
||||
$logger = $this->getLoggerMock();
|
||||
$ffmpeg = FFMpegDriver::create($logger, array());
|
||||
$ffmpeg = FFMpegDriver::create($logger, []);
|
||||
$this->assertInstanceOf('FFMpeg\Driver\FFMpegDriver', $ffmpeg);
|
||||
$this->assertEquals($logger, $ffmpeg->getProcessRunner()->getLogger());
|
||||
}
|
||||
|
|
@ -44,6 +44,6 @@ class FFMpegDriverTest extends TestCase
|
|||
public function testCreateFailureThrowsAnException()
|
||||
{
|
||||
$this->expectException('\FFMpeg\Exception\ExecutableNotFoundException');
|
||||
FFMpegDriver::create($this->getLoggerMock(), array('ffmpeg.binaries' => '/path/to/nowhere'));
|
||||
FFMpegDriver::create($this->getLoggerMock(), ['ffmpeg.binaries' => '/path/to/nowhere']);
|
||||
}
|
||||
}
|
||||
|
|
@ -4,17 +4,17 @@ namespace Tests\FFMpeg\Unit\Driver;
|
|||
|
||||
use Alchemy\BinaryDriver\Configuration;
|
||||
use FFMpeg\Driver\FFProbeDriver;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use Symfony\Component\Process\ExecutableFinder;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class FFProbeDriverTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$executableFinder = new ExecutableFinder();
|
||||
|
||||
$found = false;
|
||||
foreach (array('avprobe', 'ffprobe') as $name) {
|
||||
foreach (['avprobe', 'ffprobe'] as $name) {
|
||||
if (null !== $executableFinder->find($name)) {
|
||||
$found = true;
|
||||
break;
|
||||
|
|
@ -29,7 +29,7 @@ class FFProbeDriverTest extends TestCase
|
|||
public function testCreate()
|
||||
{
|
||||
$logger = $this->getLoggerMock();
|
||||
$ffprobe = FFProbeDriver::create(array(), $logger);
|
||||
$ffprobe = FFProbeDriver::create([], $logger);
|
||||
$this->assertInstanceOf('FFMpeg\Driver\FFProbeDriver', $ffprobe);
|
||||
$this->assertEquals($logger, $ffprobe->getProcessRunner()->getLogger());
|
||||
}
|
||||
|
|
@ -44,6 +44,6 @@ class FFProbeDriverTest extends TestCase
|
|||
public function testCreateFailureThrowsAnException()
|
||||
{
|
||||
$this->expectException('\FFMpeg\Exception\ExecutableNotFoundException');
|
||||
FFProbeDriver::create(array('ffprobe.binaries' => '/path/to/nowhere'));
|
||||
FFProbeDriver::create(['ffprobe.binaries' => '/path/to/nowhere']);
|
||||
}
|
||||
}
|
||||
|
|
@ -3,8 +3,8 @@
|
|||
namespace Tests\FFMpeg\Unit;
|
||||
|
||||
use FFMpeg\FFMpeg;
|
||||
use FFMpeg\FFProbe\DataMapping\StreamCollection;
|
||||
use FFMpeg\FFProbe\DataMapping\Stream;
|
||||
use FFMpeg\FFProbe\DataMapping\StreamCollection;
|
||||
|
||||
class FFMpegTest extends TestCase
|
||||
{
|
||||
|
|
@ -23,10 +23,10 @@ class FFMpegTest extends TestCase
|
|||
$streams = $this->getStreamCollectionMock();
|
||||
$streams->expects($this->once())
|
||||
->method('audios')
|
||||
->will($this->returnValue(new StreamCollection(array(new Stream(array())))));
|
||||
->will($this->returnValue(new StreamCollection([new Stream([])])));
|
||||
$streams->expects($this->once())
|
||||
->method('videos')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
|
||||
$ffprobe = $this->getFFProbeMock();
|
||||
$ffprobe->expects($this->once())
|
||||
|
|
@ -43,7 +43,7 @@ class FFMpegTest extends TestCase
|
|||
$streams = $this->getStreamCollectionMock();
|
||||
$streams->expects($this->once())
|
||||
->method('videos')
|
||||
->will($this->returnValue(new StreamCollection(array(new Stream(array())))));
|
||||
->will($this->returnValue(new StreamCollection([new Stream([])])));
|
||||
$streams->expects($this->never())
|
||||
->method('audios');
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ class FFMpegTest extends TestCase
|
|||
$logger = $this->getLoggerMock();
|
||||
$ffprobe = $this->getFFProbeMock();
|
||||
|
||||
$ffmpeg = FFMpeg::create(array('timeout' => 42), $logger, $ffprobe);
|
||||
$ffmpeg = FFMpeg::create(['timeout' => 42], $logger, $ffprobe);
|
||||
$this->assertInstanceOf('FFMpeg\FFMpeg', $ffmpeg);
|
||||
|
||||
$this->assertSame($logger, $ffmpeg->getFFMpegDriver()->getProcessRunner()->getLogger());
|
||||
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\FFProbe\DataMapping;
|
||||
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\FFProbe\DataMapping\AbstractData;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class AbstractDataTest extends TestCase
|
||||
{
|
||||
public function testHas()
|
||||
{
|
||||
$imp = new Implementation(array('key1' => 'value1', 'key2' => 'value2'));
|
||||
$imp = new Implementation(['key1' => 'value1', 'key2' => 'value2']);
|
||||
|
||||
$this->assertTrue($imp->has('key1'));
|
||||
$this->assertTrue($imp->has('key2'));
|
||||
|
|
@ -19,7 +19,7 @@ class AbstractDataTest extends TestCase
|
|||
|
||||
public function testGet()
|
||||
{
|
||||
$imp = new Implementation(array('key1' => 'value1', 'key2' => 'value2'));
|
||||
$imp = new Implementation(['key1' => 'value1', 'key2' => 'value2']);
|
||||
|
||||
$this->assertEquals('value1', $imp->get('key1'));
|
||||
$this->assertEquals('value2', $imp->get('key2'));
|
||||
|
|
@ -27,20 +27,20 @@ class AbstractDataTest extends TestCase
|
|||
|
||||
public function testGetDefault()
|
||||
{
|
||||
$imp = new Implementation(array('key1' => 'value1', 'key2' => 'value2'));
|
||||
$imp = new Implementation(['key1' => 'value1', 'key2' => 'value2']);
|
||||
$this->assertSame('yololo', $imp->get('key3', 'yololo'));
|
||||
}
|
||||
|
||||
public function testKeys()
|
||||
{
|
||||
$imp = new Implementation(array('key1' => 'value1', 'key2' => 'value2'));
|
||||
$imp = new Implementation(['key1' => 'value1', 'key2' => 'value2']);
|
||||
|
||||
$this->assertEquals(array('key1', 'key2'), $imp->keys());
|
||||
$this->assertEquals(['key1', 'key2'], $imp->keys());
|
||||
}
|
||||
|
||||
public function testAll()
|
||||
{
|
||||
$values = array('key1' => 'value1', 'key2' => 'value2');
|
||||
$values = ['key1' => 'value1', 'key2' => 'value2'];
|
||||
$imp = new Implementation($values);
|
||||
|
||||
$this->assertEquals($values, $imp->all());
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\FFProbe\DataMapping;
|
||||
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\FFProbe\DataMapping\StreamCollection;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class StreamCollectionTest extends TestCase
|
||||
{
|
||||
|
|
@ -12,11 +12,11 @@ class StreamCollectionTest extends TestCase
|
|||
$stream = $this->getStreamMock();
|
||||
|
||||
$collection = new StreamCollection();
|
||||
$this->assertEquals(array(), $collection->all());
|
||||
$this->assertEquals([], $collection->all());
|
||||
$collection->add($stream);
|
||||
$this->assertEquals(array($stream), $collection->all());
|
||||
$this->assertEquals([$stream], $collection->all());
|
||||
$collection->add($stream);
|
||||
$this->assertEquals(array($stream, $stream), $collection->all());
|
||||
$this->assertEquals([$stream, $stream], $collection->all());
|
||||
}
|
||||
|
||||
public function testVideos()
|
||||
|
|
@ -31,12 +31,12 @@ class StreamCollectionTest extends TestCase
|
|||
->method('isVideo')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$collection = new StreamCollection(array($audio, $video));
|
||||
$collection = new StreamCollection([$audio, $video]);
|
||||
$videos = $collection->videos();
|
||||
|
||||
$this->assertInstanceOf('FFMpeg\FFProbe\DataMapping\StreamCollection', $videos);
|
||||
$this->assertCount(1, $videos);
|
||||
$this->assertEquals(array($video), $videos->all());
|
||||
$this->assertEquals([$video], $videos->all());
|
||||
}
|
||||
|
||||
public function testAudios()
|
||||
|
|
@ -51,19 +51,19 @@ class StreamCollectionTest extends TestCase
|
|||
->method('isAudio')
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$collection = new StreamCollection(array($audio, $video));
|
||||
$collection = new StreamCollection([$audio, $video]);
|
||||
$audios = $collection->audios();
|
||||
|
||||
$this->assertInstanceOf('FFMpeg\FFProbe\DataMapping\StreamCollection', $audios);
|
||||
$this->assertCount(1, $audios);
|
||||
$this->assertEquals(array($audio), $audios->all());
|
||||
$this->assertEquals([$audio], $audios->all());
|
||||
}
|
||||
|
||||
public function testCount()
|
||||
{
|
||||
$stream = $this->getStreamMock();
|
||||
|
||||
$collection = new StreamCollection(array($stream));
|
||||
$collection = new StreamCollection([$stream]);
|
||||
$this->assertCount(1, $collection);
|
||||
}
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ class StreamCollectionTest extends TestCase
|
|||
$audio = $this->getStreamMock();
|
||||
$video = $this->getStreamMock();
|
||||
|
||||
$collection = new StreamCollection(array($audio, $video));
|
||||
$collection = new StreamCollection([$audio, $video]);
|
||||
$this->assertInstanceOf('\Iterator', $collection->getIterator());
|
||||
$this->assertCount(2, $collection->getIterator());
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ class StreamCollectionTest extends TestCase
|
|||
$stream1 = $this->getStreamMock();
|
||||
$stream2 = $this->getStreamMock();
|
||||
|
||||
$coll = new StreamCollection(array($stream1, $stream2));
|
||||
$coll = new StreamCollection([$stream1, $stream2]);
|
||||
|
||||
$this->assertSame($stream1, $coll->first());
|
||||
}
|
||||
|
|
@ -3,8 +3,8 @@
|
|||
namespace Tests\FFMpeg\Unit\FFProbe\DataMapping;
|
||||
|
||||
use FFMpeg\Coordinate\Dimension;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\FFProbe\DataMapping\Stream;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class StreamTest extends TestCase
|
||||
{
|
||||
|
|
@ -19,10 +19,10 @@ class StreamTest extends TestCase
|
|||
|
||||
public function provideAudioCases()
|
||||
{
|
||||
return array(
|
||||
array(true, array('codec_type' => 'audio')),
|
||||
array(false, array('codec_type' => 'video')),
|
||||
);
|
||||
return [
|
||||
[true, ['codec_type' => 'audio']],
|
||||
[false, ['codec_type' => 'video']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -36,10 +36,10 @@ class StreamTest extends TestCase
|
|||
|
||||
public function provideVideoCases()
|
||||
{
|
||||
return array(
|
||||
array(true, array('codec_type' => 'video')),
|
||||
array(false, array('codec_type' => 'audio')),
|
||||
);
|
||||
return [
|
||||
[true, ['codec_type' => 'video']],
|
||||
[false, ['codec_type' => 'audio']],
|
||||
];
|
||||
}
|
||||
|
||||
public function testGetDimensionsFromAudio()
|
||||
|
|
@ -48,13 +48,13 @@ class StreamTest extends TestCase
|
|||
'\FFMpeg\Exception\LogicException',
|
||||
'Dimensions can only be retrieved from video streams.'
|
||||
);
|
||||
$stream = new Stream(array('codec_type' => 'audio'));
|
||||
$stream = new Stream(['codec_type' => 'audio']);
|
||||
$stream->getDimensions();
|
||||
}
|
||||
|
||||
public function testGetDimensionsFromVideo()
|
||||
{
|
||||
$stream = new Stream(array('codec_type' => 'video', 'width' => 960, 'height' => 720));
|
||||
$stream = new Stream(['codec_type' => 'video', 'width' => 960, 'height' => 720]);
|
||||
$this->assertEquals(new Dimension(960, 720), $stream->getDimensions());
|
||||
}
|
||||
|
||||
|
|
@ -67,16 +67,16 @@ class StreamTest extends TestCase
|
|||
'\FFMpeg\Exception\RuntimeException',
|
||||
'Unable to extract dimensions.'
|
||||
);
|
||||
$stream = new Stream(array('codec_type' => 'video', 'width' => 960));
|
||||
$stream = new Stream(['codec_type' => 'video', 'width' => 960]);
|
||||
$stream->getDimensions();
|
||||
}
|
||||
|
||||
public function provideInvalidPropertiesForDimensionsExtraction()
|
||||
{
|
||||
return array(
|
||||
array('codec_type' => 'video', 'width' => 960),
|
||||
array('codec_type' => 'video', 'height' => 960),
|
||||
);
|
||||
return [
|
||||
['codec_type' => 'video', 'width' => 960],
|
||||
['codec_type' => 'video', 'height' => 960],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -84,13 +84,13 @@ class StreamTest extends TestCase
|
|||
*/
|
||||
public function testGetDimensionsFromVideoWithDisplayRatio($data)
|
||||
{
|
||||
$stream = new Stream(array(
|
||||
$stream = new Stream([
|
||||
'codec_type' => 'video',
|
||||
'width' => $data['width'],
|
||||
'height' => $data['height'],
|
||||
'sample_aspect_ratio' => $data['sar'],
|
||||
'display_aspect_ratio' => $data['dar']
|
||||
));
|
||||
'height' => $data['height'],
|
||||
'sample_aspect_ratio' => $data['sar'],
|
||||
'display_aspect_ratio' => $data['dar'],
|
||||
]);
|
||||
$this->assertEquals(new Dimension($data['result_width'], $data['result_height']), $stream->getDimensions());
|
||||
}
|
||||
|
||||
|
|
@ -99,38 +99,38 @@ class StreamTest extends TestCase
|
|||
*/
|
||||
public function testGetDimensionsFromVideoWithInvalidDisplayRatio($invalidRatio)
|
||||
{
|
||||
$stream = new Stream(array('codec_type' => 'video', 'width' => 960, 'height' => 720, 'sample_aspect_ratio' => $invalidRatio, 'display_aspect_ratio' => '16:9'));
|
||||
$stream = new Stream(['codec_type' => 'video', 'width' => 960, 'height' => 720, 'sample_aspect_ratio' => $invalidRatio, 'display_aspect_ratio' => '16:9']);
|
||||
$this->assertEquals(new Dimension(960, 720), $stream->getDimensions());
|
||||
}
|
||||
|
||||
public function provideInvalidRatios()
|
||||
{
|
||||
return array(array('0:1'), array('2:1:3'));
|
||||
return [['0:1'], ['2:1:3']];
|
||||
}
|
||||
|
||||
public function providePropertiesForDimensionsExtraction()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array('width' => '960', 'height' => '720',
|
||||
return [
|
||||
[
|
||||
['width' => '960', 'height' => '720',
|
||||
'sar' => '4:3', 'dar' => '16:9',
|
||||
'result_width' => '1280', 'result_height' => '720'),
|
||||
),
|
||||
array(
|
||||
array('width' => '1920', 'height' => '1080',
|
||||
'result_width' => '1280', 'result_height' => '720', ],
|
||||
],
|
||||
[
|
||||
['width' => '1920', 'height' => '1080',
|
||||
'sar' => '1:1', 'dar' => '16:9',
|
||||
'result_width' => '1920', 'result_height' => '1080'),
|
||||
),
|
||||
array(
|
||||
array('width' => '640', 'height' => '480',
|
||||
'result_width' => '1920', 'result_height' => '1080', ],
|
||||
],
|
||||
[
|
||||
['width' => '640', 'height' => '480',
|
||||
'sar' => '75:74', 'dar' => '50:37',
|
||||
'result_width' => '649', 'result_height' => '480'),
|
||||
),
|
||||
array(
|
||||
array('width' => '720', 'height' => '576',
|
||||
'result_width' => '649', 'result_height' => '480', ],
|
||||
],
|
||||
[
|
||||
['width' => '720', 'height' => '576',
|
||||
'sar' => '52:28', 'dar' => '16:9',
|
||||
'result_width' => '1337', 'result_height' => '752'),
|
||||
),
|
||||
);
|
||||
'result_width' => '1337', 'result_height' => '752', ],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\FFProbe;
|
||||
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\FFProbe\Mapper;
|
||||
use FFMpeg\FFProbe;
|
||||
use FFMpeg\FFProbe\DataMapping\Format;
|
||||
use FFMpeg\FFProbe\DataMapping\Stream;
|
||||
use FFMpeg\FFProbe\DataMapping\StreamCollection;
|
||||
use FFMpeg\FFProbe\Mapper;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class MapperTest extends TestCase
|
||||
{
|
||||
|
|
@ -29,14 +29,14 @@ class MapperTest extends TestCase
|
|||
|
||||
public function provideMappings()
|
||||
{
|
||||
$format = json_decode(file_get_contents(__DIR__ . '/../../fixtures/ffprobe/show_format.json'), true);
|
||||
$streams = json_decode(file_get_contents(__DIR__ . '/../../fixtures/ffprobe/show_streams.json'), true);
|
||||
$format = json_decode(file_get_contents(__DIR__.'/../../fixtures/ffprobe/show_format.json'), true);
|
||||
$streams = json_decode(file_get_contents(__DIR__.'/../../fixtures/ffprobe/show_streams.json'), true);
|
||||
|
||||
return array(
|
||||
array(FFProbe::TYPE_FORMAT, $format, new Format($format['format'])),
|
||||
array(FFProbe::TYPE_STREAMS, $streams, new StreamCollection(array_map(function ($streamData) {
|
||||
return [
|
||||
[FFProbe::TYPE_FORMAT, $format, new Format($format['format'])],
|
||||
[FFProbe::TYPE_STREAMS, $streams, new StreamCollection(array_map(function ($streamData) {
|
||||
return new Stream($streamData);
|
||||
}, $streams['streams']))),
|
||||
);
|
||||
}, $streams['streams']))],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ class OptionsTesterTest extends TestCase
|
|||
$ffprobe = $this->getFFProbeDriverMock();
|
||||
$ffprobe->expects($this->once())
|
||||
->method('command')
|
||||
->with(array('-help', '-loglevel', 'quiet'))
|
||||
->with(['-help', '-loglevel', 'quiet'])
|
||||
->will($this->throwException($executionFailerExceptionMock));
|
||||
|
||||
$tester = new OptionsTester($ffprobe, $cache);
|
||||
|
|
@ -51,7 +51,7 @@ class OptionsTesterTest extends TestCase
|
|||
$ffprobe = $this->getFFProbeDriverMock();
|
||||
$ffprobe->expects($this->once())
|
||||
->method('command')
|
||||
->with(array('-help', '-loglevel', 'quiet'))
|
||||
->with(['-help', '-loglevel', 'quiet'])
|
||||
->will($this->returnValue($data));
|
||||
|
||||
$tester = new OptionsTester($ffprobe, $cache);
|
||||
|
|
@ -62,10 +62,10 @@ class OptionsTesterTest extends TestCase
|
|||
{
|
||||
$data = file_get_contents(__DIR__ . '/../../fixtures/ffprobe/help.raw');
|
||||
|
||||
return array(
|
||||
array(true, $data, '-print_format'),
|
||||
array(false, $data, '-another_print_format'),
|
||||
);
|
||||
return [
|
||||
[true, $data, '-print_format'],
|
||||
[false, $data, '-another_print_format'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\FFProbe;
|
||||
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\FFProbe\OutputParser;
|
||||
use FFMpeg\FFProbe;
|
||||
use FFMpeg\FFProbe\OutputParser;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class OutputParserTest extends TestCase
|
||||
{
|
||||
|
|
@ -26,15 +26,15 @@ class OutputParserTest extends TestCase
|
|||
|
||||
public function provideTypeDataAndOutput()
|
||||
{
|
||||
$expectedFormat = json_decode(file_get_contents(__DIR__ . '/../../fixtures/ffprobe/show_format.json'), true);
|
||||
$expectedStreams = json_decode(file_get_contents(__DIR__ . '/../../fixtures/ffprobe/show_streams.json'), true);
|
||||
$expectedFormat = json_decode(file_get_contents(__DIR__.'/../../fixtures/ffprobe/show_format.json'), true);
|
||||
$expectedStreams = json_decode(file_get_contents(__DIR__.'/../../fixtures/ffprobe/show_streams.json'), true);
|
||||
|
||||
$rawFormat = file_get_contents(__DIR__ . '/../../fixtures/ffprobe/show_format.raw');
|
||||
$rawStreams = file_get_contents(__DIR__ . '/../../fixtures/ffprobe/show_streams.raw');
|
||||
$rawFormat = file_get_contents(__DIR__.'/../../fixtures/ffprobe/show_format.raw');
|
||||
$rawStreams = file_get_contents(__DIR__.'/../../fixtures/ffprobe/show_streams.raw');
|
||||
|
||||
return array(
|
||||
array(FFProbe::TYPE_FORMAT, $rawFormat, $expectedFormat),
|
||||
array(FFProbe::TYPE_STREAMS, $rawStreams, $expectedStreams),
|
||||
);
|
||||
return [
|
||||
[FFProbe::TYPE_FORMAT, $rawFormat, $expectedFormat],
|
||||
[FFProbe::TYPE_STREAMS, $rawStreams, $expectedStreams],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -60,12 +60,12 @@ class FFProbeTest extends TestCase
|
|||
$stream = $this->getStreamMock();
|
||||
$format = $this->getFormatMock();
|
||||
|
||||
return array(
|
||||
array($stream, 'streams', array('-show_streams', '-print_format'), FFProbe::TYPE_STREAMS, array(__FILE__, '-show_streams', '-print_format', 'json'), false),
|
||||
array($format, 'format', array('-show_format', '-print_format'), FFProbe::TYPE_FORMAT, array(__FILE__, '-show_format', '-print_format', 'json'), false),
|
||||
array($stream, 'streams', array('-show_streams'), FFProbe::TYPE_STREAMS, array(__FILE__, '-show_streams'), true),
|
||||
array($format, 'format', array('-show_format'), FFProbe::TYPE_FORMAT, array(__FILE__, '-show_format'), true),
|
||||
);
|
||||
return [
|
||||
[$stream, 'streams', ['-show_streams', '-print_format'], FFProbe::TYPE_STREAMS, [__FILE__, '-show_streams', '-print_format', 'json'], false],
|
||||
[$format, 'format', ['-show_format', '-print_format'], FFProbe::TYPE_FORMAT, [__FILE__, '-show_format', '-print_format', 'json'], false],
|
||||
[$stream, 'streams', ['-show_streams'], FFProbe::TYPE_STREAMS, [__FILE__, '-show_streams'], true],
|
||||
[$format, 'format', ['-show_format'], FFProbe::TYPE_FORMAT, [__FILE__, '-show_format'], true],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -74,7 +74,7 @@ class FFProbeTest extends TestCase
|
|||
public function testProbeWithoutCache($output, $method, $commands, $type, $caughtCommands, $isRaw)
|
||||
{
|
||||
$pathfile = __FILE__;
|
||||
$data = array('key' => 'value');
|
||||
$data = ['key' => 'value'];
|
||||
$rawData = 'raw data';
|
||||
|
||||
$ffprobe = new FFProbe($this->getFFProbeDriverMock(), $this->getCacheMock());
|
||||
|
|
@ -122,7 +122,7 @@ class FFProbeTest extends TestCase
|
|||
->setFFProbeDriver($driver)
|
||||
->setParser($parser);
|
||||
|
||||
$this->assertEquals($output, call_user_func(array($ffprobe, $method), $pathfile));
|
||||
$this->assertEquals($output, call_user_func([$ffprobe, $method], $pathfile));
|
||||
}
|
||||
|
||||
public function provideDataForInvalidJson()
|
||||
|
|
@ -130,10 +130,10 @@ class FFProbeTest extends TestCase
|
|||
$stream = $this->getStreamMock();
|
||||
$format = $this->getFormatMock();
|
||||
|
||||
return array(
|
||||
array($stream, 'streams', array('-show_streams', '-print_format'), FFProbe::TYPE_STREAMS, array(__FILE__, '-show_streams', '-print_format', 'json')),
|
||||
array($format, 'format', array('-show_format', '-print_format'), FFProbe::TYPE_FORMAT, array(__FILE__, '-show_format', '-print_format', 'json')),
|
||||
);
|
||||
return [
|
||||
[$stream, 'streams', ['-show_streams', '-print_format'], FFProbe::TYPE_STREAMS, [__FILE__, '-show_streams', '-print_format', 'json']],
|
||||
[$format, 'format', ['-show_format', '-print_format'], FFProbe::TYPE_FORMAT, [__FILE__, '-show_format', '-print_format', 'json']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -142,7 +142,7 @@ class FFProbeTest extends TestCase
|
|||
public function testProbeWithWrongJson($output, $method, $commands, $type, $caughtCommands)
|
||||
{
|
||||
$pathfile = __FILE__;
|
||||
$data = array('key' => 'value');
|
||||
$data = ['key' => 'value'];
|
||||
|
||||
$ffprobe = new FFProbe($this->getFFProbeDriverMock(), $this->getCacheMock());
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ class FFProbeTest extends TestCase
|
|||
$parser = $this->getFFProbeParserMock();
|
||||
$parser->expects($this->once())
|
||||
->method('parse')
|
||||
->with($this->isType('string', json_encode($data) . 'lala'))
|
||||
->with($this->isType('string', json_encode($data).'lala'))
|
||||
->will($this->returnValue('good data parsed'));
|
||||
|
||||
$tester = $this->getFFProbeOptionsTesterMockWithOptions($commands);
|
||||
|
|
@ -171,7 +171,7 @@ class FFProbeTest extends TestCase
|
|||
$driver = $this->getFFProbeDriverMock();
|
||||
$driver->expects($this->exactly(2))
|
||||
->method('command')
|
||||
->will($this->returnValue(json_encode($data) . 'lala'));
|
||||
->will($this->returnValue(json_encode($data).'lala'));
|
||||
|
||||
$ffprobe->setOptionsTester($tester)
|
||||
->setCache($cache)
|
||||
|
|
@ -179,7 +179,7 @@ class FFProbeTest extends TestCase
|
|||
->setFFProbeDriver($driver)
|
||||
->setParser($parser);
|
||||
|
||||
$this->assertEquals($output, call_user_func(array($ffprobe, $method), $pathfile));
|
||||
$this->assertEquals($output, call_user_func([$ffprobe, $method], $pathfile));
|
||||
}
|
||||
|
||||
public function provideProbingDataWithCache()
|
||||
|
|
@ -187,10 +187,10 @@ class FFProbeTest extends TestCase
|
|||
$stream = $this->getStreamMock();
|
||||
$format = $this->getFormatMock();
|
||||
|
||||
return array(
|
||||
array($stream, 'streams'),
|
||||
array($format, 'format'),
|
||||
);
|
||||
return [
|
||||
[$stream, 'streams'],
|
||||
[$format, 'format'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -230,15 +230,15 @@ class FFProbeTest extends TestCase
|
|||
->setMapper($mapper)
|
||||
->setFFProbeDriver($driver);
|
||||
|
||||
$this->assertEquals($output, call_user_func(array($ffprobe, $method), $pathfile));
|
||||
$this->assertEquals($output, call_user_func([$ffprobe, $method], $pathfile));
|
||||
}
|
||||
|
||||
public function provideProbeMethod()
|
||||
{
|
||||
return array(
|
||||
array('streams'),
|
||||
array('format'),
|
||||
);
|
||||
return [
|
||||
['streams'],
|
||||
['format'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -251,7 +251,7 @@ class FFProbeTest extends TestCase
|
|||
|
||||
$ffprobe = new FFProbe($this->getFFProbeDriverMock(), $this->getCacheMock());
|
||||
$ffprobe->setOptionsTester($this->getFFProbeOptionsTesterMock());
|
||||
call_user_func(array($ffprobe, $method), $pathfile);
|
||||
call_user_func([$ffprobe, $method], $pathfile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -262,14 +262,14 @@ class FFProbeTest extends TestCase
|
|||
$finder = new ExecutableFinder();
|
||||
|
||||
$found = false;
|
||||
foreach (array('avprobe', 'ffprobe') as $name) {
|
||||
foreach (['avprobe', 'ffprobe'] as $name) {
|
||||
if (null !== $finder->find($name)) {
|
||||
$found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found) {
|
||||
$this->markTestSkipped("Unable to find avprobe or ffprobe on system");
|
||||
$this->markTestSkipped('Unable to find avprobe or ffprobe on system');
|
||||
}
|
||||
|
||||
$ffprobe = FFProbe::create();
|
||||
|
|
@ -291,11 +291,11 @@ class FFProbeTest extends TestCase
|
|||
|
||||
public function provideCreateOptions()
|
||||
{
|
||||
return array(
|
||||
array(null, array('key' => 'value'), null),
|
||||
array($this->getLoggerMock(), array('key' => 'value'), null),
|
||||
array(null, new Configuration(), null),
|
||||
array(null, array('key' => 'value'), $this->getCacheMock()),
|
||||
);
|
||||
return [
|
||||
[null, ['key' => 'value'], null],
|
||||
[$this->getLoggerMock(), ['key' => 'value'], null],
|
||||
[null, new Configuration(), null],
|
||||
[null, ['key' => 'value'], $this->getCacheMock()],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -2,13 +2,14 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\Filters\Audio;
|
||||
|
||||
use FFMpeg\Filters\Audio\AudioFilters;
|
||||
use FFMpeg\Coordinate\TimeCode;
|
||||
use FFMpeg\Filters\Audio\AudioFilters;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class AudioClipTest extends TestCase {
|
||||
|
||||
public function testClipping() {
|
||||
class AudioClipTest extends TestCase
|
||||
{
|
||||
public function testClipping()
|
||||
{
|
||||
$capturedFilter = null;
|
||||
|
||||
$audio = $this->getAudioMock();
|
||||
|
|
@ -17,16 +18,17 @@ class AudioClipTest extends TestCase {
|
|||
->with($this->isInstanceOf('FFMpeg\Filters\Audio\AudioClipFilter'))
|
||||
->will($this->returnCallback(function ($filter) use (&$capturedFilter) {
|
||||
$capturedFilter = $filter;
|
||||
}));
|
||||
}));
|
||||
$format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
|
||||
|
||||
$filters = new AudioFilters($audio);
|
||||
|
||||
$filters->clip(TimeCode::fromSeconds(5));
|
||||
$this->assertEquals(array(0 => '-ss', 1 => '00:00:05.00', 2 => '-acodec', 3 => 'copy'), $capturedFilter->apply($audio, $format));
|
||||
$this->assertEquals([0 => '-ss', 1 => '00:00:05.00', 2 => '-acodec', 3 => 'copy'], $capturedFilter->apply($audio, $format));
|
||||
}
|
||||
|
||||
public function testClippingWithDuration() {
|
||||
public function testClippingWithDuration()
|
||||
{
|
||||
$capturedFilter = null;
|
||||
|
||||
$audio = $this->getAudioMock();
|
||||
|
|
@ -35,13 +37,12 @@ class AudioClipTest extends TestCase {
|
|||
->with($this->isInstanceOf('FFMpeg\Filters\Audio\AudioClipFilter'))
|
||||
->will($this->returnCallback(function ($filter) use (&$capturedFilter) {
|
||||
$capturedFilter = $filter;
|
||||
}));
|
||||
}));
|
||||
$format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
|
||||
|
||||
$filters = new AudioFilters($audio);
|
||||
|
||||
$filters->clip(TimeCode::fromSeconds(5), TimeCode::fromSeconds(5));
|
||||
$this->assertEquals(array(0 => '-ss', 1 => '00:00:05.00', 2 => '-t', 3 => '00:00:05.00', 4 => '-acodec', 5 => 'copy'), $capturedFilter->apply($audio, $format));
|
||||
$this->assertEquals([0 => '-ss', 1 => '00:00:05.00', 2 => '-t', 3 => '00:00:05.00', 4 => '-acodec', 5 => 'copy'], $capturedFilter->apply($audio, $format));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -21,8 +21,8 @@ class AudioMetadataTest extends TestCase
|
|||
$format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
|
||||
|
||||
$filters = new AudioFilters($audio);
|
||||
$filters->addMetadata(array('title' => "Hello World"));
|
||||
$this->assertEquals(array(0 => "-metadata", 1 => "title=Hello World"), $capturedFilter->apply($audio, $format));
|
||||
$filters->addMetadata(['title' => 'Hello World']);
|
||||
$this->assertEquals([0 => '-metadata', 1 => 'title=Hello World'], $capturedFilter->apply($audio, $format));
|
||||
}
|
||||
|
||||
public function testAddArtwork()
|
||||
|
|
@ -39,9 +39,9 @@ class AudioMetadataTest extends TestCase
|
|||
$format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
|
||||
|
||||
$filters = new AudioFilters($audio);
|
||||
$filters->addMetadata(array('genre' => 'Some Genre', 'artwork' => "/path/to/file.jpg"));
|
||||
$this->assertEquals(array(0 => "-i", 1 => "/path/to/file.jpg", 2 => "-map", 3 => "0", 4 => "-map", 5 => "1", 6 => "-metadata", 7 => "genre=Some Genre"), $capturedFilter->apply($audio, $format));
|
||||
$this->assertEquals(array(0 => "-i", 1 => "/path/to/file.jpg", 2 => "-map", 3 => "0", 4 => "-map", 5 => "1", 6 => "-metadata", 7 => "genre=Some Genre"), $capturedFilter->apply($audio, $format));
|
||||
$filters->addMetadata(['genre' => 'Some Genre', 'artwork' => '/path/to/file.jpg']);
|
||||
$this->assertEquals([0 => '-i', 1 => '/path/to/file.jpg', 2 => '-map', 3 => '0', 4 => '-map', 5 => '1', 6 => '-metadata', 7 => 'genre=Some Genre'], $capturedFilter->apply($audio, $format));
|
||||
$this->assertEquals([0 => '-i', 1 => '/path/to/file.jpg', 2 => '-map', 3 => '0', 4 => '-map', 5 => '1', 6 => '-metadata', 7 => 'genre=Some Genre'], $capturedFilter->apply($audio, $format));
|
||||
}
|
||||
|
||||
public function testRemoveMetadata()
|
||||
|
|
@ -59,6 +59,6 @@ class AudioMetadataTest extends TestCase
|
|||
|
||||
$filters = new AudioFilters($audio);
|
||||
$filters->addMetadata();
|
||||
$this->assertEquals(array(0 => "-map_metadata", 1 => "-1", 2 => "-vn"), $capturedFilter->apply($audio, $format));
|
||||
$this->assertEquals([0 => '-map_metadata', 1 => '-1', 2 => '-vn'], $capturedFilter->apply($audio, $format));
|
||||
}
|
||||
}
|
||||
|
|
@ -19,6 +19,6 @@ class AudioResamplableFilterTest extends TestCase
|
|||
$format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
|
||||
|
||||
$filter = new AudioResamplableFilter(500);
|
||||
$this->assertEquals(array('-ac', 2, '-ar', 500), $filter->apply($audio, $format));
|
||||
$this->assertEquals(['-ac', 2, '-ar', 500], $filter->apply($audio, $format));
|
||||
}
|
||||
}
|
||||
|
|
@ -3,9 +3,7 @@
|
|||
namespace Tests\FFMpeg\Unit\Filters\Audio;
|
||||
|
||||
use FFMpeg\Filters\Audio\CustomFilter;
|
||||
use FFMpeg\Filters\Audio\FrameRateFilter;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\Coordinate\FrameRate;
|
||||
|
||||
class CustomFilterTest extends TestCase
|
||||
{
|
||||
|
|
@ -15,6 +13,6 @@ class CustomFilterTest extends TestCase
|
|||
$format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
|
||||
|
||||
$filter = new CustomFilter('whatever i put would end up as a filter');
|
||||
$this->assertEquals(array('-af', 'whatever i put would end up as a filter'), $filter->apply($audio, $format));
|
||||
$this->assertEquals(['-af', 'whatever i put would end up as a filter'], $filter->apply($audio, $format));
|
||||
}
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\Filters;
|
||||
|
||||
use FFMpeg\Filters\FiltersCollection;
|
||||
use FFMpeg\Filters\Audio\SimpleFilter;
|
||||
use FFMpeg\Filters\FiltersCollection;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class FiltersCollectionTest extends TestCase
|
||||
|
|
@ -39,17 +39,17 @@ class FiltersCollectionTest extends TestCase
|
|||
public function testIteratorSort()
|
||||
{
|
||||
$coll = new FiltersCollection();
|
||||
$coll->add(new SimpleFilter(array('a')));
|
||||
$coll->add(new SimpleFilter(array('1'), 12));
|
||||
$coll->add(new SimpleFilter(array('b')));
|
||||
$coll->add(new SimpleFilter(array('2'), 12));
|
||||
$coll->add(new SimpleFilter(array('c')));
|
||||
$coll->add(new SimpleFilter(array('3'), 10));
|
||||
$coll->add(new SimpleFilter(array('d')));
|
||||
$coll->add(new SimpleFilter(array('4'), -2));
|
||||
$coll->add(new SimpleFilter(array('e')));
|
||||
$coll->add(new SimpleFilter(['a']));
|
||||
$coll->add(new SimpleFilter(['1'], 12));
|
||||
$coll->add(new SimpleFilter(['b']));
|
||||
$coll->add(new SimpleFilter(['2'], 12));
|
||||
$coll->add(new SimpleFilter(['c']));
|
||||
$coll->add(new SimpleFilter(['3'], 10));
|
||||
$coll->add(new SimpleFilter(['d']));
|
||||
$coll->add(new SimpleFilter(['4'], -2));
|
||||
$coll->add(new SimpleFilter(['e']));
|
||||
|
||||
$data = array();
|
||||
$data = [];
|
||||
$video = $this->getVideoMock();
|
||||
$format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
|
||||
|
||||
|
|
@ -57,6 +57,6 @@ class FiltersCollectionTest extends TestCase
|
|||
$data = array_merge($data, $filter->apply($video, $format));
|
||||
}
|
||||
|
||||
$this->assertEquals(array('1', '2', '3', 'a', 'b', 'c', 'd', 'e', '4'), $data);
|
||||
$this->assertEquals(['1', '2', '3', 'a', 'b', 'c', 'd', 'e', '4'], $data);
|
||||
}
|
||||
}
|
||||
|
|
@ -12,6 +12,6 @@ class CustomFrameFilterTest extends TestCase
|
|||
$frame = $this->getFrameMock();
|
||||
|
||||
$filter = new CustomFrameFilter('whatever i put would end up as a filter');
|
||||
$this->assertEquals(array('-vf', 'whatever i put would end up as a filter'), $filter->apply($frame));
|
||||
$this->assertEquals(['-vf', 'whatever i put would end up as a filter'], $filter->apply($frame));
|
||||
}
|
||||
}
|
||||
|
|
@ -2,19 +2,19 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\Filters\Frame;
|
||||
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\Coordinate\TimeCode;
|
||||
use FFMpeg\FFProbe\DataMapping\Stream;
|
||||
use FFMpeg\FFProbe\DataMapping\StreamCollection;
|
||||
use FFMpeg\Filters\Frame\DisplayRatioFixerFilter;
|
||||
use FFMpeg\Media\Frame;
|
||||
use FFMpeg\Coordinate\TimeCode;
|
||||
use FFMpeg\FFProbe\DataMapping\StreamCollection;
|
||||
use FFMpeg\FFProbe\DataMapping\Stream;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class DisplayRatioFixerFilterTest extends TestCase
|
||||
{
|
||||
public function testApply()
|
||||
{
|
||||
$stream = new Stream(array('codec_type' => 'video', 'width' => 960, 'height' => 720));
|
||||
$streams = new StreamCollection(array($stream));
|
||||
$stream = new Stream(['codec_type' => 'video', 'width' => 960, 'height' => 720]);
|
||||
$streams = new StreamCollection([$stream]);
|
||||
|
||||
$video = $this->getVideoMock(__FILE__);
|
||||
$video->expects($this->once())
|
||||
|
|
@ -23,6 +23,6 @@ class DisplayRatioFixerFilterTest extends TestCase
|
|||
|
||||
$frame = new Frame($video, $this->getFFMpegDriverMock(), $this->getFFProbeMock(), new TimeCode(0, 0, 0, 0));
|
||||
$filter = new DisplayRatioFixerFilter();
|
||||
$this->assertEquals(array('-s', '960x720'), $filter->apply($frame));
|
||||
$this->assertEquals(['-s', '960x720'], $filter->apply($frame));
|
||||
}
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\Filters\Frame;
|
||||
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\Filters\Frame\FrameFilters;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class FrameFiltersTest extends TestCase
|
||||
{
|
||||
|
|
@ -11,11 +11,10 @@ use Tests\FFMpeg\Unit\TestCase;
|
|||
|
||||
class CropFilterTest extends TestCase
|
||||
{
|
||||
|
||||
public function testCommandParamsAreCorrectAndStreamIsUpdated()
|
||||
{
|
||||
$stream = new Stream(array('width' => 320, 'height' => 240, 'codec_type' => 'video'));
|
||||
$streams = new StreamCollection(array($stream));
|
||||
$stream = new Stream(['width' => 320, 'height' => 240, 'codec_type' => 'video']);
|
||||
$streams = new StreamCollection([$stream]);
|
||||
|
||||
$video = $this->getVideoMock();
|
||||
$video->expects($this->once())
|
||||
|
|
@ -27,14 +26,13 @@ class CropFilterTest extends TestCase
|
|||
$dimension = new Dimension(200, 150);
|
||||
$point = new Point(25, 35);
|
||||
$filter = new CropFilter($point, $dimension);
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'-filter:v',
|
||||
'crop=' . $dimension->getWidth() . ":" . $dimension->getHeight() . ":" . $point->getX() . ":" . $point->getY()
|
||||
);
|
||||
'crop='.$dimension->getWidth().':'.$dimension->getHeight().':'.$point->getX().':'.$point->getY(),
|
||||
];
|
||||
$this->assertEquals($expected, $filter->apply($video, $format));
|
||||
|
||||
$this->assertEquals(200, $stream->get('width'));
|
||||
$this->assertEquals(150, $stream->get('height'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -3,9 +3,7 @@
|
|||
namespace Tests\FFMpeg\Unit\Filters\Video;
|
||||
|
||||
use FFMpeg\Filters\Video\CustomFilter;
|
||||
use FFMpeg\Filters\Video\FrameRateFilter;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\Coordinate\FrameRate;
|
||||
|
||||
class CustomFilterTest extends TestCase
|
||||
{
|
||||
|
|
@ -15,6 +13,6 @@ class CustomFilterTest extends TestCase
|
|||
$format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
|
||||
$filter = new CustomFilter('whatever i put would end up as a filter');
|
||||
$this->assertEquals(array('-vf', 'whatever i put would end up as a filter'), $filter->apply($video, $format));
|
||||
$this->assertEquals(['-vf', 'whatever i put would end up as a filter'], $filter->apply($video, $format));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\FFMpeg\Unit\Filters\Video;
|
||||
|
||||
use FFMpeg\FFProbe\DataMapping\Stream;
|
||||
use FFMpeg\FFProbe\DataMapping\StreamCollection;
|
||||
use FFMpeg\Filters\Video\ExtractMultipleFramesFilter;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class ExtractMultipleFramesFilterTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideFrameRates
|
||||
*/
|
||||
public function testApply($frameRate, $frameFileType, $destinationFolder, $duration, $modulus, $expected)
|
||||
{
|
||||
$video = $this->getVideoMock();
|
||||
$pathfile = '/path/to/file'.mt_rand();
|
||||
|
||||
$format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
$format->expects($this->any())
|
||||
->method('getModulus')
|
||||
->will($this->returnValue($modulus));
|
||||
|
||||
$streams = new StreamCollection([
|
||||
new Stream([
|
||||
'codec_type' => 'video',
|
||||
'duration' => $duration,
|
||||
]),
|
||||
]);
|
||||
|
||||
$video->expects($this->once())
|
||||
->method('getStreams')
|
||||
->will($this->returnValue($streams));
|
||||
|
||||
$filter = new ExtractMultipleFramesFilter($frameRate, $destinationFolder);
|
||||
$filter->setFrameFileType($frameFileType);
|
||||
$this->assertEquals($expected, $filter->apply($video, $format));
|
||||
}
|
||||
|
||||
public function provideFrameRates()
|
||||
{
|
||||
return [
|
||||
[ExtractMultipleFramesFilter::FRAMERATE_EVERY_SEC, 'jpg', '/', 100, 2, ['-vf', 'fps=1/1', '/frame-%03d.jpg']],
|
||||
[ExtractMultipleFramesFilter::FRAMERATE_EVERY_2SEC, 'jpg', '/', 100, 2, ['-vf', 'fps=1/2', '/frame-%02d.jpg']],
|
||||
[ExtractMultipleFramesFilter::FRAMERATE_EVERY_5SEC, 'jpg', '/', 100, 2, ['-vf', 'fps=1/5', '/frame-%02d.jpg']],
|
||||
[ExtractMultipleFramesFilter::FRAMERATE_EVERY_10SEC, 'jpg', '/', 100, 2, ['-vf', 'fps=1/10', '/frame-%02d.jpg']],
|
||||
[ExtractMultipleFramesFilter::FRAMERATE_EVERY_30SEC, 'jpg', '/', 100, 2, ['-vf', 'fps=1/30', '/frame-%02d.jpg']],
|
||||
[ExtractMultipleFramesFilter::FRAMERATE_EVERY_60SEC, 'jpg', '/', 100, 2, ['-vf', 'fps=1/60', '/frame-%02d.jpg']],
|
||||
|
||||
[ExtractMultipleFramesFilter::FRAMERATE_EVERY_SEC, 'jpeg', '/', 100, 2, ['-vf', 'fps=1/1', '/frame-%03d.jpeg']],
|
||||
[ExtractMultipleFramesFilter::FRAMERATE_EVERY_2SEC, 'jpeg', '/', 100, 2, ['-vf', 'fps=1/2', '/frame-%02d.jpeg']],
|
||||
[ExtractMultipleFramesFilter::FRAMERATE_EVERY_5SEC, 'jpeg', '/', 100, 2, ['-vf', 'fps=1/5', '/frame-%02d.jpeg']],
|
||||
[ExtractMultipleFramesFilter::FRAMERATE_EVERY_10SEC, 'jpeg', '/', 100, 2, ['-vf', 'fps=1/10', '/frame-%02d.jpeg']],
|
||||
[ExtractMultipleFramesFilter::FRAMERATE_EVERY_30SEC, 'jpeg', '/', 100, 2, ['-vf', 'fps=1/30', '/frame-%02d.jpeg']],
|
||||
[ExtractMultipleFramesFilter::FRAMERATE_EVERY_60SEC, 'jpeg', '/', 100, 2, ['-vf', 'fps=1/60', '/frame-%02d.jpeg']],
|
||||
|
||||
[ExtractMultipleFramesFilter::FRAMERATE_EVERY_SEC, 'png', '/', 100, 2, ['-vf', 'fps=1/1', '/frame-%03d.png']],
|
||||
[ExtractMultipleFramesFilter::FRAMERATE_EVERY_2SEC, 'png', '/', 100, 2, ['-vf', 'fps=1/2', '/frame-%02d.png']],
|
||||
[ExtractMultipleFramesFilter::FRAMERATE_EVERY_5SEC, 'png', '/', 100, 2, ['-vf', 'fps=1/5', '/frame-%02d.png']],
|
||||
[ExtractMultipleFramesFilter::FRAMERATE_EVERY_10SEC, 'png', '/', 100, 2, ['-vf', 'fps=1/10', '/frame-%02d.png']],
|
||||
[ExtractMultipleFramesFilter::FRAMERATE_EVERY_30SEC, 'png', '/', 100, 2, ['-vf', 'fps=1/30', '/frame-%02d.png']],
|
||||
[ExtractMultipleFramesFilter::FRAMERATE_EVERY_60SEC, 'png', '/', 100, 2, ['-vf', 'fps=1/60', '/frame-%02d.png']],
|
||||
];
|
||||
}
|
||||
|
||||
public function testInvalidFrameFileType()
|
||||
{
|
||||
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
||||
$filter = new ExtractMultipleFramesFilter('1/1', '/');
|
||||
$filter->setFrameFileType('webm');
|
||||
}
|
||||
}
|
||||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\Filters\Video;
|
||||
|
||||
use FFMpeg\Coordinate\FrameRate;
|
||||
use FFMpeg\Filters\Video\FrameRateFilter;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\Coordinate\FrameRate;
|
||||
|
||||
class FrameRateFilterTest extends TestCase
|
||||
{
|
||||
|
|
@ -19,7 +19,7 @@ class FrameRateFilterTest extends TestCase
|
|||
->method('supportBFrames')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$expected = array('-r', 54, '-b_strategy', '1', '-bf', '3', '-g', 42);
|
||||
$expected = ['-r', 54, '-b_strategy', '1', '-bf', '3', '-g', 42];
|
||||
|
||||
$filter = new FrameRateFilter($framerate, $gop);
|
||||
$this->assertEquals($expected, $filter->apply($video, $format));
|
||||
|
|
@ -36,7 +36,7 @@ class FrameRateFilterTest extends TestCase
|
|||
->method('supportBFrames')
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$expected = array('-r', 54);
|
||||
$expected = ['-r', 54];
|
||||
|
||||
$filter = new FrameRateFilter($framerate, $gop);
|
||||
$this->assertEquals($expected, $filter->apply($video, $format));
|
||||
44
tests/FFMpeg/Unit/Filters/Video/PadFilterTest.php
Normal file
44
tests/FFMpeg/Unit/Filters/Video/PadFilterTest.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\FFMpeg\Unit\Filters\Video;
|
||||
|
||||
use FFMpeg\Coordinate\Dimension;
|
||||
use FFMpeg\FFProbe\DataMapping\Stream;
|
||||
use FFMpeg\FFProbe\DataMapping\StreamCollection;
|
||||
use FFMpeg\Filters\Video\PadFilter;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class PadFilterTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideDimensions
|
||||
*/
|
||||
public function testApply(Dimension $dimension, $width, $height, $expected)
|
||||
{
|
||||
$video = $this->getVideoMock();
|
||||
$pathfile = '/path/to/file'.mt_rand();
|
||||
|
||||
$format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
|
||||
$streams = new StreamCollection([
|
||||
new Stream([
|
||||
'codec_type' => 'video',
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
]),
|
||||
]);
|
||||
|
||||
$filter = new PadFilter($dimension);
|
||||
$this->assertEquals($expected, $filter->apply($video, $format));
|
||||
}
|
||||
|
||||
public function provideDimensions()
|
||||
{
|
||||
return [
|
||||
[new Dimension(1000, 800), 640, 480, ['-vf', 'scale=iw*min(1000/iw\,800/ih):ih*min(1000/iw\,800/ih),pad=1000:800:(1000-iw)/2:(800-ih)/2']],
|
||||
[new Dimension(300, 600), 640, 480, ['-vf', 'scale=iw*min(300/iw\,600/ih):ih*min(300/iw\,600/ih),pad=300:600:(300-iw)/2:(600-ih)/2']],
|
||||
[new Dimension(100, 900), 640, 480, ['-vf', 'scale=iw*min(100/iw\,900/ih):ih*min(100/iw\,900/ih),pad=100:900:(100-iw)/2:(900-ih)/2']],
|
||||
[new Dimension(1200, 200), 640, 480, ['-vf', 'scale=iw*min(1200/iw\,200/ih):ih*min(1200/iw\,200/ih),pad=1200:200:(1200-iw)/2:(200-ih)/2']],
|
||||
];
|
||||
}
|
||||
}
|
||||
75
tests/FFMpeg/Unit/Filters/Video/ResizeFilterTest.php
Normal file
75
tests/FFMpeg/Unit/Filters/Video/ResizeFilterTest.php
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\FFMpeg\Unit\Filters\Video;
|
||||
|
||||
use FFMpeg\Coordinate\Dimension;
|
||||
use FFMpeg\FFProbe\DataMapping\Stream;
|
||||
use FFMpeg\FFProbe\DataMapping\StreamCollection;
|
||||
use FFMpeg\Filters\Video\ResizeFilter;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class ResizeFilterTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideDimensions
|
||||
*/
|
||||
public function testApply(Dimension $dimension, $mode, $width, $height, $modulus, $expected, $forceStandards = true)
|
||||
{
|
||||
$video = $this->getVideoMock();
|
||||
$pathfile = '/path/to/file'.mt_rand();
|
||||
|
||||
$format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
$format->expects($this->any())
|
||||
->method('getModulus')
|
||||
->will($this->returnValue($modulus));
|
||||
|
||||
$streams = new StreamCollection([
|
||||
new Stream([
|
||||
'codec_type' => 'video',
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
]),
|
||||
]);
|
||||
|
||||
$video->expects($this->once())
|
||||
->method('getStreams')
|
||||
->will($this->returnValue($streams));
|
||||
|
||||
$filter = new ResizeFilter($dimension, $mode, $forceStandards);
|
||||
$this->assertEquals($expected, $filter->apply($video, $format));
|
||||
}
|
||||
|
||||
public function provideDimensions()
|
||||
{
|
||||
return [
|
||||
[new Dimension(320, 240), ResizeFilter::RESIZEMODE_FIT, 640, 480, 2, ['-vf', '[in]scale=320:240 [out]']],
|
||||
[new Dimension(320, 240), ResizeFilter::RESIZEMODE_INSET, 640, 480, 2, ['-vf', '[in]scale=320:240 [out]']],
|
||||
[new Dimension(320, 240), ResizeFilter::RESIZEMODE_SCALE_HEIGHT, 640, 480, 2, ['-vf', '[in]scale=320:240 [out]']],
|
||||
[new Dimension(320, 240), ResizeFilter::RESIZEMODE_SCALE_WIDTH, 640, 480, 2, ['-vf', '[in]scale=320:240 [out]']],
|
||||
|
||||
[new Dimension(640, 480), ResizeFilter::RESIZEMODE_FIT, 320, 240, 2, ['-vf', '[in]scale=640:480 [out]']],
|
||||
[new Dimension(640, 480), ResizeFilter::RESIZEMODE_INSET, 320, 240, 2, ['-vf', '[in]scale=640:480 [out]']],
|
||||
[new Dimension(640, 480), ResizeFilter::RESIZEMODE_SCALE_HEIGHT, 320, 240, 2, ['-vf', '[in]scale=640:480 [out]']],
|
||||
[new Dimension(640, 480), ResizeFilter::RESIZEMODE_SCALE_WIDTH, 320, 240, 2, ['-vf', '[in]scale=640:480 [out]']],
|
||||
|
||||
[new Dimension(640, 360), ResizeFilter::RESIZEMODE_FIT, 1280, 720, 2, ['-vf', '[in]scale=640:360 [out]']],
|
||||
[new Dimension(640, 360), ResizeFilter::RESIZEMODE_INSET, 1280, 720, 2, ['-vf', '[in]scale=640:360 [out]']],
|
||||
[new Dimension(640, 360), ResizeFilter::RESIZEMODE_SCALE_HEIGHT, 1280, 720, 2, ['-vf', '[in]scale=640:360 [out]']],
|
||||
[new Dimension(640, 360), ResizeFilter::RESIZEMODE_SCALE_WIDTH, 1280, 720, 2, ['-vf', '[in]scale=640:360 [out]']],
|
||||
|
||||
[new Dimension(640, 360), ResizeFilter::RESIZEMODE_FIT, 1280, 720, 2, ['-vf', '[in]scale=640:360 [out]']],
|
||||
[new Dimension(640, 360), ResizeFilter::RESIZEMODE_INSET, 1280, 720, 2, ['-vf', '[in]scale=640:360 [out]']],
|
||||
[new Dimension(640, 360), ResizeFilter::RESIZEMODE_SCALE_HEIGHT, 1280, 720, 2, ['-vf', '[in]scale=640:360 [out]']],
|
||||
[new Dimension(640, 360), ResizeFilter::RESIZEMODE_SCALE_WIDTH, 1280, 720, 2, ['-vf', '[in]scale=640:360 [out]']],
|
||||
|
||||
// test non standard dimension
|
||||
[new Dimension(700, 150), ResizeFilter::RESIZEMODE_INSET, 123, 456, 2, ['-vf', '[in]scale=62:150 [out]'], true],
|
||||
[new Dimension(700, 150), ResizeFilter::RESIZEMODE_INSET, 123, 456, 2, ['-vf', '[in]scale=40:150 [out]'], false],
|
||||
|
||||
[new Dimension(320, 320), ResizeFilter::RESIZEMODE_FIT, 640, 480, 2, ['-vf', '[in]scale=320:320 [out]']],
|
||||
[new Dimension(320, 320), ResizeFilter::RESIZEMODE_INSET, 640, 480, 2, ['-vf', '[in]scale=320:240 [out]']],
|
||||
[new Dimension(320, 320), ResizeFilter::RESIZEMODE_SCALE_HEIGHT, 640, 480, 2, ['-vf', '[in]scale=320:240 [out]']],
|
||||
[new Dimension(320, 320), ResizeFilter::RESIZEMODE_SCALE_WIDTH, 640, 480, 2, ['-vf', '[in]scale=426:320 [out]']],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -14,8 +14,8 @@ class RotateFilterTest extends TestCase
|
|||
*/
|
||||
public function testApplyWithSizeTransformation($value)
|
||||
{
|
||||
$stream = new Stream(array('width' => 320, 'height' => 240, 'codec_type' => 'video'));
|
||||
$streams = new StreamCollection(array($stream));
|
||||
$stream = new Stream(['width' => 320, 'height' => 240, 'codec_type' => 'video']);
|
||||
$streams = new StreamCollection([$stream]);
|
||||
|
||||
$video = $this->getVideoMock();
|
||||
$video->expects($this->once())
|
||||
|
|
@ -25,7 +25,7 @@ class RotateFilterTest extends TestCase
|
|||
$format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
|
||||
$filter = new RotateFilter($value);
|
||||
$this->assertEquals(array('-vf', $value, '-metadata:s:v:0', 'rotate=0'), $filter->apply($video, $format));
|
||||
$this->assertEquals(['-vf', $value, '-metadata:s:v:0', 'rotate=0'], $filter->apply($video, $format));
|
||||
|
||||
$this->assertEquals(240, $stream->get('width'));
|
||||
$this->assertEquals(320, $stream->get('height'));
|
||||
|
|
@ -33,10 +33,10 @@ class RotateFilterTest extends TestCase
|
|||
|
||||
public function provide90degresTranspositions()
|
||||
{
|
||||
return array(
|
||||
array(RotateFilter::ROTATE_90),
|
||||
array(RotateFilter::ROTATE_270),
|
||||
);
|
||||
return [
|
||||
[RotateFilter::ROTATE_90],
|
||||
[RotateFilter::ROTATE_270],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -51,14 +51,14 @@ class RotateFilterTest extends TestCase
|
|||
$format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
|
||||
$filter = new RotateFilter($value);
|
||||
$this->assertEquals(array('-vf', $value, '-metadata:s:v:0', 'rotate=0'), $filter->apply($video, $format));
|
||||
$this->assertEquals(['-vf', $value, '-metadata:s:v:0', 'rotate=0'], $filter->apply($video, $format));
|
||||
}
|
||||
|
||||
public function provideDegresWithoutTranspositions()
|
||||
{
|
||||
return array(
|
||||
array(RotateFilter::ROTATE_180),
|
||||
);
|
||||
return [
|
||||
[RotateFilter::ROTATE_180],
|
||||
];
|
||||
}
|
||||
|
||||
public function testApplyInvalidAngle()
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\Filters\Video;
|
||||
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\Filters\Video\SynchronizeFilter;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class SynchronizeFilterTest extends TestCase
|
||||
{
|
||||
|
|
@ -13,6 +13,6 @@ class SynchronizeFilterTest extends TestCase
|
|||
$format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
|
||||
$filter = new SynchronizeFilter();
|
||||
$this->assertEquals(array('-async', '1', '-metadata:s:v:0', 'start_time=0'), $filter->apply($video, $format));
|
||||
$this->assertEquals(['-async', '1', '-metadata:s:v:0', 'start_time=0'], $filter->apply($video, $format));
|
||||
}
|
||||
}
|
||||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\Filters\Video;
|
||||
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\Filters\Video\VideoFilters;
|
||||
use FFMpeg\Filters\Video\ResizeFilter;
|
||||
use FFMpeg\Filters\Video\VideoFilters;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class VideoFiltersTest extends TestCase
|
||||
{
|
||||
|
|
@ -35,12 +35,12 @@ class VideoFiltersTest extends TestCase
|
|||
|
||||
public function provideResizeOptions()
|
||||
{
|
||||
return array(
|
||||
array(ResizeFilter::RESIZEMODE_FIT, true),
|
||||
array(ResizeFilter::RESIZEMODE_SCALE_WIDTH, true),
|
||||
array(ResizeFilter::RESIZEMODE_SCALE_HEIGHT, false),
|
||||
array(ResizeFilter::RESIZEMODE_INSET, false),
|
||||
);
|
||||
return [
|
||||
[ResizeFilter::RESIZEMODE_FIT, true],
|
||||
[ResizeFilter::RESIZEMODE_SCALE_WIDTH, true],
|
||||
[ResizeFilter::RESIZEMODE_SCALE_HEIGHT, false],
|
||||
[ResizeFilter::RESIZEMODE_INSET, false],
|
||||
];
|
||||
}
|
||||
|
||||
public function testResample()
|
||||
62
tests/FFMpeg/Unit/Filters/Video/WatermarkFilterTest.php
Normal file
62
tests/FFMpeg/Unit/Filters/Video/WatermarkFilterTest.php
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\FFMpeg\Unit\Filters\Video;
|
||||
|
||||
use FFMpeg\FFProbe\DataMapping\Stream;
|
||||
use FFMpeg\FFProbe\DataMapping\StreamCollection;
|
||||
use FFMpeg\Filters\Video\WatermarkFilter;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class WatermarkFilterTest extends TestCase
|
||||
{
|
||||
public function testApplyWatermark()
|
||||
{
|
||||
$stream = new Stream(['width' => 320, 'height' => 240, 'codec_type' => 'video']);
|
||||
$streams = new StreamCollection([$stream]);
|
||||
|
||||
$video = $this->getVideoMock();
|
||||
|
||||
$format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
|
||||
$filter = new WatermarkFilter(__DIR__.'/../../../files/watermark.png');
|
||||
$this->assertEquals(['-vf', 'movie='.__DIR__.'/../../../files/watermark.png [watermark]; [in][watermark] overlay=0:0 [out]'], $filter->apply($video, $format));
|
||||
|
||||
// check size of video is unchanged
|
||||
$this->assertEquals(320, $stream->get('width'));
|
||||
$this->assertEquals(240, $stream->get('height'));
|
||||
}
|
||||
|
||||
public function testDifferentCoordinaates()
|
||||
{
|
||||
$video = $this->getVideoMock();
|
||||
$format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
|
||||
// test position absolute
|
||||
$filter = new WatermarkFilter(__DIR__.'/../../../files/watermark.png', [
|
||||
'position' => 'absolute',
|
||||
'x' => 10, 'y' => 5,
|
||||
]);
|
||||
$this->assertEquals(['-vf', 'movie='.__DIR__.'/../../../files/watermark.png [watermark]; [in][watermark] overlay=10:5 [out]'], $filter->apply($video, $format));
|
||||
|
||||
// test position relative
|
||||
$filter = new WatermarkFilter(__DIR__.'/../../../files/watermark.png', [
|
||||
'position' => 'relative',
|
||||
'bottom' => 10, 'left' => 5,
|
||||
]);
|
||||
$this->assertEquals(['-vf', 'movie='.__DIR__.'/../../../files/watermark.png [watermark]; [in][watermark] overlay=5:main_h - 10 - overlay_h [out]'], $filter->apply($video, $format));
|
||||
|
||||
// test position relative
|
||||
$filter = new WatermarkFilter(__DIR__.'/../../../files/watermark.png', [
|
||||
'position' => 'relative',
|
||||
'bottom' => 5, 'right' => 4,
|
||||
]);
|
||||
$this->assertEquals(['-vf', 'movie='.__DIR__.'/../../../files/watermark.png [watermark]; [in][watermark] overlay=main_w - 4 - overlay_w:main_h - 5 - overlay_h [out]'], $filter->apply($video, $format));
|
||||
|
||||
// test position relative
|
||||
$filter = new WatermarkFilter(__DIR__.'/../../../files/watermark.png', [
|
||||
'position' => 'relative',
|
||||
'left' => 5, 'top' => 11,
|
||||
]);
|
||||
$this->assertEquals(['-vf', 'movie='.__DIR__.'/../../../files/watermark.png [watermark]; [in][watermark] overlay=5:11 [out]'], $filter->apply($video, $format));
|
||||
}
|
||||
}
|
||||
|
|
@ -2,19 +2,18 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\Filters\Waveform;
|
||||
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\FFProbe\DataMapping\Stream;
|
||||
use FFMpeg\FFProbe\DataMapping\StreamCollection;
|
||||
use FFMpeg\Filters\Waveform\WaveformDownmixFilter;
|
||||
use FFMpeg\Media\Waveform;
|
||||
use FFMpeg\Coordinate\TimeCode;
|
||||
use FFMpeg\FFProbe\DataMapping\StreamCollection;
|
||||
use FFMpeg\FFProbe\DataMapping\Stream;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class WaveformDownmixFilterTest extends TestCase
|
||||
{
|
||||
public function testApply()
|
||||
{
|
||||
$stream = new Stream(array('codec_type' => 'audio', 'width' => 960, 'height' => 720));
|
||||
$streams = new StreamCollection(array($stream));
|
||||
$stream = new Stream(['codec_type' => 'audio', 'width' => 960, 'height' => 720]);
|
||||
$streams = new StreamCollection([$stream]);
|
||||
|
||||
$audio = $this->getAudioMock(__FILE__);
|
||||
$audio->expects($this->once())
|
||||
|
|
@ -22,7 +21,7 @@ class WaveformDownmixFilterTest extends TestCase
|
|||
->will($this->returnValue($streams));
|
||||
|
||||
$waveform = new Waveform($audio, $this->getFFMpegDriverMock(), $this->getFFProbeMock(), 640, 120);
|
||||
$filter = new WaveformDownmixFilter(TRUE);
|
||||
$this->assertEquals(array('"aformat=channel_layouts=mono"'), $filter->apply($waveform));
|
||||
$filter = new WaveformDownmixFilter(true);
|
||||
$this->assertEquals(['"aformat=channel_layouts=mono"'], $filter->apply($waveform));
|
||||
}
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\Filters\Waveform;
|
||||
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\Filters\Waveform\WaveformFilters;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class WaveformFiltersTest extends TestCase
|
||||
{
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\Format\Audio;
|
||||
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\Format\Audio\DefaultAudio;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
abstract class AudioTestCase extends TestCase
|
||||
{
|
||||
|
|
@ -2,29 +2,37 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\Format\ProgressListener;
|
||||
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\Format\ProgressListener\AudioProgressListener;
|
||||
use FFMpeg\FFProbe\DataMapping\Format;
|
||||
use FFMpeg\Format\ProgressListener\AudioProgressListener;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class AudioProgressListenerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideData
|
||||
*/
|
||||
public function testHandle($size, $duration,
|
||||
$data, $expectedPercent, $expectedRemaining, $expectedRate,
|
||||
$data2, $expectedPercent2, $expectedRemaining2, $expectedRate2,
|
||||
$currentPass, $totalPass
|
||||
)
|
||||
{
|
||||
public function testHandle(
|
||||
$size,
|
||||
$duration,
|
||||
$data,
|
||||
$expectedPercent,
|
||||
$expectedRemaining,
|
||||
$expectedRate,
|
||||
$data2,
|
||||
$expectedPercent2,
|
||||
$expectedRemaining2,
|
||||
$expectedRate2,
|
||||
$currentPass,
|
||||
$totalPass
|
||||
) {
|
||||
$ffprobe = $this->getFFProbeMock();
|
||||
$ffprobe->expects($this->once())
|
||||
->method('format')
|
||||
->with(__FILE__)
|
||||
->will($this->returnValue(new Format(array(
|
||||
'size' => $size,
|
||||
->will($this->returnValue(new Format([
|
||||
'size' => $size,
|
||||
'duration' => $duration,
|
||||
))));
|
||||
])));
|
||||
|
||||
$listener = new AudioProgressListener($ffprobe, __FILE__, $currentPass, $totalPass);
|
||||
$phpunit = $this;
|
||||
|
|
@ -40,7 +48,7 @@ class AudioProgressListenerTest extends TestCase
|
|||
$phpunit->assertLessThan($expectedRate2 + 3, $rate);
|
||||
$phpunit->assertGreaterThan($expectedRate2 - 3, $rate);
|
||||
}
|
||||
$n++;
|
||||
++$n;
|
||||
});
|
||||
// first one does not trigger progress event
|
||||
$listener->handle('any-type'.mt_rand(), $data);
|
||||
|
|
@ -53,8 +61,8 @@ class AudioProgressListenerTest extends TestCase
|
|||
|
||||
public function provideData()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
2894412,
|
||||
180.900750,
|
||||
'size= 712kB time=00:00:45.50 bitrate= 128.1kbits/s',
|
||||
|
|
@ -66,9 +74,9 @@ class AudioProgressListenerTest extends TestCase
|
|||
2,
|
||||
563,
|
||||
1,
|
||||
1
|
||||
),
|
||||
array(
|
||||
1,
|
||||
],
|
||||
[
|
||||
2894412,
|
||||
180.900750,
|
||||
'size= 712kB time=00:00:45.50 bitrate= 128.1kbits/s',
|
||||
|
|
@ -80,8 +88,8 @@ class AudioProgressListenerTest extends TestCase
|
|||
2,
|
||||
563,
|
||||
1,
|
||||
2
|
||||
)
|
||||
);
|
||||
2,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -2,29 +2,38 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\Format\ProgressListener;
|
||||
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\Format\ProgressListener\VideoProgressListener;
|
||||
use FFMpeg\FFProbe\DataMapping\Format;
|
||||
use FFMpeg\Format\ProgressListener\VideoProgressListener;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
|
||||
class VideoProgressListenerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideData
|
||||
*/
|
||||
public function testHandle($size, $duration, $newVideoDuration,
|
||||
$data, $expectedPercent, $expectedRemaining, $expectedRate,
|
||||
$data2, $expectedPercent2, $expectedRemaining2, $expectedRate2,
|
||||
$currentPass, $totalPass
|
||||
)
|
||||
{
|
||||
public function testHandle(
|
||||
$size,
|
||||
$duration,
|
||||
$newVideoDuration,
|
||||
$data,
|
||||
$expectedPercent,
|
||||
$expectedRemaining,
|
||||
$expectedRate,
|
||||
$data2,
|
||||
$expectedPercent2,
|
||||
$expectedRemaining2,
|
||||
$expectedRate2,
|
||||
$currentPass,
|
||||
$totalPass
|
||||
) {
|
||||
$ffprobe = $this->getFFProbeMock();
|
||||
$ffprobe->expects($this->once())
|
||||
->method('format')
|
||||
->with(__FILE__)
|
||||
->will($this->returnValue(new Format(array(
|
||||
'size' => $size,
|
||||
->will($this->returnValue(new Format([
|
||||
'size' => $size,
|
||||
'duration' => $duration,
|
||||
))));
|
||||
])));
|
||||
|
||||
$listener = new VideoProgressListener($ffprobe, __FILE__, $currentPass, $totalPass, $newVideoDuration);
|
||||
$phpunit = $this;
|
||||
|
|
@ -40,7 +49,7 @@ class VideoProgressListenerTest extends TestCase
|
|||
$phpunit->assertLessThan($expectedRate2 + 10, $rate);
|
||||
$phpunit->assertGreaterThan($expectedRate2 - 10, $rate);
|
||||
}
|
||||
$n++;
|
||||
++$n;
|
||||
});
|
||||
// first one does not trigger progress event
|
||||
$listener->handle('any-type'.mt_rand(), $data);
|
||||
|
|
@ -53,8 +62,8 @@ class VideoProgressListenerTest extends TestCase
|
|||
|
||||
public function provideData()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
147073958,
|
||||
281.147533,
|
||||
281.147533,
|
||||
|
|
@ -67,9 +76,9 @@ class VideoProgressListenerTest extends TestCase
|
|||
32,
|
||||
3868,
|
||||
1,
|
||||
1
|
||||
),
|
||||
array(
|
||||
1,
|
||||
],
|
||||
[
|
||||
147073958,
|
||||
281.147533,
|
||||
281.147533,
|
||||
|
|
@ -82,9 +91,9 @@ class VideoProgressListenerTest extends TestCase
|
|||
32,
|
||||
3868,
|
||||
1,
|
||||
2
|
||||
),
|
||||
array(
|
||||
2,
|
||||
],
|
||||
[
|
||||
147073958,
|
||||
281.147533,
|
||||
35,
|
||||
|
|
@ -97,8 +106,8 @@ class VideoProgressListenerTest extends TestCase
|
|||
0,
|
||||
3868,
|
||||
2,
|
||||
2
|
||||
)
|
||||
);
|
||||
2,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ class InitialParametersTest extends TestCase
|
|||
public function testApplyInitialParameters()
|
||||
{
|
||||
$format = new X264();
|
||||
$format->setInitialParameters(array('-acodec', 'libopus'));
|
||||
$this->assertEquals(array('-acodec', 'libopus'), $format->getInitialParameters());
|
||||
$format->setInitialParameters(['-acodec', 'libopus']);
|
||||
$this->assertEquals(['-acodec', 'libopus'], $format->getInitialParameters());
|
||||
}
|
||||
}
|
||||
|
|
@ -11,8 +11,8 @@ class AdvancedMediaTest extends AbstractMediaTestCase
|
|||
$driver = $this->getFFMpegDriverMock();
|
||||
$ffprobe = $this->getFFProbeMock();
|
||||
|
||||
$advancedMedia = new AdvancedMedia(array(__FILE__, __FILE__), $driver, $ffprobe);
|
||||
$this->assertSame(array(__FILE__, __FILE__), $advancedMedia->getInputs());
|
||||
$advancedMedia = new AdvancedMedia([__FILE__, __FILE__], $driver, $ffprobe);
|
||||
$this->assertSame([__FILE__, __FILE__], $advancedMedia->getInputs());
|
||||
}
|
||||
|
||||
public function testGetInputsCount()
|
||||
|
|
@ -20,7 +20,7 @@ class AdvancedMediaTest extends AbstractMediaTestCase
|
|||
$driver = $this->getFFMpegDriverMock();
|
||||
$ffprobe = $this->getFFProbeMock();
|
||||
|
||||
$advancedMedia = new AdvancedMedia(array(__FILE__, __FILE__), $driver, $ffprobe);
|
||||
$advancedMedia = new AdvancedMedia([__FILE__, __FILE__], $driver, $ffprobe);
|
||||
$this->assertEquals(2, $advancedMedia->getInputsCount());
|
||||
}
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ class AdvancedMediaTest extends AbstractMediaTestCase
|
|||
$driver = $this->getFFMpegDriverMock();
|
||||
$ffprobe = $this->getFFProbeMock();
|
||||
|
||||
$advancedMedia = new AdvancedMedia(array(__FILE__, __FILE__), $driver, $ffprobe);
|
||||
$advancedMedia = new AdvancedMedia([__FILE__, __FILE__], $driver, $ffprobe);
|
||||
$this->assertInstanceOf('FFMpeg\Filters\AdvancedMedia\ComplexFilters', $advancedMedia->filters());
|
||||
}
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\Media;
|
||||
|
||||
use FFMpeg\Format\ProgressableInterface;
|
||||
use FFMpeg\Format\AudioInterface;
|
||||
use FFMpeg\Format\ProgressableInterface;
|
||||
|
||||
abstract class AudioProg implements ProgressableInterface, AudioInterface
|
||||
{
|
||||
|
|
@ -4,8 +4,6 @@ namespace Tests\FFMpeg\Unit\Media;
|
|||
|
||||
use FFMpeg\Exception\RuntimeException;
|
||||
use FFMpeg\Media\Audio;
|
||||
use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
|
||||
use FFMpeg\Format\AudioInterface;
|
||||
|
||||
class AudioTest extends AbstractStreamableTestCase
|
||||
{
|
||||
|
|
@ -69,7 +67,7 @@ class AudioTest extends AbstractStreamableTestCase
|
|||
$format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
|
||||
$format->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
|
||||
$configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock();
|
||||
|
||||
|
|
@ -95,7 +93,7 @@ class AudioTest extends AbstractStreamableTestCase
|
|||
$format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
|
||||
$format->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
|
||||
$configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock();
|
||||
|
||||
|
|
@ -109,9 +107,9 @@ class AudioTest extends AbstractStreamableTestCase
|
|||
$filter->expects($this->once())
|
||||
->method('apply')
|
||||
->with($audio, $format)
|
||||
->will($this->returnValue(array('extra-filter-command')));
|
||||
->will($this->returnValue(['extra-filter-command']));
|
||||
|
||||
$capturedCommands = array();
|
||||
$capturedCommands = [];
|
||||
|
||||
$driver->expects($this->once())
|
||||
->method('command')
|
||||
|
|
@ -184,7 +182,7 @@ class AudioTest extends AbstractStreamableTestCase
|
|||
$format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
|
||||
$format->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
$format->expects($this->any())
|
||||
->method('getAudioKiloBitrate')
|
||||
->will($this->returnValue(663));
|
||||
|
|
@ -195,7 +193,7 @@ class AudioTest extends AbstractStreamableTestCase
|
|||
$audioFormat = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
|
||||
$audioFormat->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
$audioFormat->expects($this->any())
|
||||
->method('getAudioKiloBitrate')
|
||||
->will($this->returnValue(664));
|
||||
|
|
@ -209,7 +207,7 @@ class AudioTest extends AbstractStreamableTestCase
|
|||
$formatExtra = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
|
||||
$formatExtra->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array('extra', 'param')));
|
||||
->will($this->returnValue(['extra', 'param']));
|
||||
$formatExtra->expects($this->any())
|
||||
->method('getAudioKiloBitrate')
|
||||
->will($this->returnValue(665));
|
||||
|
|
@ -217,13 +215,13 @@ class AudioTest extends AbstractStreamableTestCase
|
|||
->method('getAudioChannels')
|
||||
->will($this->returnValue(5));
|
||||
|
||||
$listeners = array($this->getMockBuilder('Alchemy\BinaryDriver\Listeners\ListenerInterface')->getMock());
|
||||
$listeners = [$this->getMockBuilder('Alchemy\BinaryDriver\Listeners\ListenerInterface')->getMock()];
|
||||
|
||||
$progressableFormat = $this->getMockBuilder('Tests\FFMpeg\Unit\Media\AudioProg')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$progressableFormat->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
$progressableFormat->expects($this->any())
|
||||
->method('createProgressListener')
|
||||
->will($this->returnValue($listeners));
|
||||
|
|
@ -234,56 +232,56 @@ class AudioTest extends AbstractStreamableTestCase
|
|||
->method('getAudioChannels')
|
||||
->will($this->returnValue(5));
|
||||
|
||||
return array(
|
||||
array(false, array(
|
||||
'-y', '-i', __FILE__,
|
||||
'-b:a', '663k',
|
||||
'-ac', '5',
|
||||
'/target/file',
|
||||
), null, $format),
|
||||
array(false, array(
|
||||
'-y', '-i', __FILE__,
|
||||
'-acodec', 'patati-patata-audio',
|
||||
'-b:a', '664k',
|
||||
'-ac', '5',
|
||||
'/target/file',
|
||||
), null, $audioFormat),
|
||||
array(false, array(
|
||||
'-y', '-i', __FILE__,
|
||||
'extra', 'param',
|
||||
'-b:a', '665k',
|
||||
'-ac', '5',
|
||||
'/target/file',
|
||||
), null, $formatExtra),
|
||||
array(true, array(
|
||||
'-y', '-i', __FILE__,
|
||||
'-threads', 24,
|
||||
'-b:a', '663k',
|
||||
'-ac', '5',
|
||||
'/target/file',
|
||||
), null, $format),
|
||||
array(true, array(
|
||||
'-y', '-i', __FILE__,
|
||||
'extra', 'param',
|
||||
'-threads', 24,
|
||||
'-b:a', '665k',
|
||||
'-ac', '5',
|
||||
'/target/file',
|
||||
), null, $formatExtra),
|
||||
array(false, array(
|
||||
'-y', '-i', __FILE__,
|
||||
'-b:a', '666k',
|
||||
'-ac', '5',
|
||||
'/target/file',
|
||||
), $listeners, $progressableFormat),
|
||||
array(true, array(
|
||||
'-y', '-i', __FILE__,
|
||||
'-threads', 24,
|
||||
'-b:a', '666k',
|
||||
'-ac', '5',
|
||||
'/target/file',
|
||||
), $listeners, $progressableFormat),
|
||||
);
|
||||
return [
|
||||
[false, [
|
||||
'-y', '-i', __FILE__,
|
||||
'-b:a', '663k',
|
||||
'-ac', '5',
|
||||
'/target/file',
|
||||
], null, $format],
|
||||
[false, [
|
||||
'-y', '-i', __FILE__,
|
||||
'-acodec', 'patati-patata-audio',
|
||||
'-b:a', '664k',
|
||||
'-ac', '5',
|
||||
'/target/file',
|
||||
], null, $audioFormat],
|
||||
[false, [
|
||||
'-y', '-i', __FILE__,
|
||||
'extra', 'param',
|
||||
'-b:a', '665k',
|
||||
'-ac', '5',
|
||||
'/target/file',
|
||||
], null, $formatExtra],
|
||||
[true, [
|
||||
'-y', '-i', __FILE__,
|
||||
'-threads', 24,
|
||||
'-b:a', '663k',
|
||||
'-ac', '5',
|
||||
'/target/file',
|
||||
], null, $format],
|
||||
[true, [
|
||||
'-y', '-i', __FILE__,
|
||||
'extra', 'param',
|
||||
'-threads', 24,
|
||||
'-b:a', '665k',
|
||||
'-ac', '5',
|
||||
'/target/file',
|
||||
], null, $formatExtra],
|
||||
[false, [
|
||||
'-y', '-i', __FILE__,
|
||||
'-b:a', '666k',
|
||||
'-ac', '5',
|
||||
'/target/file',
|
||||
], $listeners, $progressableFormat],
|
||||
[true, [
|
||||
'-y', '-i', __FILE__,
|
||||
'-threads', 24,
|
||||
'-b:a', '666k',
|
||||
'-ac', '5',
|
||||
'/target/file',
|
||||
], $listeners, $progressableFormat],
|
||||
];
|
||||
}
|
||||
|
||||
public function testSaveShouldNotStoreCodecFiltersInTheMedia()
|
||||
|
|
@ -307,7 +305,7 @@ class AudioTest extends AbstractStreamableTestCase
|
|||
->with($this->equalTo('ffmpeg.threads'))
|
||||
->will($this->returnValue(24));
|
||||
|
||||
$capturedCommands = array();
|
||||
$capturedCommands = [];
|
||||
|
||||
$driver->expects($this->exactly(2))
|
||||
->method('command')
|
||||
|
|
@ -321,15 +319,15 @@ class AudioTest extends AbstractStreamableTestCase
|
|||
$format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
|
||||
$format->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array('param')));
|
||||
->will($this->returnValue(['param']));
|
||||
|
||||
$audio = new Audio(__FILE__, $driver, $ffprobe);
|
||||
$audio->save($format, $outputPathfile);
|
||||
$audio->save($format, $outputPathfile);
|
||||
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'-y', '-i', __FILE__, 'param', '-threads', 24, '/target/file',
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($capturedCommands as $capturedCommand) {
|
||||
$this->assertEquals($expected, $capturedCommand);
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\FFMpeg\Unit\Media;
|
||||
|
||||
use FFMpeg\Media\Clip;
|
||||
|
||||
class ClipTest extends AbstractMediaTestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @dataProvider provideBuildOptions
|
||||
*/
|
||||
|
|
@ -41,7 +41,7 @@ class ClipTest extends AbstractMediaTestCase
|
|||
->will($this->returnValue(1));
|
||||
$format->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
|
||||
$clip = new Clip($this->getVideoMock(__FILE__), $driver, $ffprobe, $start, $duration);
|
||||
$fc = $clip->getFinalCommand($format, $outputPathfile);
|
||||
|
|
@ -52,16 +52,16 @@ class ClipTest extends AbstractMediaTestCase
|
|||
|
||||
public function provideBuildOptions()
|
||||
{
|
||||
return array(
|
||||
array('SS01', null, array(
|
||||
'-y', '-ss', 'SS01',
|
||||
'-i', __FILE__)
|
||||
),
|
||||
array('SS02', 'D02', array(
|
||||
'-y', '-ss', 'SS02',
|
||||
'-i', __FILE__,
|
||||
'-t', 'D02')
|
||||
)
|
||||
);
|
||||
return [
|
||||
['SS01', null, [
|
||||
'-y', '-ss', 'SS01',
|
||||
'-i', __FILE__, ],
|
||||
],
|
||||
['SS02', 'D02', [
|
||||
'-y', '-ss', 'SS02',
|
||||
'-i', __FILE__,
|
||||
'-t', 'D02', ],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
namespace Tests\FFMpeg\Unit\Media;
|
||||
|
||||
use FFMpeg\Media\Concat;
|
||||
use Neutron\TemporaryFilesystem\Manager as FsManager;
|
||||
use Spatie\TemporaryDirectory\TemporaryDirectory;
|
||||
|
||||
class ConcatTest extends AbstractMediaTestCase
|
||||
{
|
||||
|
|
@ -12,8 +12,8 @@ class ConcatTest extends AbstractMediaTestCase
|
|||
$driver = $this->getFFMpegDriverMock();
|
||||
$ffprobe = $this->getFFProbeMock();
|
||||
|
||||
$concat = new Concat(array(__FILE__, __FILE__), $driver, $ffprobe);
|
||||
$this->assertSame(array(__FILE__, __FILE__), $concat->getSources());
|
||||
$concat = new Concat([__FILE__, __FILE__], $driver, $ffprobe);
|
||||
$this->assertSame([__FILE__, __FILE__], $concat->getSources());
|
||||
}
|
||||
|
||||
public function testFiltersReturnFilters()
|
||||
|
|
@ -21,7 +21,7 @@ class ConcatTest extends AbstractMediaTestCase
|
|||
$driver = $this->getFFMpegDriverMock();
|
||||
$ffprobe = $this->getFFProbeMock();
|
||||
|
||||
$concat = new Concat(array(__FILE__, __FILE__), $driver, $ffprobe);
|
||||
$concat = new Concat([__FILE__, __FILE__], $driver, $ffprobe);
|
||||
$this->assertInstanceOf('FFMpeg\Filters\Concat\ConcatFilters', $concat->filters());
|
||||
}
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ class ConcatTest extends AbstractMediaTestCase
|
|||
->method('add')
|
||||
->with($filter);
|
||||
|
||||
$concat = new Concat(array(__FILE__, __FILE__), $driver, $ffprobe);
|
||||
$concat = new Concat([__FILE__, __FILE__], $driver, $ffprobe);
|
||||
$concat->setFiltersCollection($filters);
|
||||
$concat->addFilter($filter);
|
||||
}
|
||||
|
|
@ -60,9 +60,10 @@ class ConcatTest extends AbstractMediaTestCase
|
|||
$driver->expects($this->exactly(1))
|
||||
->method('command')
|
||||
->with($this->isType('array'), false, $this->anything())
|
||||
->will($this->returnCallback(function ($commands, $errors, $listeners) {}));
|
||||
->will($this->returnCallback(function ($commands, $errors, $listeners) {
|
||||
}));
|
||||
|
||||
$concat = new Concat(array(__FILE__, 'concat-2.mp4'), $driver, $ffprobe);
|
||||
$concat = new Concat([__FILE__, 'concat-2.mp4'], $driver, $ffprobe);
|
||||
$concat->saveFromSameCodecs($pathfile, $streamCopy);
|
||||
|
||||
$this->assertEquals('-f', $commands[0]);
|
||||
|
|
@ -70,7 +71,7 @@ class ConcatTest extends AbstractMediaTestCase
|
|||
$this->assertEquals('-safe', $commands[2]);
|
||||
$this->assertEquals('0', $commands[3]);
|
||||
$this->assertEquals('-i', $commands[4]);
|
||||
if(isset($commands[6]) && (strcmp($commands[6], "-c") == 0)) {
|
||||
if (isset($commands[6]) && (0 == strcmp($commands[6], '-c'))) {
|
||||
$this->assertEquals('-c', $commands[6]);
|
||||
$this->assertEquals('copy', $commands[7]);
|
||||
}
|
||||
|
|
@ -78,28 +79,29 @@ class ConcatTest extends AbstractMediaTestCase
|
|||
|
||||
public function provideSaveFromSameCodecsOptions()
|
||||
{
|
||||
$fs = FsManager::create();
|
||||
$tmpFile = $fs->createTemporaryFile('ffmpeg-concat');
|
||||
$fs = (new TemporaryDirectory())->create();
|
||||
$tmpFile = $fs->path('ffmpeg-concat');
|
||||
touch($tmpFile);
|
||||
|
||||
return array(
|
||||
array(
|
||||
TRUE,
|
||||
array(
|
||||
return [
|
||||
[
|
||||
true,
|
||||
[
|
||||
'-f', 'concat',
|
||||
'-safe', '0',
|
||||
'-i', $tmpFile,
|
||||
'-c', 'copy'
|
||||
),
|
||||
),
|
||||
array(
|
||||
FALSE,
|
||||
array(
|
||||
'-c', 'copy',
|
||||
],
|
||||
],
|
||||
[
|
||||
false,
|
||||
[
|
||||
'-f', 'concat',
|
||||
'-safe', '0',
|
||||
'-i', $tmpFile
|
||||
)
|
||||
),
|
||||
);
|
||||
'-i', $tmpFile,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -125,23 +127,23 @@ class ConcatTest extends AbstractMediaTestCase
|
|||
->method('command')
|
||||
->with($commands);
|
||||
|
||||
$concat = new Concat(array(__FILE__, 'concat-2.mp4'), $driver, $ffprobe);
|
||||
$concat = new Concat([__FILE__, 'concat-2.mp4'], $driver, $ffprobe);
|
||||
$this->assertSame($concat, $concat->saveFromDifferentCodecs($format, $pathfile));
|
||||
}
|
||||
|
||||
public function provideSaveFromDifferentCodecsOptions()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
[
|
||||
'-i', __FILE__,
|
||||
'-i', 'concat-2.mp4',
|
||||
'-filter_complex',
|
||||
'[0:v:0] [0:a:0] [1:v:0] [1:a:0] concat=n=2:v=1:a=1 [v] [a]',
|
||||
'-map', '[v]',
|
||||
'-map', '[a]'
|
||||
),
|
||||
),
|
||||
);
|
||||
'-map', '[a]',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -69,11 +69,10 @@ class FrameTest extends AbstractMediaTestCase
|
|||
->method('command')
|
||||
->with($commands);
|
||||
|
||||
if(!$base64) {
|
||||
if (!$base64) {
|
||||
$frame = new Frame($this->getVideoMock(__FILE__), $driver, $ffprobe, $timecode);
|
||||
$this->assertSame($frame, $frame->save($pathfile, $accurate, $base64));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$frame = new Frame($this->getVideoMock(__FILE__), $driver, $ffprobe, $timecode);
|
||||
$frame->save($pathfile, $accurate, $base64);
|
||||
}
|
||||
|
|
@ -81,29 +80,29 @@ class FrameTest extends AbstractMediaTestCase
|
|||
|
||||
public function provideSaveOptions()
|
||||
{
|
||||
return array(
|
||||
array(false, false, array(
|
||||
return [
|
||||
[false, false, [
|
||||
'-y', '-ss', 'timecode',
|
||||
'-i', __FILE__,
|
||||
'-vframes', '1',
|
||||
'-f', 'image2')
|
||||
),
|
||||
array(true, false, array(
|
||||
'-f', 'image2', ],
|
||||
],
|
||||
[true, false, [
|
||||
'-y', '-i', __FILE__,
|
||||
'-vframes', '1', '-ss', 'timecode',
|
||||
'-f', 'image2')
|
||||
),
|
||||
array(false, true, array(
|
||||
'-y', '-ss', 'timecode',
|
||||
'-i', __FILE__,
|
||||
'-vframes', '1',
|
||||
'-f', 'image2pipe', '-')
|
||||
),
|
||||
array(true, true, array(
|
||||
'-y', '-i', __FILE__,
|
||||
'-vframes', '1', '-ss', 'timecode',
|
||||
'-f', 'image2pipe', '-')
|
||||
)
|
||||
);
|
||||
'-f', 'image2', ],
|
||||
],
|
||||
[false, true, [
|
||||
'-y', '-ss', 'timecode',
|
||||
'-i', __FILE__,
|
||||
'-vframes', '1',
|
||||
'-f', 'image2pipe', '-', ],
|
||||
],
|
||||
[true, true, [
|
||||
'-y', '-i', __FILE__,
|
||||
'-vframes', '1', '-ss', 'timecode',
|
||||
'-f', 'image2pipe', '-', ],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Tests\FFMpeg\Unit\Media;
|
||||
|
||||
use FFMpeg\Media\Gif;
|
||||
use FFMpeg\Coordinate\Dimension;
|
||||
use FFMpeg\Media\Gif;
|
||||
|
||||
class GifTest extends AbstractMediaTestCase
|
||||
{
|
||||
|
|
@ -89,28 +89,28 @@ class GifTest extends AbstractMediaTestCase
|
|||
|
||||
public function provideSaveOptions()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
new Dimension(320, 240), 3,
|
||||
array(
|
||||
[
|
||||
'-ss', 'timecode',
|
||||
'-t', '3',
|
||||
'-i', __FILE__,
|
||||
'-vf',
|
||||
'scale=320:-1', '-gifflags',
|
||||
'+transdiff', '-y'
|
||||
),
|
||||
),
|
||||
array(
|
||||
'+transdiff', '-y',
|
||||
],
|
||||
],
|
||||
[
|
||||
new Dimension(320, 240), null,
|
||||
array(
|
||||
[
|
||||
'-ss', 'timecode',
|
||||
'-i', __FILE__,
|
||||
'-vf',
|
||||
'scale=320:-1', '-gifflags',
|
||||
'+transdiff', '-y'
|
||||
)
|
||||
),
|
||||
);
|
||||
'+transdiff', '-y',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -3,16 +3,14 @@
|
|||
namespace Tests\FFMpeg\Unit\Media;
|
||||
|
||||
use FFMpeg\Exception\RuntimeException;
|
||||
use FFMpeg\Media\Video;
|
||||
use FFMpeg\Format\Video\X264;
|
||||
use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
|
||||
use FFMpeg\Format\VideoInterface;
|
||||
use FFMpeg\Media\Video;
|
||||
|
||||
class VideoTest extends AbstractStreamableTestCase
|
||||
{
|
||||
public function testFiltersReturnsVideoFilters()
|
||||
{
|
||||
$driver = $this->getFFMpegDriverMock();
|
||||
$driver = $this->getFFMpegDriverMock();
|
||||
$ffprobe = $this->getFFProbeMock();
|
||||
|
||||
$video = new Video(__FILE__, $driver, $ffprobe);
|
||||
|
|
@ -21,7 +19,7 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
|
||||
public function testAddFiltersAddsAFilter()
|
||||
{
|
||||
$driver = $this->getFFMpegDriverMock();
|
||||
$driver = $this->getFFMpegDriverMock();
|
||||
$ffprobe = $this->getFFProbeMock();
|
||||
|
||||
$filters = $this->getMockBuilder('FFMpeg\Filters\FiltersCollection')
|
||||
|
|
@ -42,7 +40,7 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
|
||||
public function testAddAudioFilterAddsAFilter()
|
||||
{
|
||||
$driver = $this->getFFMpegDriverMock();
|
||||
$driver = $this->getFFMpegDriverMock();
|
||||
$ffprobe = $this->getFFProbeMock();
|
||||
|
||||
$filters = $this->getMockBuilder('FFMpeg\Filters\FiltersCollection')
|
||||
|
|
@ -63,7 +61,7 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
|
||||
public function testFrameShouldReturnAFrame()
|
||||
{
|
||||
$driver = $this->getFFMpegDriverMock();
|
||||
$driver = $this->getFFMpegDriverMock();
|
||||
$ffprobe = $this->getFFProbeMock();
|
||||
|
||||
$at = $this->getTimeCodeMock();
|
||||
|
|
@ -78,16 +76,16 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
|
||||
public function testSaveWithFailure()
|
||||
{
|
||||
$driver = $this->getFFMpegDriverMock();
|
||||
$ffprobe = $this->getFFProbeMock();
|
||||
$driver = $this->getFFMpegDriverMock();
|
||||
$ffprobe = $this->getFFProbeMock();
|
||||
$outputPathfile = '/target/file';
|
||||
$format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
$format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
$format->expects($this->any())
|
||||
->method('getPasses')
|
||||
->will($this->returnValue(1));
|
||||
$format->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
|
||||
$configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock();
|
||||
|
||||
|
|
@ -107,13 +105,13 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
|
||||
public function testSaveAppliesFilters()
|
||||
{
|
||||
$driver = $this->getFFMpegDriverMock();
|
||||
$ffprobe = $this->getFFProbeMock();
|
||||
$driver = $this->getFFMpegDriverMock();
|
||||
$ffprobe = $this->getFFProbeMock();
|
||||
$outputPathfile = '/target/file';
|
||||
$format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
$format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
$format->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
$format->expects($this->any())
|
||||
->method('getPasses')
|
||||
->will($this->returnValue(2));
|
||||
|
|
@ -130,9 +128,9 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
$filter->expects($this->once())
|
||||
->method('apply')
|
||||
->with($video, $format)
|
||||
->will($this->returnValue(array('extra-filter-command')));
|
||||
->will($this->returnValue(['extra-filter-command']));
|
||||
|
||||
$capturedCommands = array();
|
||||
$capturedCommands = [];
|
||||
|
||||
$driver->expects($this->exactly(2))
|
||||
->method('command')
|
||||
|
|
@ -157,7 +155,7 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
*/
|
||||
public function testSaveShouldSave($threads, $expectedCommands, $expectedListeners, $format)
|
||||
{
|
||||
$driver = $this->getFFMpegDriverMock();
|
||||
$driver = $this->getFFMpegDriverMock();
|
||||
$ffprobe = $this->getFFProbeMock();
|
||||
|
||||
$configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock();
|
||||
|
|
@ -181,7 +179,7 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
->method('get');
|
||||
}
|
||||
|
||||
$capturedCommands = array();
|
||||
$capturedCommands = [];
|
||||
$capturedListeners = null;
|
||||
|
||||
$driver->expects($this->exactly(count($expectedCommands)))
|
||||
|
|
@ -238,7 +236,7 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
$format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
$format->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
$format->expects($this->any())
|
||||
->method('getKiloBitrate')
|
||||
->will($this->returnValue(663));
|
||||
|
|
@ -253,12 +251,12 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
->will($this->returnValue(2));
|
||||
$format->expects($this->any())
|
||||
->method('getAdditionalParameters')
|
||||
->will($this->returnValue(array('foo', 'bar')));
|
||||
->will($this->returnValue(['foo', 'bar']));
|
||||
|
||||
$format2 = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
$format2->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
$format2->expects($this->any())
|
||||
->method('getKiloBitrate')
|
||||
->will($this->returnValue(663));
|
||||
|
|
@ -273,12 +271,12 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
->will($this->returnValue(2));
|
||||
$format2->expects($this->any())
|
||||
->method('getAdditionalParameters')
|
||||
->will($this->returnValue(array('foo', 'bar')));
|
||||
->will($this->returnValue(['foo', 'bar']));
|
||||
|
||||
$audioFormat = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
|
||||
$audioFormat->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
$audioFormat->expects($this->any())
|
||||
->method('getAudioCodec')
|
||||
->will($this->returnValue('patati-patata-audio'));
|
||||
|
|
@ -295,7 +293,7 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
$audioVideoFormat = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
$audioVideoFormat->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
$audioVideoFormat->expects($this->any())
|
||||
->method('getVideoCodec')
|
||||
->will($this->returnValue('gloubi-boulga-video'));
|
||||
|
|
@ -316,12 +314,12 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
->will($this->returnValue(2));
|
||||
$audioVideoFormat->expects($this->any())
|
||||
->method('getAdditionalParameters')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
|
||||
$audioVideoFormatSinglePass = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
$audioVideoFormatSinglePass->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
$audioVideoFormatSinglePass->expects($this->any())
|
||||
->method('getVideoCodec')
|
||||
->will($this->returnValue('gloubi-boulga-video'));
|
||||
|
|
@ -342,12 +340,12 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
->will($this->returnValue(1));
|
||||
$audioVideoFormatSinglePass->expects($this->any())
|
||||
->method('getAdditionalParameters')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
|
||||
$formatExtra = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
$formatExtra->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array('extra', 'param')));
|
||||
->will($this->returnValue(['extra', 'param']));
|
||||
$formatExtra->expects($this->any())
|
||||
->method('getKiloBitrate')
|
||||
->will($this->returnValue(665));
|
||||
|
|
@ -362,12 +360,12 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
->will($this->returnValue(2));
|
||||
$formatExtra->expects($this->any())
|
||||
->method('getAdditionalParameters')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
|
||||
$formatExtra2 = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
$formatExtra2->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array('extra', 'param')));
|
||||
->will($this->returnValue(['extra', 'param']));
|
||||
$formatExtra2->expects($this->any())
|
||||
->method('getKiloBitrate')
|
||||
->will($this->returnValue(665));
|
||||
|
|
@ -382,15 +380,15 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
->will($this->returnValue(2));
|
||||
$formatExtra2->expects($this->any())
|
||||
->method('getAdditionalParameters')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
|
||||
$listeners = array($this->getMockBuilder('Alchemy\BinaryDriver\Listeners\ListenerInterface')->getMock());
|
||||
$listeners = [$this->getMockBuilder('Alchemy\BinaryDriver\Listeners\ListenerInterface')->getMock()];
|
||||
|
||||
$progressableFormat = $this->getMockBuilder('Tests\FFMpeg\Unit\Media\Prog')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$progressableFormat->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
$progressableFormat->expects($this->any())
|
||||
->method('createProgressListener')
|
||||
->will($this->returnValue($listeners));
|
||||
|
|
@ -411,7 +409,7 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
->disableOriginalConstructor()->getMock();
|
||||
$progressableFormat2->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
$progressableFormat2->expects($this->any())
|
||||
->method('createProgressListener')
|
||||
->will($this->returnValue($listeners));
|
||||
|
|
@ -432,7 +430,7 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
->disableOriginalConstructor()->getMock();
|
||||
$progressableAudioFormat->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
$progressableAudioFormat->expects($this->any())
|
||||
->method('getAudioCodec')
|
||||
->will($this->returnValue('patati-patata-audio'));
|
||||
|
|
@ -449,142 +447,142 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
->method('getPasses')
|
||||
->will($this->returnValue(1));
|
||||
|
||||
return array(
|
||||
array(false, array(array(
|
||||
'-y', '-i', __FILE__, '-b:v', '663k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', 2, 'foo', 'bar', '-pass', 1, '-passlogfile',
|
||||
'/target/file',
|
||||
), array(
|
||||
'-y', '-i', __FILE__,
|
||||
'-b:v', '663k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', 2, 'foo', 'bar', '-pass', 2, '-passlogfile',
|
||||
'/target/file',
|
||||
)), null, $format),
|
||||
array(false, array(array(
|
||||
'-y', '-i', __FILE__,
|
||||
'-vcodec', 'gloubi-boulga-video',
|
||||
'-acodec', 'patati-patata-audio', '-b:v', '664k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '1', '-passlogfile',
|
||||
'/target/file',
|
||||
), array(
|
||||
'-y', '-i', __FILE__,
|
||||
'-vcodec', 'gloubi-boulga-video',
|
||||
'-acodec', 'patati-patata-audio',
|
||||
'-b:v', '664k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '2', '-passlogfile',
|
||||
'/target/file',
|
||||
)), null, $audioVideoFormat),
|
||||
array(false, array(array(
|
||||
'-y', '-i', __FILE__,
|
||||
'-vcodec', 'gloubi-boulga-video',
|
||||
'-acodec', 'patati-patata-audio', '-b:v', '664k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2',
|
||||
'/target/file',
|
||||
)), null, $audioVideoFormatSinglePass),
|
||||
array(false, array(array(
|
||||
'-y', '-i', __FILE__,
|
||||
'extra', 'param','-b:v', '665k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '1', '-passlogfile',
|
||||
'/target/file',
|
||||
), array(
|
||||
'-y', '-i', __FILE__,
|
||||
'extra', 'param', '-b:v', '665k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '2', '-passlogfile',
|
||||
'/target/file',
|
||||
)), null, $formatExtra),
|
||||
array(true, array(array(
|
||||
'-y', '-i', __FILE__,
|
||||
'-threads', 24, '-b:v', '663k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', 2, 'foo', 'bar', '-pass', 1, '-passlogfile',
|
||||
'/target/file',
|
||||
), array(
|
||||
'-y', '-i', __FILE__,
|
||||
'-threads', 24,
|
||||
'-b:v', '663k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', 2, 'foo', 'bar', '-pass', 2, '-passlogfile',
|
||||
'/target/file',
|
||||
)), null, $format2),
|
||||
array(true, array(array(
|
||||
'-y', '-i', __FILE__,
|
||||
'extra', 'param', '-threads', 24, '-b:v', '665k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '1', '-passlogfile',
|
||||
'/target/file',
|
||||
), array(
|
||||
'-y', '-i', __FILE__,
|
||||
'extra', 'param', '-threads', 24, '-b:v', '665k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '2', '-passlogfile',
|
||||
'/target/file',
|
||||
)), null, $formatExtra2),
|
||||
array(false, array(array(
|
||||
'-y', '-i', __FILE__, '-b:v', '666k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '1', '-passlogfile',
|
||||
'/target/file',
|
||||
), array(
|
||||
'-y', '-i', __FILE__,
|
||||
'-b:v', '666k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '2', '-passlogfile',
|
||||
'/target/file',
|
||||
)), $listeners, $progressableFormat2),
|
||||
array(true, array(array(
|
||||
'-y', '-i', __FILE__,
|
||||
'-threads', 24, '-b:v', '666k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '1', '-passlogfile',
|
||||
'/target/file',
|
||||
), array(
|
||||
'-y', '-i', __FILE__,
|
||||
'-threads', 24,
|
||||
'-b:v', '666k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '2', '-passlogfile',
|
||||
'/target/file',
|
||||
)), $listeners, $progressableFormat),
|
||||
array(true, array(array(
|
||||
'-y', '-i', __FILE__,
|
||||
'-threads', 24, '-acodec', 'patati-patata-audio',
|
||||
'-b:a', '92k', '-ac', '2',
|
||||
'/target/file',
|
||||
)), null, $audioFormat),
|
||||
array(true, array(array(
|
||||
'-y', '-i', __FILE__,
|
||||
'-threads', 24, '-acodec', 'patati-patata-audio',
|
||||
'-b:a', '92k', '-ac', '2',
|
||||
'/target/file',
|
||||
)), $listeners, $progressableAudioFormat),
|
||||
);
|
||||
return [
|
||||
[false, [[
|
||||
'-y', '-i', __FILE__, '-b:v', '663k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', 2, 'foo', 'bar', '-pass', 1, '-passlogfile',
|
||||
'/target/file',
|
||||
], [
|
||||
'-y', '-i', __FILE__,
|
||||
'-b:v', '663k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', 2, 'foo', 'bar', '-pass', 2, '-passlogfile',
|
||||
'/target/file',
|
||||
]], null, $format],
|
||||
[false, [[
|
||||
'-y', '-i', __FILE__,
|
||||
'-vcodec', 'gloubi-boulga-video',
|
||||
'-acodec', 'patati-patata-audio', '-b:v', '664k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '1', '-passlogfile',
|
||||
'/target/file',
|
||||
], [
|
||||
'-y', '-i', __FILE__,
|
||||
'-vcodec', 'gloubi-boulga-video',
|
||||
'-acodec', 'patati-patata-audio',
|
||||
'-b:v', '664k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '2', '-passlogfile',
|
||||
'/target/file',
|
||||
]], null, $audioVideoFormat],
|
||||
[false, [[
|
||||
'-y', '-i', __FILE__,
|
||||
'-vcodec', 'gloubi-boulga-video',
|
||||
'-acodec', 'patati-patata-audio', '-b:v', '664k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2',
|
||||
'/target/file',
|
||||
]], null, $audioVideoFormatSinglePass],
|
||||
[false, [[
|
||||
'-y', '-i', __FILE__,
|
||||
'extra', 'param', '-b:v', '665k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '1', '-passlogfile',
|
||||
'/target/file',
|
||||
], [
|
||||
'-y', '-i', __FILE__,
|
||||
'extra', 'param', '-b:v', '665k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '2', '-passlogfile',
|
||||
'/target/file',
|
||||
]], null, $formatExtra],
|
||||
[true, [[
|
||||
'-y', '-i', __FILE__,
|
||||
'-threads', 24, '-b:v', '663k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', 2, 'foo', 'bar', '-pass', 1, '-passlogfile',
|
||||
'/target/file',
|
||||
], [
|
||||
'-y', '-i', __FILE__,
|
||||
'-threads', 24,
|
||||
'-b:v', '663k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', 2, 'foo', 'bar', '-pass', 2, '-passlogfile',
|
||||
'/target/file',
|
||||
]], null, $format2],
|
||||
[true, [[
|
||||
'-y', '-i', __FILE__,
|
||||
'extra', 'param', '-threads', 24, '-b:v', '665k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '1', '-passlogfile',
|
||||
'/target/file',
|
||||
], [
|
||||
'-y', '-i', __FILE__,
|
||||
'extra', 'param', '-threads', 24, '-b:v', '665k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '2', '-passlogfile',
|
||||
'/target/file',
|
||||
]], null, $formatExtra2],
|
||||
[false, [[
|
||||
'-y', '-i', __FILE__, '-b:v', '666k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '1', '-passlogfile',
|
||||
'/target/file',
|
||||
], [
|
||||
'-y', '-i', __FILE__,
|
||||
'-b:v', '666k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '2', '-passlogfile',
|
||||
'/target/file',
|
||||
]], $listeners, $progressableFormat2],
|
||||
[true, [[
|
||||
'-y', '-i', __FILE__,
|
||||
'-threads', 24, '-b:v', '666k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '1', '-passlogfile',
|
||||
'/target/file',
|
||||
], [
|
||||
'-y', '-i', __FILE__,
|
||||
'-threads', 24,
|
||||
'-b:v', '666k',
|
||||
'-refs', '6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71', '-qcomp', '0.6',
|
||||
'-qdiff', '4', '-trellis', '1', '-b:a', '92k', '-ac', '2', '-pass', '2', '-passlogfile',
|
||||
'/target/file',
|
||||
]], $listeners, $progressableFormat],
|
||||
[true, [[
|
||||
'-y', '-i', __FILE__,
|
||||
'-threads', 24, '-acodec', 'patati-patata-audio',
|
||||
'-b:a', '92k', '-ac', '2',
|
||||
'/target/file',
|
||||
]], null, $audioFormat],
|
||||
[true, [[
|
||||
'-y', '-i', __FILE__,
|
||||
'-threads', 24, '-acodec', 'patati-patata-audio',
|
||||
'-b:a', '92k', '-ac', '2',
|
||||
'/target/file',
|
||||
]], $listeners, $progressableAudioFormat],
|
||||
];
|
||||
}
|
||||
|
||||
public function testSaveShouldNotStoreCodecFiltersInTheMedia()
|
||||
{
|
||||
$driver = $this->getFFMpegDriverMock();
|
||||
$driver = $this->getFFMpegDriverMock();
|
||||
$ffprobe = $this->getFFProbeMock();
|
||||
|
||||
$configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock();
|
||||
|
|
@ -603,7 +601,7 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
->with($this->equalTo('ffmpeg.threads'))
|
||||
->will($this->returnValue(24));
|
||||
|
||||
$capturedCommands = array();
|
||||
$capturedCommands = [];
|
||||
|
||||
$driver->expects($this->exactly(4))
|
||||
->method('command')
|
||||
|
|
@ -617,7 +615,7 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
$format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
$format->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array('param')));
|
||||
->will($this->returnValue(['param']));
|
||||
$format->expects($this->any())
|
||||
->method('getPasses')
|
||||
->will($this->returnValue(2));
|
||||
|
|
@ -626,20 +624,20 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
$video->save($format, $outputPathfile);
|
||||
$video->save($format, $outputPathfile);
|
||||
|
||||
$expectedPass1 = array(
|
||||
$expectedPass1 = [
|
||||
'-y', '-i', __FILE__, 'param', '-threads', 24, '-b:v', 'k', '-refs',
|
||||
'6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71',
|
||||
'-qcomp', '0.6', '-qdiff', '4', '-trellis', '1',
|
||||
'-pass', '1', '-passlogfile', '/target/file',
|
||||
);
|
||||
$expectedPass2 = array(
|
||||
];
|
||||
$expectedPass2 = [
|
||||
'-y', '-i', __FILE__, 'param', '-threads', 24, '-b:v', 'k', '-refs',
|
||||
'6', '-coder', '1', '-sc_threshold', '40', '-flags', '+loop',
|
||||
'-me_range', '16', '-subq', '7', '-i_qfactor', '0.71',
|
||||
'-qcomp', '0.6', '-qdiff', '4', '-trellis', '1',
|
||||
'-pass', '2', '-passlogfile', '/target/file',
|
||||
);
|
||||
];
|
||||
|
||||
$n = 1;
|
||||
foreach ($capturedCommands as $capturedCommand) {
|
||||
|
|
@ -674,16 +672,16 @@ class VideoTest extends AbstractStreamableTestCase
|
|||
} else {
|
||||
$this->assertEquals($expectedPass1, $capturedCommand);
|
||||
}
|
||||
$n++;
|
||||
++$n;
|
||||
}
|
||||
}
|
||||
|
||||
public function testCaseWhereKiloBitRateIsEqualToZero()
|
||||
{
|
||||
$driver = $this->getFFMpegDriverMock();
|
||||
$driver = $this->getFFMpegDriverMock();
|
||||
$ffprobe = $this->getFFProbeMock();
|
||||
|
||||
$pathfile = '/target/destination';
|
||||
$pathfile = '/target/destination';
|
||||
$outputPathfile = '/target/file';
|
||||
|
||||
$format = new X264();
|
||||
|
|
@ -6,7 +6,6 @@ use FFMpeg\Media\Waveform;
|
|||
|
||||
class WaveformTest extends AbstractMediaTestCase
|
||||
{
|
||||
|
||||
public function testFiltersReturnFilters()
|
||||
{
|
||||
$driver = $this->getFFMpegDriverMock();
|
||||
|
|
@ -58,14 +57,14 @@ class WaveformTest extends AbstractMediaTestCase
|
|||
|
||||
public function provideSaveOptions()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
'-y', '-i', NULL, '-filter_complex',
|
||||
return [
|
||||
[
|
||||
[
|
||||
'-y', '-i', null, '-filter_complex',
|
||||
'showwavespic=colors=#FFFFFF:s=640x120',
|
||||
'-frames:v', '1',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -161,7 +161,7 @@ class TestCase extends BaseTestCase
|
|||
|
||||
$FormatInterface->expects($this->any())
|
||||
->method('getExtraParams')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
|
||||
return $FormatInterface;
|
||||
}
|
||||
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
|
|
@ -1,83 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\FFMpeg\Unit\Coordinate;
|
||||
|
||||
use FFMpeg\Coordinate\Dimension;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\Coordinate\AspectRatio;
|
||||
|
||||
class AspectRatioTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideDimensionsAndExpectedratio
|
||||
*/
|
||||
public function testFromDimensions($width, $height, $strategy, $expected, $calculatedWidth, $calculatedHeight, $modulus = 2)
|
||||
{
|
||||
$ratio = AspectRatio::create(new Dimension($width, $height), $strategy);
|
||||
$this->assertEquals($expected, $ratio->getValue());
|
||||
|
||||
$this->assertEquals($calculatedHeight, $ratio->calculateHeight(240, $modulus));
|
||||
$this->assertEquals($calculatedWidth, $ratio->calculateWidth(320, $modulus));
|
||||
}
|
||||
|
||||
public function provideDimensionsAndExpectedratio()
|
||||
{
|
||||
return array(
|
||||
//AR_5_4
|
||||
array(720, 576, false, 5/4, 400, 192),
|
||||
array(720, 577, false, 5/4, 400, 192),
|
||||
array(720, 620, false, 720/620, 372, 206),
|
||||
array(720, 576, true, 5/4, 400, 192),
|
||||
//AR_ROTATED_4_5
|
||||
array(576, 720, false, 4/5, 256, 300),
|
||||
array(576, 720, true, 4/5, 256, 300),
|
||||
//AR_4_3
|
||||
array(320, 240, false, 4/3, 426, 180),
|
||||
array(320, 240, true, 4/3, 426, 180),
|
||||
//AR_ROTATED_3_4
|
||||
array(240, 320, false, 3/4, 240, 320),
|
||||
array(240, 320, true, 3/4, 240, 320),
|
||||
//AR_16_9
|
||||
array(1920, 1080, false, 16/9, 568, 136),
|
||||
array(1920, 1080, true, 16/9, 568, 136),
|
||||
array(1280, 720, false, 16/9, 568, 136),
|
||||
array(1280, 720, true, 16/9, 568, 136),
|
||||
array(3840, 2160, false, 16/9, 568, 136),
|
||||
array(3840, 2160, true, 16/9, 568, 136),
|
||||
// modulus 4
|
||||
array(1920, 1080, false, 16/9, 568, 136, 4),
|
||||
array(1920, 1080, true, 16/9, 568, 136, 4),
|
||||
array(1280, 720, false, 16/9, 568, 136, 4),
|
||||
array(1280, 720, true, 16/9, 568, 136, 4),
|
||||
array(3840, 2160, false, 16/9, 568, 136, 4),
|
||||
array(3840, 2160, true, 16/9, 568, 136, 4),
|
||||
// modulus 16
|
||||
array(1920, 1080, false, 16/9, 576, 128, 16),
|
||||
array(1920, 1080, true, 16/9, 576, 128, 16),
|
||||
array(1280, 720, false, 16/9, 576, 128, 16),
|
||||
array(1280, 720, true, 16/9, 576, 128, 16),
|
||||
array(3840, 2160, false, 16/9, 576, 128, 16),
|
||||
array(3840, 2160, true, 16/9, 576, 128, 16),
|
||||
//AR_ROTATED_9_16
|
||||
array(1080, 1920, false, 9/16, 180, 426),
|
||||
array(1080, 1920, true, 9/16, 180, 426),
|
||||
array(720, 1280, false, 9/16, 180, 426),
|
||||
array(720, 1280, true, 9/16, 180, 426),
|
||||
array(2160, 3840, false, 9/16, 180, 426),
|
||||
array(2160, 3840, true, 9/16, 180, 426),
|
||||
//AR_3_2
|
||||
array(360, 240, false, 3/2, 480, 160),
|
||||
array(360, 240, true, 3/2, 480, 160),
|
||||
//AR_ROTATED_2_3
|
||||
array(240, 360, false, 2/3, 214, 360),
|
||||
array(240, 360, true, 2/3, 214, 360),
|
||||
//AR_5_3
|
||||
//AR_ROTATED_3_5
|
||||
//AR_1_1
|
||||
//AR_1_DOT_85_1
|
||||
//AR_ROTATED_1_DOT_85
|
||||
//AR_2_DOT_39_1
|
||||
//AR_ROTATED_2_DOT_39
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\FFMpeg\Unit;
|
||||
|
||||
use FFMpeg\FFMpegServiceProvider;
|
||||
use Silex\Application;
|
||||
|
||||
class FFMpegServiceProviderTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (!class_exists('\Application\Silex')) {
|
||||
$this->markTestSkipped('You MUST have silex/silex installed.');
|
||||
}
|
||||
}
|
||||
|
||||
public function testWithConfig()
|
||||
{
|
||||
$app = new Application();
|
||||
$app->register(new FFMpegServiceProvider(), array(
|
||||
'ffmpeg.configuration' => array(
|
||||
'ffmpeg.threads' => 12,
|
||||
'ffmpeg.timeout' => 10666,
|
||||
'ffprobe.timeout' => 4242,
|
||||
)
|
||||
));
|
||||
|
||||
$this->assertInstanceOf('FFMpeg\FFMpeg', $app['ffmpeg']);
|
||||
$this->assertSame($app['ffmpeg'], $app['ffmpeg.ffmpeg']);
|
||||
$this->assertInstanceOf('FFMpeg\FFProbe', $app['ffmpeg.ffprobe']);
|
||||
|
||||
$this->assertEquals(12, $app['ffmpeg']->getFFMpegDriver()->getConfiguration()->get('ffmpeg.threads'));
|
||||
$this->assertEquals(10666, $app['ffmpeg']->getFFMpegDriver()->getProcessBuilderFactory()->getTimeout());
|
||||
$this->assertEquals(4242, $app['ffmpeg.ffprobe']->getFFProbeDriver()->getProcessBuilderFactory()->getTimeout());
|
||||
}
|
||||
|
||||
public function testWithoutConfig()
|
||||
{
|
||||
$app = new Application();
|
||||
$app->register(new FFMpegServiceProvider());
|
||||
|
||||
$this->assertInstanceOf('FFMpeg\FFMpeg', $app['ffmpeg']);
|
||||
$this->assertSame($app['ffmpeg'], $app['ffmpeg.ffmpeg']);
|
||||
$this->assertInstanceOf('FFMpeg\FFProbe', $app['ffmpeg.ffprobe']);
|
||||
|
||||
$this->assertEquals(4, $app['ffmpeg']->getFFMpegDriver()->getConfiguration()->get('ffmpeg.threads'));
|
||||
$this->assertEquals(300, $app['ffmpeg']->getFFMpegDriver()->getProcessBuilderFactory()->getTimeout());
|
||||
$this->assertEquals(30, $app['ffmpeg.ffprobe']->getFFProbeDriver()->getProcessBuilderFactory()->getTimeout());
|
||||
}
|
||||
|
||||
public function testWithFFMpegBinaryConfig()
|
||||
{
|
||||
$app = new Application();
|
||||
$app->register(new FFMpegServiceProvider(), array(
|
||||
'ffmpeg.configuration' => array(
|
||||
'ffmpeg.binaries' => '/path/to/ffmpeg',
|
||||
)
|
||||
));
|
||||
|
||||
$this->expectException('\FFMpeg\Exception\ExecutableNotFoundException', 'Unable to load FFMpeg');
|
||||
$app['ffmpeg'];
|
||||
}
|
||||
|
||||
public function testWithFFMprobeBinaryConfig()
|
||||
{
|
||||
$app = new Application();
|
||||
$app->register(new FFMpegServiceProvider(), array(
|
||||
'ffmpeg.configuration' => array(
|
||||
'ffprobe.binaries' => '/path/to/ffprobe',
|
||||
)
|
||||
));
|
||||
|
||||
$this->expectException('\FFMpeg\Exception\ExecutableNotFoundException', 'Unable to load FFProbe');
|
||||
$app['ffmpeg.ffprobe'];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\FFMpeg\Unit\Filters\Video;
|
||||
|
||||
use FFMpeg\Filters\Video\ExtractMultipleFramesFilter;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\FFProbe\DataMapping\Stream;
|
||||
use FFMpeg\FFProbe\DataMapping\StreamCollection;
|
||||
|
||||
class ExtractMultipleFramesFilterTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideFrameRates
|
||||
*/
|
||||
public function testApply($frameRate, $frameFileType,$destinationFolder, $duration, $modulus, $expected)
|
||||
{
|
||||
$video = $this->getVideoMock();
|
||||
$pathfile = '/path/to/file'.mt_rand();
|
||||
|
||||
$format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
$format->expects($this->any())
|
||||
->method('getModulus')
|
||||
->will($this->returnValue($modulus));
|
||||
|
||||
$streams = new StreamCollection(array(
|
||||
new Stream(array(
|
||||
'codec_type' => 'video',
|
||||
'duration' => $duration,
|
||||
))
|
||||
));
|
||||
|
||||
$video->expects($this->once())
|
||||
->method('getStreams')
|
||||
->will($this->returnValue($streams));
|
||||
|
||||
$filter = new ExtractMultipleFramesFilter($frameRate, $destinationFolder);
|
||||
$filter->setFrameFileType($frameFileType);
|
||||
$this->assertEquals($expected, $filter->apply($video, $format));
|
||||
}
|
||||
|
||||
public function provideFrameRates()
|
||||
{
|
||||
return array(
|
||||
array(ExtractMultipleFramesFilter::FRAMERATE_EVERY_SEC, 'jpg', '/', 100, 2, array('-vf', 'fps=1/1', '/frame-%03d.jpg')),
|
||||
array(ExtractMultipleFramesFilter::FRAMERATE_EVERY_2SEC, 'jpg', '/', 100, 2, array('-vf', 'fps=1/2', '/frame-%02d.jpg')),
|
||||
array(ExtractMultipleFramesFilter::FRAMERATE_EVERY_5SEC, 'jpg', '/', 100, 2, array('-vf', 'fps=1/5', '/frame-%02d.jpg')),
|
||||
array(ExtractMultipleFramesFilter::FRAMERATE_EVERY_10SEC, 'jpg', '/', 100, 2, array('-vf', 'fps=1/10', '/frame-%02d.jpg')),
|
||||
array(ExtractMultipleFramesFilter::FRAMERATE_EVERY_30SEC, 'jpg', '/', 100, 2, array('-vf', 'fps=1/30', '/frame-%02d.jpg')),
|
||||
array(ExtractMultipleFramesFilter::FRAMERATE_EVERY_60SEC, 'jpg', '/', 100, 2, array('-vf', 'fps=1/60', '/frame-%02d.jpg')),
|
||||
|
||||
array(ExtractMultipleFramesFilter::FRAMERATE_EVERY_SEC, 'jpeg', '/', 100, 2, array('-vf', 'fps=1/1', '/frame-%03d.jpeg')),
|
||||
array(ExtractMultipleFramesFilter::FRAMERATE_EVERY_2SEC, 'jpeg', '/', 100, 2, array('-vf', 'fps=1/2', '/frame-%02d.jpeg')),
|
||||
array(ExtractMultipleFramesFilter::FRAMERATE_EVERY_5SEC, 'jpeg', '/', 100, 2, array('-vf', 'fps=1/5', '/frame-%02d.jpeg')),
|
||||
array(ExtractMultipleFramesFilter::FRAMERATE_EVERY_10SEC, 'jpeg', '/', 100, 2, array('-vf', 'fps=1/10', '/frame-%02d.jpeg')),
|
||||
array(ExtractMultipleFramesFilter::FRAMERATE_EVERY_30SEC, 'jpeg', '/', 100, 2, array('-vf', 'fps=1/30', '/frame-%02d.jpeg')),
|
||||
array(ExtractMultipleFramesFilter::FRAMERATE_EVERY_60SEC, 'jpeg', '/', 100, 2, array('-vf', 'fps=1/60', '/frame-%02d.jpeg')),
|
||||
|
||||
array(ExtractMultipleFramesFilter::FRAMERATE_EVERY_SEC, 'png', '/', 100, 2, array('-vf', 'fps=1/1', '/frame-%03d.png')),
|
||||
array(ExtractMultipleFramesFilter::FRAMERATE_EVERY_2SEC, 'png', '/', 100, 2, array('-vf', 'fps=1/2', '/frame-%02d.png')),
|
||||
array(ExtractMultipleFramesFilter::FRAMERATE_EVERY_5SEC, 'png', '/', 100, 2, array('-vf', 'fps=1/5', '/frame-%02d.png')),
|
||||
array(ExtractMultipleFramesFilter::FRAMERATE_EVERY_10SEC, 'png', '/', 100, 2, array('-vf', 'fps=1/10', '/frame-%02d.png')),
|
||||
array(ExtractMultipleFramesFilter::FRAMERATE_EVERY_30SEC, 'png', '/', 100, 2, array('-vf', 'fps=1/30', '/frame-%02d.png')),
|
||||
array(ExtractMultipleFramesFilter::FRAMERATE_EVERY_60SEC, 'png', '/', 100, 2, array('-vf', 'fps=1/60', '/frame-%02d.png')),
|
||||
);
|
||||
}
|
||||
|
||||
public function testInvalidFrameFileType() {
|
||||
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
||||
$filter = new ExtractMultipleFramesFilter('1/1', '/');
|
||||
$filter->setFrameFileType('webm');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\FFMpeg\Unit\Filters\Video;
|
||||
|
||||
use FFMpeg\Filters\Video\PadFilter;
|
||||
use Tests\FFMpeg\Unit\TestCase;
|
||||
use FFMpeg\FFProbe\DataMapping\Stream;
|
||||
use FFMpeg\FFProbe\DataMapping\StreamCollection;
|
||||
use FFMpeg\Coordinate\Dimension;
|
||||
|
||||
class PadFilterTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideDimensions
|
||||
*/
|
||||
public function testApply(Dimension $dimension, $width, $height, $expected)
|
||||
{
|
||||
$video = $this->getVideoMock();
|
||||
$pathfile = '/path/to/file'.mt_rand();
|
||||
|
||||
$format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
|
||||
|
||||
$streams = new StreamCollection(array(
|
||||
new Stream(array(
|
||||
'codec_type' => 'video',
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
))
|
||||
));
|
||||
|
||||
$filter = new PadFilter($dimension);
|
||||
$this->assertEquals($expected, $filter->apply($video, $format));
|
||||
}
|
||||
|
||||
public function provideDimensions()
|
||||
{
|
||||
return array(
|
||||
array(new Dimension(1000, 800), 640, 480, array('-vf', 'scale=iw*min(1000/iw\,800/ih):ih*min(1000/iw\,800/ih),pad=1000:800:(1000-iw)/2:(800-ih)/2')),
|
||||
array(new Dimension(300, 600), 640, 480, array('-vf', 'scale=iw*min(300/iw\,600/ih):ih*min(300/iw\,600/ih),pad=300:600:(300-iw)/2:(600-ih)/2')),
|
||||
array(new Dimension(100, 900), 640, 480, array('-vf', 'scale=iw*min(100/iw\,900/ih):ih*min(100/iw\,900/ih),pad=100:900:(100-iw)/2:(900-ih)/2')),
|
||||
array(new Dimension(1200, 200), 640, 480, array('-vf', 'scale=iw*min(1200/iw\,200/ih):ih*min(1200/iw\,200/ih),pad=1200:200:(1200-iw)/2:(200-ih)/2')),
|
||||
);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue