From ea17f2f257354abc2d817fc8d788c5491ecc8c8c Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Wed, 31 Oct 2012 00:53:26 +0100 Subject: [PATCH] Rename Audio to AudioInterface and Video to VideoInterface --- docs/source/Recipes.rst | 24 +++++----- src/FFMpeg/FFMpeg.php | 18 +++---- src/FFMpeg/Format/Audio/Resamplable.php | 4 +- src/FFMpeg/Format/Audio/Transcodable.php | 4 +- .../Format/{Audio.php => AudioInterface.php} | 2 +- src/FFMpeg/Format/Video/Resamplable.php | 4 +- src/FFMpeg/Format/Video/Resizable.php | 4 +- src/FFMpeg/Format/Video/Transcodable.php | 4 +- src/FFMpeg/Format/Video/WMV.php | 47 +++++++++++++++++++ src/FFMpeg/Format/Video/WMV3.php | 47 +++++++++++++++++++ .../Format/{Video.php => VideoInterface.php} | 2 +- tests/src/FFMpeg/FFMpegTest.php | 2 +- 12 files changed, 128 insertions(+), 34 deletions(-) rename src/FFMpeg/Format/{Audio.php => AudioInterface.php} (96%) create mode 100644 src/FFMpeg/Format/Video/WMV.php create mode 100644 src/FFMpeg/Format/Video/WMV3.php rename src/FFMpeg/Format/{Video.php => VideoInterface.php} (90%) diff --git a/docs/source/Recipes.rst b/docs/source/Recipes.rst index 3545b13..95cd105 100644 --- a/docs/source/Recipes.rst +++ b/docs/source/Recipes.rst @@ -197,18 +197,18 @@ PHP-FFMpeg provides three video formats out of the box : HTML5 video formats Create your own media type ++++++++++++++++++++++++++ -PHP-FFMpeg provides ``FFMpeg\Format\Video``, as base interface for creating a -Video format. To define a target format, all you need to do is implement this -Interface. +PHP-FFMpeg provides ``FFMpeg\Format\VideoInterface``, as base interface for +creating a Video format. To define a target format, all you need to do is +implement this Interface. .. code-block:: php pathfile) { throw new LogicException('No file open'); } switch (true) { - case $format instanceof Video: + case $format instanceof VideoInterface: $this->encodeVideo($format, $outputPathfile); break; default: - case $format instanceof Audio: + case $format instanceof AudioInterface: $this->encodeAudio($format, $outputPathfile); break; } @@ -216,7 +216,7 @@ class FFMpeg extends Binary * @return \FFMpeg\FFMpeg * @throws RuntimeException */ - protected function encodeAudio(Audio $format, $outputPathfile) + protected function encodeAudio(AudioInterface $format, $outputPathfile) { $builder = ProcessBuilder::create(array( $this->binary, @@ -263,12 +263,12 @@ class FFMpeg extends Binary /** * Encode to video * - * @param Video $format The output format + * @param VideoInterface $format The output format * @param string $outputPathfile The pathfile where to write * @return \FFMpeg\FFMpeg * @throws RuntimeException */ - protected function encodeVideo(Video $format, $outputPathfile) + protected function encodeVideo(VideoInterface $format, $outputPathfile) { $builder = ProcessBuilder::create(array( $this->binary, '-y', '-i', diff --git a/src/FFMpeg/Format/Audio/Resamplable.php b/src/FFMpeg/Format/Audio/Resamplable.php index d208218..2f8aa81 100644 --- a/src/FFMpeg/Format/Audio/Resamplable.php +++ b/src/FFMpeg/Format/Audio/Resamplable.php @@ -11,7 +11,7 @@ namespace FFMpeg\Format\Audio; -use FFMpeg\Format\Audio as BaseAudio; +use FFMpeg\Format\AudioInterface; /** * The resamplable audio interface @@ -20,7 +20,7 @@ use FFMpeg\Format\Audio as BaseAudio; * * @author Romain Neutron imprec@gmail.com */ -interface Resamplable extends BaseAudio +interface Resamplable extends AudioInterface { /** diff --git a/src/FFMpeg/Format/Audio/Transcodable.php b/src/FFMpeg/Format/Audio/Transcodable.php index c110b00..3b85ecc 100644 --- a/src/FFMpeg/Format/Audio/Transcodable.php +++ b/src/FFMpeg/Format/Audio/Transcodable.php @@ -11,12 +11,12 @@ namespace FFMpeg\Format\Audio; -use FFMpeg\Format\Audio as BaseAudio; +use FFMpeg\Format\AudioInterface; /** * @author Romain Neutron imprec@gmail.com */ -interface Transcodable extends BaseAudio +interface Transcodable extends AudioInterface { /** diff --git a/src/FFMpeg/Format/Audio.php b/src/FFMpeg/Format/AudioInterface.php similarity index 96% rename from src/FFMpeg/Format/Audio.php rename to src/FFMpeg/Format/AudioInterface.php index 10e5e50..22eac12 100644 --- a/src/FFMpeg/Format/Audio.php +++ b/src/FFMpeg/Format/AudioInterface.php @@ -16,7 +16,7 @@ namespace FFMpeg\Format; * * @author Romain Neutron imprec@gmail.com */ -interface Audio +interface AudioInterface { /** diff --git a/src/FFMpeg/Format/Video/Resamplable.php b/src/FFMpeg/Format/Video/Resamplable.php index 0d4e2ff..dd00ebc 100644 --- a/src/FFMpeg/Format/Video/Resamplable.php +++ b/src/FFMpeg/Format/Video/Resamplable.php @@ -11,7 +11,7 @@ namespace FFMpeg\Format\Video; -use FFMpeg\Format\Video as BaseVideo; +use FFMpeg\Format\VideoInterface; /** * The resamplable video interface @@ -20,7 +20,7 @@ use FFMpeg\Format\Video as BaseVideo; * * @author Romain Neutron imprec@gmail.com */ -interface Resamplable extends BaseVideo +interface Resamplable extends VideoInterface { /** diff --git a/src/FFMpeg/Format/Video/Resizable.php b/src/FFMpeg/Format/Video/Resizable.php index a3b0e99..63289d6 100644 --- a/src/FFMpeg/Format/Video/Resizable.php +++ b/src/FFMpeg/Format/Video/Resizable.php @@ -11,7 +11,7 @@ namespace FFMpeg\Format\Video; -use FFMpeg\Format\Video as BaseVideo; +use FFMpeg\Format\VideoInterface; use FFMpeg\Format\Dimension; /** @@ -21,7 +21,7 @@ use FFMpeg\Format\Dimension; * * @author Romain Neutron imprec@gmail.com */ -interface Resizable extends BaseVideo +interface Resizable extends VideoInterface { /** diff --git a/src/FFMpeg/Format/Video/Transcodable.php b/src/FFMpeg/Format/Video/Transcodable.php index 5ef2395..2c6a92a 100644 --- a/src/FFMpeg/Format/Video/Transcodable.php +++ b/src/FFMpeg/Format/Video/Transcodable.php @@ -11,12 +11,12 @@ namespace FFMpeg\Format\Video; -use FFMpeg\Format\Video as BaseVideo; +use FFMpeg\Format\VideoInterface; /** * @author Romain Neutron imprec@gmail.com */ -interface Transcodable extends BaseVideo +interface Transcodable extends VideoInterface { /** diff --git a/src/FFMpeg/Format/Video/WMV.php b/src/FFMpeg/Format/Video/WMV.php new file mode 100644 index 0000000..ae57ecd --- /dev/null +++ b/src/FFMpeg/Format/Video/WMV.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace FFMpeg\Format\Video; + +/** + * The WMV video format + * + * @author Romain Neutron imprec@gmail.com + */ +class WMV extends DefaultVideo +{ + protected $audioCodec = 'wmav2'; + protected $videoCodec = 'wmv2'; + + /** + * {@inheritDoc} + */ + public function supportBFrames() + { + return false; + } + + /** + * {@inheritDoc} + */ + public function getAvailableAudioCodecs() + { + return array('wmav2'); + } + + /** + * {@inheritDoc} + */ + public function getAvailableVideoCodecs() + { + return array('wmv2'); + } +} diff --git a/src/FFMpeg/Format/Video/WMV3.php b/src/FFMpeg/Format/Video/WMV3.php new file mode 100644 index 0000000..a534b52 --- /dev/null +++ b/src/FFMpeg/Format/Video/WMV3.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace FFMpeg\Format\Video; + +/** + * The WMV video format + * + * @author Romain Neutron imprec@gmail.com + */ +class WMV3 extends DefaultVideo +{ + protected $audioCodec = 'wmav3'; + protected $videoCodec = 'wmv3'; + + /** + * {@inheritDoc} + */ + public function supportBFrames() + { + return false; + } + + /** + * {@inheritDoc} + */ + public function getAvailableAudioCodecs() + { + return array('wmav3'); + } + + /** + * {@inheritDoc} + */ + public function getAvailableVideoCodecs() + { + return array('wmv3'); + } +} diff --git a/src/FFMpeg/Format/Video.php b/src/FFMpeg/Format/VideoInterface.php similarity index 90% rename from src/FFMpeg/Format/Video.php rename to src/FFMpeg/Format/VideoInterface.php index 49bf0ae..6e16a5a 100644 --- a/src/FFMpeg/Format/Video.php +++ b/src/FFMpeg/Format/VideoInterface.php @@ -16,7 +16,7 @@ namespace FFMpeg\Format; * * @author Romain Neutron imprec@gmail.com */ -interface Video extends Audio +interface VideoInterface extends AudioInterface { /** * Returns the number of passes diff --git a/tests/src/FFMpeg/FFMpegTest.php b/tests/src/FFMpeg/FFMpegTest.php index 3629008..477f773 100644 --- a/tests/src/FFMpeg/FFMpegTest.php +++ b/tests/src/FFMpeg/FFMpegTest.php @@ -200,7 +200,7 @@ class FFMpegTest extends \PHPUnit_Framework_TestCase { $dest = __DIR__ . '/../../files/encode_test.mp4'; - $format = new Format\Video\WebM(); + $format = new Format\Video\X264(); $format-> setDimensions(32, 32); $this->object->open(__DIR__ . '/../../files/Test.ogv');