问题
<?PHP
exec("ffmpeg.exe -i something.mp4 -ss 1 -t 1 -r 1 -s 320x240 -y something.jpg");
?>
Calling this script results in a server error 500 every other request. PHP 7.01, IIS 10.
I have already ruled out that the problem might be related to the specific ffmpeg paramters of my call.
The execution is < than 1 second, so it can't be a PHP or IIS script execution timeout.
No matter how much time passes between one "call" to the script and the next, the odd numbered calls result in error 500, the even numbered calls are just fine.
Note that when I say "call" I actually refer to calling the script (i.e. http://server/script.php ) - whereas if I put 2,3, or 100 calls to Exec within the same script, they will all succeed.
Edit: Quite randomly, I tried to trigger a timeout by calling the same Exec("ffmpeg etc. ) line 100 times in a loop. To my surprise, the Error 500 disappears. So I removed the loop and added a similar pause by adding a call to sleep(10): the error 500 returns, and it's instant - like the server fails to run the script even before parsing it. Now I am totally lost..
Any hint?
回答1:
Well, it seems that changing the FastCGI protocol for PHP from Named Pipe to TCP, fixed the problem.
It would still be interesting, though, understanding what makes Named Pipes fail immediately every other time. Setting Named Pipe Flushing didn't help.
来源:https://stackoverflow.com/questions/46067127/php-exec-ffmpeg-fails-on-iis-every-other-request