This commit is contained in:
Xes
2025-08-14 22:41:49 +02:00
parent 2de81ccc46
commit 8ce45119b6
39774 changed files with 4309466 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
/vendor
/nbproject
composer.phar
/tests/phpunit_report

View File

@@ -0,0 +1,18 @@
language: php
services: []
before_script:
- sudo apt-get update
- sudo apt-get install -y gpac
- composer install --dev --prefer-source
php:
- 5.3.3
- 5.3
- 5.4
- 5.5
script:
- phpunit --coverage-text
- phpunit -c phpunit-functional.xml.dist

View File

@@ -0,0 +1,35 @@
CHANGELOG
---------
* 0.3.0 (06-25-2013)
* BC Break : switch MP4Box::create arguments.
* BC Break : simplify service provider configuration.
* 0.2.2 (04-27-2013)
* Split unit and functional tests
* Upgrade to alchemy/binary-driver 1.3.4
* 0.2.1 (04-24-2013)
* Add support for timeout in ServiceProvider
* Move tests in their own namespace
* 0.2.0 (04-24-2013)
* Use alchemy/binary-driver as base driver
* BC Break : `MP4Box::load()` is replaced by `MP4Box::create()`. `load` now
allows a driver creation with a customized binary path.
* BC Break : Invoking constructor is deprecated in favor of `load` and `create`
methods.
* BC Break : There are no more `open` and `close` methods. The `process` method
now takes input and output files as argument.
* 0.1.1 (01-11-2012)
* Adjust composer dependencies with the tilde operator, adjust to larger dependencies
* 0.1.0 (12-21-2012)
* First stable version.

18
vendor/php-mp4box/php-mp4box/LICENSE vendored Normal file
View File

@@ -0,0 +1,18 @@
MIT License
Copyright (c) 2012 Alchemy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.

64
vendor/php-mp4box/php-mp4box/README.md vendored Normal file
View File

