Rename Audio to AudioInterface and Video to VideoInterface

This commit is contained in:
Romain Neutron 2012-10-31 00:53:26 +01:00
commit ea17f2f257
12 changed files with 128 additions and 34 deletions

View file

@ -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
<?php
namespace Foo\Bar;
use FFMpeg\Format\Video;
use FFMpeg\Format\VideoInterface;
class MyFormat implements Video
class MyFormat implements VideoInterface
{
public function getKiloBitrate()
{
@ -400,9 +400,9 @@ The following example initialize a Flac format and extract the audio track from
Create your own media type
++++++++++++++++++++++++++
PHP-FFMpeg provides ``FFMpeg\Format\Audio``, as base interface for creating an
Audio format. To define a target format, all you need to do is implement this
Interface.
PHP-FFMpeg provides ``FFMpeg\Format\AudioInterface``, as base interface for
creating an Audio format. To define a target format, all you need to do is
implement this Interface.
This example transcodes the mp3 track to a 128kb mp3 :
@ -411,9 +411,9 @@ This example transcodes the mp3 track to a 128kb mp3 :
<?php
namespace Foo\Bar;
use FFMpeg\Format\Audio;
use FFMpeg\Format\AudioInterface;
class MyFormat implements Audio
class MyFormat implements AudioInterface
{
public function getKiloBitrate()
{
@ -522,9 +522,9 @@ latest AvConv / FFMPeg version, aac encoding has to be executed with extra comma
namespace Foo\Bar;
use FFMpeg\Format\Audio\Transcodable;
use FFMpeg\Format\Video;
use FFMpeg\Format\VideoInterface;
class MyFormat implements Video, Transcodable
class MyFormat implements VideoInterface, Transcodable
{
public function getAudioCodec()

View file

@ -14,8 +14,8 @@ namespace FFMpeg;
use FFMpeg\Exception\InvalidArgumentException;
use FFMpeg\Exception\LogicException;
use FFMpeg\Exception\RuntimeException;
use FFMpeg\Format\Audio;
use FFMpeg\Format\Video;
use FFMpeg\Format\AudioInterface;
use FFMpeg\Format\VideoInterface;
use FFMpeg\Helper\HelperInterface;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\ProcessBuilder;
@ -183,24 +183,24 @@ class FFMpeg extends Binary
/**
* Encode the file to the specified format
*
* @param Audio $format The output format
* @param AudioInterface $format The output format
* @param string $outputPathfile The pathfile where to write
* @return \FFMpeg\FFMpeg
* @throws RuntimeException
* @throws LogicException
*/
public function encode(Audio $format, $outputPathfile)
public function encode(AudioInterface $format, $outputPathfile)
{
if (!$this->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',

View file

@ -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
{
/**

View file

@ -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
{
/**

View file

@ -16,7 +16,7 @@ namespace FFMpeg\Format;
*
* @author Romain Neutron imprec@gmail.com
*/
interface Audio
interface AudioInterface
{
/**

View file

@ -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
{
/**

View file

@ -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
{
/**

View file

@ -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
{
/**

View file

@ -0,0 +1,47 @@
<?php
/*
* This file is part of PHP-FFmpeg.
*
* (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 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');
}
}

View file

@ -0,0 +1,47 @@
<?php
/*
* This file is part of PHP-FFmpeg.
*
* (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 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');
}
}

View file

@ -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

View file

@ -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');