每隔一个其他请求,PHP Exec(ffmpeg)在IIS上失败 [英] PHP Exec (ffmpeg) fails on IIS every other request

查看:54
本文介绍了每隔一个其他请求,PHP Exec(ffmpeg)在IIS上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?PHP
    exec("ffmpeg.exe -i something.mp4 -ss 1 -t 1 -r 1 -s 320x240 -y something.jpg");
?>

调用此脚本会导致服务器错误500 其他每个请求.PHP 7.01,IIS 10.

Calling this script results in a server error 500 every other request. PHP 7.01, IIS 10.

我已经排除了问题可能与呼叫中的特定ffmpeg参数有关.

I have already ruled out that the problem might be related to the specific ffmpeg paramters of my call.

执行是<超过1秒,因此它不能是PHP或IIS脚本执行超时.

The execution is < than 1 second, so it can't be a PHP or IIS script execution timeout.

无论一个脚本调用到下一个脚本调用之间经过了多少时间,奇数调用都会导致错误500,偶数调用就可以了.

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.

请注意,当我说调用"时,实际上是指调用脚本(即 http://server/script.php )-如果我在同一个脚本中对Exec进行了2,3或100次调用,它们将全部成功.

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.

很随机,我试图通过在循环中调用同一Exec("ffmpeg等.)行100次来触发超时.令我惊讶的是,错误500消失了.所以我删除了循环并添加了类似的内容通过添加对sleep(10)的调用来暂停:错误500返回,并且是即时的-就像服务器甚至在解析脚本之前都无法运行脚本.现在我完全迷失了..

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..

有任何提示吗?

推荐答案

好吧,看来将PHP的FastCGI协议从命名管道更改为TCP可以解决此问题.

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.

这篇关于每隔一个其他请求,PHP Exec(ffmpeg)在IIS上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