-
-
Save mikakaltoft/eb0ee7670835bf9ac72472d6a9cdf5a8 to your computer and use it in GitHub Desktop.
Add an intro audio file to a list of audio files in PHP using SoX.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Make sure you have SoX installed. | |
* * Ubuntu install: `sudo apt-get install sox` | |
* * Mac install (using Homebrew): `brew install sox` | |
*/ | |
$audio_intro = '/var/www/wp-content/uploads/audio-intro.mp3'; | |
$audio_output_dir = '/var/www/wp-content/uploads/audio-output/'; | |
$audio_files = array( | |
0 => array( | |
'id' => 1, | |
'title' => 'Audio File 1', | |
'file_path' => '/var/www/wp-content/uploads/audio-originals/1' | |
), | |
1 => array( | |
'id' => 2, | |
'title' => 'Audio File 2', | |
'file_path' => '/var/www/wp-content/uploads/audio-originals/2' | |
) | |
); | |
foreach ($audio_files as $audio_file) { | |
$input = $audio_file['file_path']; | |
$output = $audio_output_dir.$audio_file['id'].'.mp3'; | |
$command = 'sox '$audio_intro.' '.$input.' '.$output; | |
shell_exec($command); | |
$new_audio_url = 'http://example.com/wp-content/uploads/improved/'.$audio_file['id'].'.mp3'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment