public function getAudioStream($url, $format)
{
if (!shell_exec('which ' . $this->config->avconv)) {
throw new \Exception('Can\'t find avconv or ffmpeg');
}
$video = $this->getJSON($url, $format);
//Vimeo needs a correct user-agent
ini_set('user_agent', $video->http_headers->{'User-Agent'});
$avconvProc = ProcessBuilder::create([$this->config->avconv, '-v', 'quiet', '-i', '-', '-f', 'mp3', '-vn', 'pipe:1']);
if (parse_url($video->url, PHP_URL_SCHEME) == 'rtmp') {
$process = $this->getRtmpProcess($video);
} else {
$process = $this->getCurlProcess($video);
}
$chain = new Chain($process);
$chain->add('|', $avconvProc);
return popen($chain->getProcess()->getCommandLine(), 'r');
}