Last active
May 30, 2016 05:56
-
-
Save adriancarriger/7cfb2d4586d28b9a65c8ad98fa61d15b 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 hidden or 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