@@ -0,0 +1,64 @@
#PHP MP4Box
[![Build Status](https://secure.travis-ci.org/alchemy-fr/PHP-MP4Box.png?branch=master)](http://travis-ci.org/alchemy-fr/PHP-MP4Box)
PHP driver for MP4Box
## API usage
To instantiate MP4Box driver, the easiest way is :
```php
$mp4box = MP4Box\MP4Box::create();
```
You can customize your driver by passing a `Psr\Log\LoggerInterface` or
configuration options.
Available options are :
- timeout : the timeout for the underlying process
- mp4box.binaries : the path (or an array of paths) to custom binary.
```php
$mp4box = MP4Box\MP4Box::create(array(
'timeout' => 42,
'mp4box.bonaries' => '/path/to/custom/binary',
), $logger);
```
To process a mp4 file, use the `process` method :
```php
$mp4box->process('video.mp4');
```
If you do not want to process file in place, you can write the output in another
file :
```php
$mp4box->process('video.mp4', 'output.mp4');
```
## Silex Service Provider :
A [Silex](silex.sensiolabs.org) Service Provider is available, all parameters
are optionals :
```php
$app = new Silex\Application();
$app->register(new MP4Box\MP4BoxServiceProvider(), array(
'mp4box.configuration' => array(
'mp4box.binaries' => '/path/to/custom/binary',
'timeout' => 42,
),
'mp4box.logger' => $app->share(function () {
return $app['monolog']; // use Monolog service provider
}),
));
```
## License
MIT licensed

View File

@@ -0,0 +1,32 @@
{
"name": "php-mp4box/php-mp4box",
"type": "library",
"description": "PHP MP4Box, an Object Oriented library for easy file conversion with MP4 Box",
"keywords": ["mp4box", "gpac"],
"license": "MIT",
"authors": [
{
"name": "Romain Neutron",
"email": "imprec@gmail.com",
"homepage": "http://www.lickmychip.com/"
},
{
"name": "Phraseanet Team",
"email": "info@alchemy.fr",
"homepage": "http://www.phraseanet.com/"
}
],
"require": {
"php" : ">=5.3.3",
"alchemy/binary-driver" : "~1.5"
},
"require-dev": {
"phpunit/phpunit" : "~3.7",
"silex/silex" : "~1.0"
},
"autoload": {
"psr-0": {
"MP4Box": "src"
}
}
}

1088
vendor/php-mp4box/php-mp4box/composer.lock generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="true"
verbose="false"
bootstrap="tests/bootstrap.php"
>
<php>
<ini name="display_errors" value="on"/>
</php>
<testsuites>
<testsuite name="MP4Box Functional Tests Suite">
<directory>tests/MP4Box/Functional</directory>
</testsuite>
</testsuites>
<filter>
<blacklist>
<directory>vendor</directory>
<directory>tests</directory>
</blacklist>
</filter>
</phpunit>

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="true"
verbose="false"
bootstrap="tests/bootstrap.php"
>
<logging>
<log type="coverage-html" target="tests/phpunit_report/report" charset="UTF-8"
yui="true" highlight="false"
lowUpperBound="35" highLowerBound="70"/>
</logging>
<php>
<ini name="display_errors" value="on"/>
</php>
<testsuites>
<testsuite name="PHP MP4Box Tests Suite">
<directory>tests/MP4Box/Tests</directory>
</testsuite>
</testsuites>
<filter>
<blacklist>
<directory>vendor</directory>
<directory>tests</directory>
</blacklist>
</filter>
</phpunit>

View File

@@ -0,0 +1,16 @@
<?php
/*
* This file is part of PHP-MP4Box.
*
* (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 MP4Box\Exception;
interface ExceptionInterface
{
}

View File

@@ -0,0 +1,16 @@
<?php
/*
* This file is part of PHP-MP4Box.
*
* (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 MP4Box\Exception;
class InvalidFileArgumentException extends \InvalidArgumentException implements ExceptionInterface
{
}

View File

@@ -0,0 +1,16 @@
<?php
/*
* This file is part of PHP-MP4Box.
*
* (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 MP4Box\Exception;
class RuntimeException extends \RuntimeException implements ExceptionInterface
{
}

View File

@@ -0,0 +1,92 @@
<?php
/*
* This file is part of PHP-MP4Box.
*
* (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 MP4Box;
use Alchemy\BinaryDriver\AbstractBinary;
use Alchemy\BinaryDriver\Configuration;
use Alchemy\BinaryDriver\ConfigurationInterface;
use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
use MP4Box\Exception\InvalidFileArgumentException;
use MP4Box\Exception\RuntimeException;
use Psr\Log\LoggerInterface;
class MP4Box extends AbstractBinary
{
/**
* {@inheritdoc}
*/
public function getName()
{
return 'MP4Box';
}
/**
* Processes a file
*
* @param string $inputFile The file to process.
* @param null|string $outputFile The output file to write. If not provided, processes the file in place.
*
* @return MP4Box
*
* @throws InvalidFileArgumentException In case the input file is not readable
* @throws RuntimeException In case the process failed
*/
public function process($inputFile, $outputFile = null)
{
if (!file_exists($inputFile) || !is_readable($inputFile)) {
throw new InvalidFileArgumentException(sprintf('File %s does not exist or is not readable', $inputFile));
}
$arguments = array(
'-quiet',
'-inter',
'0.5',
'-tmp',
dirname($inputFile),
$inputFile,
);
if ($outputFile) {
$arguments[] = '-out';
$arguments[] = $outputFile;
}
try {
$this->command($arguments);
} catch (ExecutionFailureException $e) {
throw new RuntimeException(sprintf(
'MP4Box failed to process %s', $inputFile
), $e->getCode(), $e);
}
return $this;
}
/**
* Creates an MP4Box binary adapter.
*
* @param null|LoggerInterface $logger
* @param array|ConfigurationInterface $conf
*
* @return MP4Box
*/
public static function create($conf = array(), LoggerInterface $logger = null)
{
if (!$conf instanceof ConfigurationInterface) {
$conf = new Configuration($conf);
}
$binaries = $conf->get('mp4box.binaries', array('MP4Box'));
return static::load($binaries, $logger, $conf);
}
}

View File

@@ -0,0 +1,40 @@
<?php
/*
* This file is part of PHP-MP4Box.
*
* (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 MP4Box;
use Silex\Application;
use Silex\ServiceProviderInterface;
class MP4BoxServiceProvider implements ServiceProviderInterface
{
public function register(Application $app)
{
$app['mp4box.default.configuration'] = array(
'mp4box.binaries' => array('MP4Box'),
'timeout' => 60,
);
$app['mp4box.configuration'] = array();
$app['mp4box.logger'] = null;
$app['mp4box'] = $app->share(function(Application $app) {
$app['mp4box.configuration'] = array_replace(
$app['mp4box.default.configuration'], $app['mp4box.configuration']
);
return MP4Box::create($app['mp4box.configuration'], $app['mp4box.logger']);
});
}
public function boot(Application $app)
{
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace MP4Box\Functional;
use MP4Box\MP4Box;
class MP4BoxTest extends \PHPUnit_Framework_TestCase
{
public function testProcess()
{
$mp4box = MP4Box::create();
$mp4box->process(__DIR__ . '/../../files/Video.mp4');
}
public function testProcessWithCustomOutput()
{
$out = __DIR__ . '/../../files/OutVideo.mp4';
if (file_exists($out)) {
unlink($out);
}
$mp4box = MP4Box::create();
$mp4box->process(__DIR__ . '/../../files/Video.mp4', $out);
$this->assertTrue(file_exists($out));
unlink($out);
}
/**
* @expectedException MP4Box\Exception\RuntimeException
*/
public function testProcessFail()
{
$mp4box = MP4Box::create();
$mp4box->process(__DIR__ . '/../../files/WrongFile.mp4');
}
}

