I've searched for help and tried everything on this thread, but still can't make this work. I'm trying to run the sox (Sound eXchange) command line utility from my PHP script using shell_exec(). I need to concatenate two audio files, both of which are in the same directory as the PHP script (i.e. accessible to apache).
Here's the confusion:
So this works in the shell:
"/soxpath/sox /filepath/file1.wav /filepath/file2.wav /filepath/combined.wav"
But this doesn't work from PHP:
shell_exec('/soxpath/sox /filepath/file1.wav /filepath/file2.wav /filepath/combined.wav');
Can anyone shed some light on this? What am I missing? Thanks.
Okay, I got it working finally so I thought I should clear up any confusion I created. The problem was something unrelated. So, yes, you can run sox commands from PHP using shell_exec().
I was simply running into a timing issue with javascript. I was using wami recorder to capture audio on the client side and then save the audio file on the server. So my PHP script was in the context of an ajax call handler, which by definition is asynchronous. Should have realized that earlier.
The issue was that the file was not done saving when the sox command to concatenate was run, so naturally it failed because the file didn't exist yet. When I made the call synchronous it worked.