Methods getAdditionalParams & setAdditionalParams which allow the user to pass additional parameters to the encoding request (#284)

* Modification of the format Video to add additional parameters based on user's desire
* Update of the README
* Working version of this feature. Still needs tests
* Fixing the tests of FFMPeg\Media\Video
* Setting up tests for the additionalParams feature
* Correction des tests
* Modifying tests. They work locally but not on Travis.
* Still trying to understand why Travis is throwing errors when PHPUnit is not.
* Add the additional params at the end of the command
* Fixed the tests and the way we add the parameters
* We remove log files
This commit is contained in:
Romain Biard 2017-01-24 15:19:32 -03:00 committed by GitHub
commit 6ba011de3a
5 changed files with 136 additions and 7 deletions

View file

@ -32,6 +32,9 @@ abstract class DefaultVideo extends DefaultAudio implements VideoInterface
/** @var Integer */
protected $modulus = 16;
/** @var Array */
protected $additionalParamaters;
/**
* {@inheritdoc}
*/
@ -94,6 +97,31 @@ abstract class DefaultVideo extends DefaultAudio implements VideoInterface
return $this->modulus;
}
/**
* {@inheritdoc}
*/
public function getAdditionalParameters()
{
return $this->additionalParamaters;
}
/**
* Sets additional parameters.
*
* @param array $additionalParamaters
* @throws InvalidArgumentException
*/
public function setAdditionalParameters($additionalParamaters)
{
if (!is_array($additionalParamaters)) {
throw new InvalidArgumentException('Wrong additionalParamaters value');
}
$this->additionalParamaters = $additionalParamaters;
return $this;
}
/**
* {@inheritdoc}
*/

View file

@ -54,4 +54,11 @@ interface VideoInterface extends AudioInterface
* @return array
*/
public function getAvailableVideoCodecs();
/**
* Returns the list of available video codecs for this format.
*
* @return array
*/
public function getAdditionalParameters();
}

View file

@ -120,6 +120,15 @@ class Video extends Audio
}
}
// If the user passed some additional parameters
if ($format instanceof VideoInterface) {
if (null !== $format->getAdditionalParameters()) {
foreach ($format->getAdditionalParameters() as $additionalParameter) {
$commands[] = $additionalParameter;
}
}
}
$fs = FsManager::create();
$fsId = uniqid('ffmpeg-passes');
$passPrefix = $fs->createTemporaryDirectory(0777, 50, $fsId) . '/' . uniqid('pass-');