convert audio to mp3 when ffmpeg is available, otherwise default to m4a;
This commit is contained in:
@@ -10,7 +10,7 @@ class Youtube
|
|||||||
{
|
{
|
||||||
private $ipv4Only;
|
private $ipv4Only;
|
||||||
public $audioOnly = 0;
|
public $audioOnly = 0;
|
||||||
private $audioFormat = 'm4a', $videoFormat;
|
public $audioFormat = 'm4a', $videoFormat;
|
||||||
private $format = 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best';
|
private $format = 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best';
|
||||||
private $options = [];
|
private $options = [];
|
||||||
private $downloadDir;
|
private $downloadDir;
|
||||||
@@ -62,9 +62,9 @@ class Youtube
|
|||||||
$this->addOption('--add-metadata');
|
$this->addOption('--add-metadata');
|
||||||
$this->addOption('--metadata-from-title');
|
$this->addOption('--metadata-from-title');
|
||||||
$this->addOption("%(artist)s - %(title)s");
|
$this->addOption("%(artist)s - %(title)s");
|
||||||
$this->addOption('--audio-format');
|
$this->audioFormat = 'mp3';
|
||||||
$this->addOption($this->audioFormat);
|
|
||||||
}
|
}
|
||||||
|
$this->setAudioFormat($this->audioFormat);
|
||||||
$this->addOption('--extract-audio');
|
$this->addOption('--extract-audio');
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -74,6 +74,16 @@ class Youtube
|
|||||||
$this->setOption('--audio-quality', $value);
|
$this->setOption('--audio-quality', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setAudioFormat($format)
|
||||||
|
{
|
||||||
|
$this->setOption('--audio-format',$format);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setvideoFormat($format)
|
||||||
|
{
|
||||||
|
$this->videoFormat = $format;
|
||||||
|
}
|
||||||
|
|
||||||
public function GetUrlOnly()
|
public function GetUrlOnly()
|
||||||
{
|
{
|
||||||
$this->addOption('--get-filename');
|
$this->addOption('--get-filename');
|
||||||
@@ -201,16 +211,6 @@ class Youtube
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAudioFormat($format)
|
|
||||||
{
|
|
||||||
$this->audioFormat = $format;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setvideoFormat($format)
|
|
||||||
{
|
|
||||||
$this->videoFormat = $format;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function buildCMD()
|
private function buildCMD()
|
||||||
{
|
{
|
||||||
$this->cmd = $this->bin; //. " 2>&1";
|
$this->cmd = $this->bin; //. " 2>&1";
|
||||||
|
|||||||
Reference in New Issue
Block a user