From 96225b2dff65a4c3b0b541f2420742ffe5851127 Mon Sep 17 00:00:00 2001 From: Romain Biard Date: Fri, 30 Jun 2017 21:27:10 +0200 Subject: [PATCH] Revert "Audio Params" (#377) * Revert "Correct type in VideoFilters->framerate (#372)" This reverts commit cedcd37bd22479bbe7874fd0e063a2047e122d0a. * Revert "fix sources parameter type (array) in concat function (#363)" This reverts commit af00b9d6a395386742de80f46c6d0973e70e5540. * Revert "Audio Params (#344)" This reverts commit cb7d850338844d74f425c44c0b883d3b24681255. --- src/FFMpeg/Format/Audio/DefaultAudio.php | 25 ----- src/FFMpeg/Format/AudioInterface.php | 7 -- src/FFMpeg/Format/Profile.php | 22 ---- src/FFMpeg/Format/Video/DefaultVideo.php | 78 +++++--------- src/FFMpeg/Format/VideoInterface.php | 13 +-- src/FFMpeg/Media/Audio.php | 7 -- src/FFMpeg/Media/Video.php | 10 +- tests/Unit/Media/VideoTest.php | 125 ++++++++++------------- 8 files changed, 88 insertions(+), 199 deletions(-) delete mode 100644 src/FFMpeg/Format/Profile.php diff --git a/src/FFMpeg/Format/Audio/DefaultAudio.php b/src/FFMpeg/Format/Audio/DefaultAudio.php index d0d1030..4226bff 100644 --- a/src/FFMpeg/Format/Audio/DefaultAudio.php +++ b/src/FFMpeg/Format/Audio/DefaultAudio.php @@ -46,31 +46,6 @@ abstract class DefaultAudio extends EventEmitter implements AudioInterface, Prog return $this->audioCodec; } - /** - * {@inheritdoc} - */ - public function getAdditionalParameters() - { - return $this->additionalParameters; - } - - /** - * Sets additional parameters. - * - * @param array $additionalParameters - * @throws InvalidArgumentException - */ - public function setAdditionalParameters($additionalParameters) - { - if (!is_array($additionalParameters)) { - throw new InvalidArgumentException('Wrong additionalParamaters value'); - } - - $this->additionalParameters = $additionalParameters; - - return $this; - } - /** * Sets the audio codec, Should be in the available ones, otherwise an * exception is thrown. diff --git a/src/FFMpeg/Format/AudioInterface.php b/src/FFMpeg/Format/AudioInterface.php index 9a8a927..1af29c0 100644 --- a/src/FFMpeg/Format/AudioInterface.php +++ b/src/FFMpeg/Format/AudioInterface.php @@ -25,13 +25,6 @@ interface AudioInterface extends FormatInterface * @return integer */ public function getAudioChannels(); - - /** - * Returns the list of available video codecs for this format. - * - * @return array - */ - public function getAdditionalParameters(); /** * Returns the audio codec. diff --git a/src/FFMpeg/Format/Profile.php b/src/FFMpeg/Format/Profile.php deleted file mode 100644 index 32a65a7..0000000 --- a/src/FFMpeg/Format/Profile.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FFMpeg\Format; - -interface Profile { - - const HIGH = 'high'; - - const MAIN = 'main'; - - const BASELINE = 'baseline'; - -} \ No newline at end of file diff --git a/src/FFMpeg/Format/Video/DefaultVideo.php b/src/FFMpeg/Format/Video/DefaultVideo.php index dc7d898..1abfa67 100644 --- a/src/FFMpeg/Format/Video/DefaultVideo.php +++ b/src/FFMpeg/Format/Video/DefaultVideo.php @@ -16,7 +16,6 @@ use FFMpeg\Exception\InvalidArgumentException; use FFMpeg\Format\Audio\DefaultAudio; use FFMpeg\Format\VideoInterface; use FFMpeg\Media\MediaTypeInterface; -use FFMpeg\Format\Profile; use FFMpeg\Format\ProgressListener\VideoProgressListener; /** @@ -33,56 +32,8 @@ abstract class DefaultVideo extends DefaultAudio implements VideoInterface /** @var Integer */ protected $modulus = 16; - /** @var string */ - private $profile = Profile::MAIN; - - /** @var float */ - private $level = 3.1; - - /** @var string[] */ - protected $additionalParameters; - - /** - * Sets the profile of this video - * @var string $profile must be one of `baseline`, `main` or `high` - * @throws \InvalidArgumentException - */ - public function setProfile(string $profile) { - switch($profile) { - case Profile::BASELINE: - case Profile::MAIN: - case Profile::HIGH: - // these are fine - break; - default: - throw new \InvalidArgumentException('Invalid profile given! Must be one of `baseline`, `main` or `high`!'); - } - $this->profile = $profile; - return $this; - } - - /** - * @inheritDoc - */ - public function getProfile() { - return $this->profile; - } - - /** - * Sets the given level - * @param float $level The level(for example: 3.0, 3.1, 4.0, 4.1) - */ - public function setLevel(float $level) { - $this->level = $level; - return $this; - } - - /** - * @inheritDoc - */ - public function getLevel() { - return $this->level; - } + /** @var Array */ + protected $additionalParamaters; /** * {@inheritdoc} @@ -146,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} */ diff --git a/src/FFMpeg/Format/VideoInterface.php b/src/FFMpeg/Format/VideoInterface.php index 71bb659..329bff2 100644 --- a/src/FFMpeg/Format/VideoInterface.php +++ b/src/FFMpeg/Format/VideoInterface.php @@ -56,14 +56,9 @@ interface VideoInterface extends AudioInterface public function getAvailableVideoCodecs(); /** - * Returns the current profile - * @return string + * Returns the list of available video codecs for this format. + * + * @return array */ - public function getProfile(); - - /** - * Returns the level - * @return float - */ - public function getLevel(); + public function getAdditionalParameters(); } diff --git a/src/FFMpeg/Media/Audio.php b/src/FFMpeg/Media/Audio.php index 4b5c84b..19f3478 100644 --- a/src/FFMpeg/Media/Audio.php +++ b/src/FFMpeg/Media/Audio.php @@ -91,13 +91,6 @@ class Audio extends AbstractStreamableMedia $commands[] = '-ac'; $commands[] = $format->getAudioChannels(); } - // If the user passed some additional parameters - if (null !== $format->getAdditionalParameters()) { - foreach ($format->getAdditionalParameters() as $additionalParameter) { - $commands[] = $additionalParameter; - } - } - $commands[] = $outputPathfile; try { diff --git a/src/FFMpeg/Media/Video.php b/src/FFMpeg/Media/Video.php index a757b21..a3fa271 100644 --- a/src/FFMpeg/Media/Video.php +++ b/src/FFMpeg/Media/Video.php @@ -72,8 +72,6 @@ class Video extends Audio if ($format instanceof VideoInterface) { if (null !== $format->getVideoCodec()) { $filters->add(new SimpleFilter(array('-vcodec', $format->getVideoCodec()))); - $filters->add(new SimpleFilter(array('-vprofile', $format->getProfile()))); - $filters->add(new SimpleFilter(array('-level', $format->getLevel()))); } } if ($format instanceof AudioInterface) { @@ -123,9 +121,11 @@ class Video extends Audio } // If the user passed some additional parameters - if (null !== $format->getAdditionalParameters()) { - foreach ($format->getAdditionalParameters() as $additionalParameter) { - $commands[] = $additionalParameter; + if ($format instanceof VideoInterface) { + if (null !== $format->getAdditionalParameters()) { + foreach ($format->getAdditionalParameters() as $additionalParameter) { + $commands[] = $additionalParameter; + } } } diff --git a/tests/Unit/Media/VideoTest.php b/tests/Unit/Media/VideoTest.php index 322ba53..009a2f6 100644 --- a/tests/Unit/Media/VideoTest.php +++ b/tests/Unit/Media/VideoTest.php @@ -449,81 +449,60 @@ class VideoTest extends AbstractStreamableTestCase 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__, - '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__, '-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__, - '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', + '-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__,