Skip to content

Instantly share code, notes, and snippets.

@farvisun
Created July 29, 2018 17:00
Show Gist options
  • Save farvisun/67e4bf7079627bb39271448299b6ed2b to your computer and use it in GitHub Desktop.
Save farvisun/67e4bf7079627bb39271448299b6ed2b to your computer and use it in GitHub Desktop.
convert music video to mp3 inside directory with ffmpeg
<?php
$files = scandir(__DIR__);
foreach($files as $file){
$name = explode(".",$file);
unset($name[count($name)-1]);
$name = implode("-",$name);
$name = str_replace(" ","-",$name);
$name = strtolower($name);
$name = preg_replace("/[\-]{1,}/i","-",$name);
echo "Start Convert for " . $name . "\n";
exec("ffmpeg -i \"".$file."\" -vn -acodec libmp3lame -ac 2 -qscale:a 4 -ar 48000 ".$name.".mp3");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment