2

The following worked fine locally on Windows 7, but now the website is on Windows 8 and does not work. This is run in an Apache web request:

exec('ffmpeg -i "C:\temp\testing.mp4" "C:\temp\testing.mp3"', $errors, $result);
    var_dump($errors);
    var_dump($result);
    exit;

gives: array(0) { } int(1)

$output = exec('ffmpeg -i "C:\\temp\\testing.mp4" "C:\\temp\\testing.mp3"', $errors, $result);
var_dump($output);
var_dump($errors);
var_dump($result);
exit;

gives: string(0) "" array(0) { } int(1)

but if I execute the text C:\temp\testing.mp4" "C:\temp\testing.mp3 in the command window in any directory (PATH is set to ffmpeg), it works fine.

I set the rights on c:\temp for all users to full control, but the MP3 file is still not created. Why is this statement not being executed in Windows 8 but is executed in Windows 7? How can I find out more information about why it is not creating the MP3 file?

Interestingly, this works:

exec('copy "C:\\temp\\testing.mp4" "C:\\temp\\testing.mp3"', $result);
var_dump($result);

and yields:

array(1) { [0]=> string(30) " 1 file(s) copied." } 
halfer
  • 19,824
  • 17
  • 99
  • 186
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
  • It might be the env vars are not being sent, and perhaps this command needs them. [See this answer](http://stackoverflow.com/a/10056329/472495) for ideas - that was on Mac, but it could apply to all OSes. – halfer Jun 03 '14 at 07:31
  • Also, are you running this command on the console or in the web server? If the latter, try the former, using `php test.php`. – halfer Jun 03 '14 at 07:34

1 Answers1

1

I found the answer:

After editing the Environment Path variable, Restart Apache for it to take effect in PHP.

Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
  • Hmm, if were are running the PHP script from `cmd`, how could Apache have an effect on it? `:)` – halfer Jun 03 '14 at 09:02
  • Sorry for the confusion, I meant that I (1) was executing the PHP script via Apache where it wouldn't work, and then (2) was copying and pasting the command into the command prompt where it would work. – Edward Tanguay Jun 03 '14 at 16:07
  • Ah righto. The intermediate thing to try would have been to see if the PHP `exec` worked at the console. – halfer Jun 03 '14 at 21:08