Merge branch 'master' of github.com:SimonSimCity/PHP-FFMpeg into SimonSimCity-master
* 'master' of github.com:SimonSimCity/PHP-FFMpeg: checkstyle by php-cs-fixer Added configuration for audio channels
This commit is contained in:
commit
c1993b6b92
10 changed files with 131 additions and 20 deletions
|
|
@ -27,6 +27,9 @@ abstract class DefaultAudio extends EventEmitter implements AudioInterface, Prog
|
|||
/** @var integer */
|
||||
protected $audioKiloBitrate = 128;
|
||||
|
||||
/** @var integer */
|
||||
protected $audioChannels = null;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -90,6 +93,31 @@ abstract class DefaultAudio extends EventEmitter implements AudioInterface, Prog
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAudioChannels()
|
||||
{
|
||||
return $this->audioChannels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the channels value.
|
||||
*
|
||||
* @param integer $channels
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function setAudioChannels($channels)
|
||||
{
|
||||
if ($channels < 1) {
|
||||
throw new InvalidArgumentException('Wrong channels value');
|
||||
}
|
||||
|
||||
$this->audioChannels = (int) $channels;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,6 +19,13 @@ interface AudioInterface extends FormatInterface
|
|||
*/
|
||||
public function getAudioKiloBitrate();
|
||||
|
||||
/**
|
||||
* Gets the audio channels value.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getAudioChannels();
|
||||
|
||||
/**
|
||||
* Returns the audio codec.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -87,6 +87,10 @@ class Audio extends AbstractStreamableMedia
|
|||
$commands[] = '-b:a';
|
||||
$commands[] = $format->getAudioKiloBitrate() . 'k';
|
||||
}
|
||||
if (null !== $format->getAudioChannels()) {
|
||||
$commands[] = '-ac';
|
||||
$commands[] = $format->getAudioChannels();
|
||||
}
|
||||
$commands[] = $outputPathfile;
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -113,6 +113,10 @@ class Video extends Audio
|
|||
$commands[] = '-b:a';
|
||||
$commands[] = $format->getAudioKiloBitrate() . 'k';
|
||||
}
|
||||
if (null !== $format->getAudioChannels()) {
|
||||
$commands[] = '-ac';
|
||||
$commands[] = $format->getAudioChannels();
|
||||
}
|
||||
}
|
||||
|
||||
$fs = FsManager::create();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue