mp3-to-ogg.php 515 B

1234567891011121314151617
  1. <?php
  2. $mp3s = shell_exec('find "$(pwd)" -type f -name "*.mp3"');
  3. $mp3s_ex = preg_split("/\\r\\n|\\r|\\n/", $mp3s);
  4. $mp3s_total = sizeof($mp3s_ex);
  5. $playlist = 'playlist.txt';
  6. for($i = 0; $i < $mp3s_total - 1; $i++){
  7. $mp3 = $mp3s_ex[$i];
  8. $ogg = str_replace('.mp3', '.ogg', $mp3);
  9. # Generating the list
  10. file_put_contents($playlist, $ogg . PHP_EOL, FILE_APPEND | LOCK_EX);
  11. # The conversion command
  12. shell_exec('mpg321 "' . $mp3 . '" -w raw && oggenc raw -o "' . $ogg . '"');
  13. }
  14. ?>