PHP ffmpeg exec returns null

I am trying to run ffmpeg through a call to PHP exec, I debugged for a while and looked at a lot of answers here, but still could not find the answers ...

My simplified call:

$cmd = 'ffmpeg 2>&1'; exec(escapeshellcmd($cmd), $stdout, $stderr); var_dump($stderr); var_dump($stdout); var_dump($cmd); exit; 

My conclusion: $ stderr = int (1) and $ stdout = array (0) {}

I also tried shell_exec($cmd) , which returns NULL .

cmd.exe has permissions set for the IUSR account - for example. I can run $cmd = 'dir' and see the output of the directory.

PHP does not work in safe mode.

The ffmpeg.exe file is in the same directory as my php file, but I have the same answer that gives the absolute path to the ffmpeg.exe file in $cmd .

ffmpeg does a fine from the command line.

I am running Windows XP, IIS and PHP 5.3.

EDIT:

If I run 'ffmpeg -h', I get help commands that should indicate that ffmpeg is recognized

I increased the PHP memory limit to 1024 - no luck.

+4
source share
1 answer

Now it works for me - I think there may be several problems:

It turns out that $cmd = 'ffmpeg' returns null, so this is not a good test!

An escape shell command also runs on the '2> & 1' echo 2 ^> ^ & 1 "- I think this was my original problem.

Now I managed to execute the test file using: 'ffmpeg -i SAMPLE.AVI 2> & 1'.

Work code:

 $cmd = 'ffmpeg -i SAMPLE.AVI 2>&1'; exec($cmd, $output, $value); var_dump($output); var_dump($value); var_dump($cmd); exit; 

As noted above, ffmpeg is a bit of memory, so you should also check the memory.

+5
source

Source: https://habr.com/ru/post/1402224/


All Articles