Question

i ran into some problems lately with SoX and PHP. I am a complete beginner in running command-line tools in PHP, so i try to describe the problem as good as i can:

So we have the following situation:

There is a .wav-file in the folder [root]/demo/test.wav

My php-file is located is located in [root]/inc/classes.php

So the php looks somewhat like this (really a minimal example)

function wav() {
    $output = shell_exec('sox ..\demo\test.wav -n stat');
    var_dump($output);
    echo "<pre>".$output."</pre>";
}

So if i run the function (and if i take a really huge .wav-file) it seems to "do" something, because the browser takes a long time to run the request.

But everything i receive is "NULL"

If i change the shell_exec-command to shell_exec('sox -help') it works.

So my question is: How come? xD

best regards

Was it helpful?

Solution

I've been banging my head against the wall with this one too. You were the only documented problem I could find on it. All I wanted was the mp3 duration.

shell_exec("sox test.mp3 -n stat") // was returning NULL

but

shell_exec("sox --i -D test.mp3") // worked!

No idea why.

Three months late, but this might save someone some time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top