Search code examples
perlffmpegyoutube-dl

ffmpeg not working from php script but works from command line


i can run youtube-dl.php from command line "php youtube-dl.php" works fine

but not working from http... is it someting with chown?

$url = "https://www.youtube.com/watch?v=KdS6HFQ_LUc";

echo "Saving $url";


$cmd = 'youtube-dl -o "/var/www/domain.com/test/%(title)s.%(ext)s" '.$url.' -f bestvideo+bestaudio'; 
exec($cmd, $output, $ret);
echo 'output: ';
var_export($output);

echo "\nret: "; var_export($ret);


Solution

  • There is no need to run any scripts in the first place. Simply add -f bestvideo+bestaudio/best to your youtube-dl command-line and let youtube-dl merge the video automatically. Don't forget to install ffmpeg!