Browse Source

intial working version, can convert the directory and generate the playlist

master
Sean Clarke 2 years ago
parent
commit
1a6bd7e00c
  1. 9
      mp3-to-ogg.php

9
mp3-to-ogg.php

@ -2,12 +2,15 @@
$mp3s = shell_exec('find "$(pwd)" -type f -name "*.mp3"');
$mp3s_ex = preg_split("/\\r\\n|\\r|\\n/", $mp3s);
$mp3s_total = sizeof($mp3s_ex);
$playlist = 'playlist.txt';
for($i = 0; $i < $mp3s_total - 1; $i++){
for($i = 0; $i < $mp3s_total; $i++){
// echo $mp3s_ex[$i] . PHP_EOL;
$mp3 = $mp3s_ex[$i];
$ogg = str_replace('.mp3', '.ogg', $mp3);
echo $ogg . PHP_EOL;
file_put_contents($playlist, $ogg . PHP_EOL, FILE_APPEND | LOCK_EX);
shell_exec('mpg321 ' . $mp3 . ' -w raw && oggenc raw -o' . $ogg);
}
?>