PHP 忽略我的 max_execution_time
我的脚本中有一些关于使用 ffmpeg 转换视频的任务。我使用 codeigniter 2.0.3 执行此操作,并在库中找到脚本并使用 shell_exec() 运行 ffmpeg。
我的 php 脚本中有 3 个任务。
- 上传文件
- 将视频转换为 .flv
- 生成缩略图
- 保存到数据库。
当我上传文件时,我的 php 脚本开始转换我上传的视频。但转换结束时大约需要5分多钟。它不会继续生成拇指。它说
PHP 致命错误:第 102 行的 C:\AppServ\www\mis\application\libraries\my_video_utility.php 中超出了最大执行时间 300 秒,引荐来源:http://localhost/mis/test/
我已在 php.ini 中将 max_execution time、max_input_time 等设置为 3600,还添加 set_time_limit() 和我的 php 脚本中的 set_ini() 。但是,它仍然出错。
但是,当我上传短视频时,就完成了。
I have some task in my script that is about converting video with ffmpeg . I do this with codeigniter 2.0.3 and locate the script at libraries and use shell_exec() to run ffmpeg.
There are 3 tasks in my php script.
- Upload File
- Convert video to .flv
- Generate thumb
- Save to db.
When I upload file, my php script start to convert my uploaded video. But when converting is end about over 5 minutes. Its not continue to generate thumb. And Its say
PHP Fatal error: Maximum execution time of 300 seconds exceeded in C:\AppServ\www\mis\application\libraries\my_video_utility.php on line 102, referer: http://localhost/mis/test/
I have set my max_execution time, max_input_time, etc to 3600 in php.ini also add set_time_limit() and set_ini() in my php script. But, its still get error.
But, when I uploaded short video, its done.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好的。我自己做这个。我已经联系了我的老师。 CodeIgniter 没有将其包含在其文档中。
在 system/core/CodeIgniter.php 的第 103 行,
我尝试更改该值并且它有效。
Ok. I do this my self. I have contacted my teacher. There is a something that CodeIgniter not include this in their documentation.
At line 103 in system/core/CodeIgniter.php
I try to change the value and it works.
更改 CodeIgniter.php 中的
set_time_limit()
函数的解决方案是有效的,但我认为更改框架的核心文件不是一个好主意。我发现了另一个决定,你可以在你需要的地方调用
set_time_limit()
,它将在CodeIgniter.php中重叠设置时间限制。Solution to change
set_time_limit()
function in CodeIgniter.php is works, but I'm think it's not good idea to change framework's core files.I'm found another decision, you can call
set_time_limit()
where you need and it will be overlapp setting of time limit in CodeIgniter.php.Codeigniter 2 的 set_time_limit 函数运行时间为 300。升级到 Codeigniter 3 后,一件事开始失败。查看这篇文章后,我意识到 set_time_limit 调用已在 3 中删除,因此您可能必须将接受的答案中的代码添加到您的特定问题代码中。我不建议将其添加回 Codeigniter.php
Codeigniter 2 has the set_time_limit function run with 300. After upgrading to Codeigniter 3, one thing started failing. After viewing this post, I realized that the set_time_limit call was removed in 3, so you may have to add the code in the accepted answer to your particular problem code. I would not recommend adding it back into the Codeigniter.php