View File

@@ -0,0 +1,62 @@
<?php
namespace MP4Box\Tests;
use Silex\Application;
use MP4Box\MP4BoxServiceProvider;
class MP4BoxServiceProviderTest extends \PHPUnit_Framework_TestCase
{
public function getApplication()
{
return new Application();
}
public function testInit()
{
$app = $this->getApplication();
$app->register(new MP4BoxServiceProvider());
$this->assertInstanceOf('\\MP4Box\\MP4Box', $app['mp4box']);
}
/**
* @expectedException Alchemy\BinaryDriver\Exception\ExecutableNotFoundException
*/
public function testInitFailOnBinary()
{
$app = $this->getApplication();
$app->register(new MP4BoxServiceProvider(), array(
'mp4box.configuration' => array(
'mp4box.binaries' => 'no/binary/here'
)
));
$app['mp4box'];
}
public function testInitCustomLogger()
{
$logger = $this->getMock('Psr\Log\LoggerInterface');
$app = $this->getApplication();
$app->register(new MP4BoxServiceProvider(), array(
'mp4box.logger' => $logger
));
$this->assertInstanceOf('\\MP4Box\\MP4Box', $app['mp4box']);
$this->assertEquals($logger, $app['mp4box']->getProcessRunner()->getLogger());
}
public function testInitCustomTimeout()
{
$app = $this->getApplication();
$app->register(new MP4BoxServiceProvider(), array(
'mp4box.configuration' => array(
'timeout' => 128
)
));
$this->assertEquals(128, $app['mp4box']->getProcessBuilderFactory()->getTimeout());
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace MP4Box\Tests;
use MP4Box\MP4Box;
use Alchemy\BinaryDriver\BinaryDriverTestCase;
class MP4BoxTest extends BinaryDriverTestCase
{
public function testProcessOutputWithCustomOutput()
{
$input = __DIR__ . '/../../files/Video.mp4';
$out = 'Output.mp4';
$mp4box = MP4Box::create();
$factory = $this->createProcessBuilderFactoryMock();
$process = $this->createProcessMock(1, true);
$factory
->expects($this->once())
->method('create')
->with(array(
'-quiet',
'-inter',
'0.5',
'-tmp',
dirname($input),
$input,
'-out',
$out,
))
->will($this->returnValue($process));
$mp4box->setProcessBuilderFactory($factory);
$mp4box->process(__DIR__ . '/../../files/Video.mp4', $out);
}
/**
* @expectedException MP4Box\Exception\InvalidFileArgumentException
*/
public function testProcessOnNonUnexistingFile()
{
$mp4box = MP4Box::create();
$mp4box->process(__DIR__ . '/../../files/Unknown');
}
}

View File

@@ -0,0 +1,5 @@
<?php
$loader = require __DIR__.'/../vendor/autoload.php';
$loader->add('MP4Box\Tests', __DIR__);
$loader->add('MP4Box\Functional', __DIR__);

Binary file not shown.

Binary file not shown.