Browse Source

initial commit copy from mp3-to-ogg and modified

master
Sean Clarke 2 years ago
commit
b8fddab5f5
  1. 5
      README.md
  2. 17
      flac-to-ogg.php

5
README.md

@ -0,0 +1,5 @@
# flac-to-ogg
This is a basic PHP script that can convert an entire directory (with all sub directories) of flac to ogg files.
[Buy me a ☕ or ☕☕](https://www.buymeacoffee.com/seanland)

17
flac-to-ogg.php

@ -0,0 +1,17 @@
<?php
$flacs = shell_exec('find "$(pwd)" -type f -name "*.flac"');
$flacs_ex = preg_split("/\\r\\n|\\r|\\n/", $flacs);
$flacs_total = sizeof($flacs_ex);
$playlist = 'playlist.txt';
for($i = 0; $i < $flacs_total - 1; $i++){
$flac = $flacs_ex[$i];
$ogg = str_replace('.flac', '.ogg', $flac);
# Generating the list
file_put_contents($playlist, $ogg . PHP_EOL, FILE_APPEND | LOCK_EX);
# The conversion command
shell_exec('ffmpeg -i ' . $flac . ' ' . $ogg);
}
?>