Version 0.3

This commit is contained in:
Romain Neutron 2013-06-25 10:03:20 +02:00
commit ad3a5af623
130 changed files with 7283 additions and 2627 deletions

View file

@ -11,23 +11,24 @@
namespace FFMpeg\Format\Audio;
use Evenement\EventEmitter;
use FFMpeg\Exception\InvalidArgumentException;
use FFMpeg\Format\AudioInterface;
use FFMpeg\Media\MediaTypeInterface;
use FFMpeg\Format\ProgressableInterface;
use FFMpeg\Format\ProgressListener\AudioProgressListener;
use FFMpeg\FFProbe;
/**
* The abstract default Audio format
*
* @author Romain Neutron imprec@gmail.com
*/
abstract class DefaultAudio implements Resamplable, Interactive
abstract class DefaultAudio extends EventEmitter implements AudioInterface, ProgressableInterface
{
/** @var string */
protected $audioCodec;
protected $audioSampleRate = 44100;
protected $kiloBitrate = 128;
/** @var integer */
protected $audioKiloBitrate = 128;
/**
* Returns extra parameters for the encoding
*
* @return string
* {@inheritdoc}
*/
public function getExtraParams()
{
@ -43,11 +44,12 @@ abstract class DefaultAudio implements Resamplable, Interactive
}
/**
* Set the audio codec, Should be in the available ones, otherwise an
* Sets the audio codec, Should be in the available ones, otherwise an
* exception is thrown
*
* @param string $audioCodec
* @throws \InvalidArgumentException
* @param string $audioCodec
*
* @throws InvalidArgumentException
*/
public function setAudioCodec($audioCodec)
{
@ -66,24 +68,24 @@ abstract class DefaultAudio implements Resamplable, Interactive
/**
* {@inheritdoc}
*/
public function getAudioSampleRate()
public function getAudioKiloBitrate()
{
return $this->audioSampleRate;
return $this->audioKiloBitrate;
}
/**
* Set the audio sample rate
* Sets the kiloBitrate value
*
* @param integer $audioSampleRate
* @throws \InvalidArgumentException
* @param integer $kiloBitrate
* @throws InvalidArgumentException
*/
public function setAudioSampleRate($audioSampleRate)
public function setAudioKiloBitrate($kiloBitrate)
{
if ($audioSampleRate < 1) {
throw new InvalidArgumentException('Wrong audio sample rate value');
if ($kiloBitrate < 1) {
throw new InvalidArgumentException('Wrong kiloBitrate value');
}
$this->audioSampleRate = (int) $audioSampleRate;
$this->audioKiloBitrate = (int) $kiloBitrate;
return $this;
}
@ -91,25 +93,14 @@ abstract class DefaultAudio implements Resamplable, Interactive
/**
* {@inheritdoc}
*/
public function getKiloBitrate()
public function createProgressListener(MediaTypeInterface $media, FFProbe $ffprobe, $pass, $total)
{
return $this->kiloBitrate;
}
$format = $this;
$listener = new AudioProgressListener($ffprobe, $media->getPathfile(), $pass, $total);
$listener->on('progress', function () use ($media, $format) {
$format->emit('progress', array_merge(array($media, $format), func_get_args()));
});
/**
* Set the kiloBitrate value
*
* @param int integer $kiloBitrate
* @throws \InvalidArgumentException
*/
public function setKiloBitrate($kiloBitrate)
{
if ($kiloBitrate < 1) {
throw new InvalidArgumentException('Wrong kiloBitrate value');
}
$this->kiloBitrate = (int) $kiloBitrate;
return $this;
return array($listener);
}
}

View file

@ -13,12 +13,13 @@ namespace FFMpeg\Format\Audio;
/**
* The Flac audio format
*
* @author Romain Neutron imprec@gmail.com
*/
class Flac extends DefaultAudio
{
protected $audioCodec = 'flac';
public function __construct()
{
$this->audioCodec = 'flac';
}
/**
* {@inheritDoc}

View file

@ -1,30 +0,0 @@
<?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\Audio;
/**
* The interactive audio interface. This provide a method to list available
* codecs. This is usefull to build interactive development and switch between
* different codecs
*
* @author Romain Neutron imprec@gmail.com
*/
interface Interactive extends Transcodable
{
/**
* Returns the list of available audio codecs for this format
*
* @return array
*/
public function getAvailableAudioCodecs();
}

View file

@ -13,12 +13,13 @@ namespace FFMpeg\Format\Audio;
/**
* The MP3 audio format
*
* @author Romain Neutron imprec@gmail.com
*/
class Mp3 extends DefaultAudio
{
protected $audioCodec = 'libmp3lame';
public function __construct()
{
$this->audioCodec = 'libmp3lame';
}
/**
* {@inheritDoc}

View file

@ -1,32 +0,0 @@
<?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\Audio;
use FFMpeg\Format\AudioInterface;
/**
* The resamplable audio interface
*
* This provide a method to define the AudiosampleRate
*
* @author Romain Neutron imprec@gmail.com
*/
interface Resamplable extends AudioInterface
{
/**
* Get the audio sample rate
*
* @return integer
*/
public function getAudioSampleRate();
}

View file

@ -1,28 +0,0 @@
<?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\Audio;
use FFMpeg\Format\AudioInterface;
/**
* @author Romain Neutron imprec@gmail.com
*/
interface Transcodable extends AudioInterface
{
/**
* Returns the audio codec
*
* @return string
*/
public function getAudioCodec();
}