11

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.

  1. Upload File
  2. Convert video to .flv
  3. Generate thumb
  4. 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.

9
  • Have you checked phpinfo(); that all parameters have been actually changed?
    – zerkms
    Oct 5, 2011 at 2:15
  • did you restart php after editing php.ini?
    – user557846
    Oct 5, 2011 at 2:22
  • Could it be the hosting company is blocking you from doing this? There is a safety setting which disallows you from changing max exec time some hosts like to use. I'll try to find the setting name
    – Jess
    Oct 5, 2011 at 2:23
  • 2
    so you'd be willing to allow requests to run for 1 hour? why aren't you doing this in the background?
    – miki
    Oct 5, 2011 at 2:26
  • ah found it, it's when php is compiled with safe mode on, idk if it works for the php.ini settings, but I know it would block the max exec command, php.net/manual/en/ini.sect.safe-mode.php#ini.safe-mode
    – Jess
    Oct 5, 2011 at 2:31

3 Answers 3

20

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

if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0)
{
    @set_time_limit(300);
}

I try to change the value and it works.

1
2

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.

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.