problem with shell_exec in a library. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: problem with shell_exec in a library. (/showthread.php?tid=12339) |
problem with shell_exec in a library. - El Forum - 10-15-2008 [eluser]oll[/eluser] For the youtube-like website I'm developping for my work, I use the function below, with ffmpeg as Command, to convert a video file into flash, since it can take a long time to be converted (I redirect the output and then "ajax" it in a webpage, so that the user can go on doing something else meanwhile). background process with php Code: function run_in_background($Command) It works well with a simple PHP page. It also works well with codeigniter if I put this function directly in the controller and call it with another function (for instance, index() ) Code: $pid = $this->run_in_background($videofile); It works means "I have the pid instantantly" and the web site goes on, while ffmpeg process in the background. But I would like to use it with the library I created and it doesn't work. It's defined as a method in my library (a simple copy/paste from this function in the library file) I have another method, createflash(), in which there's a simple : Code: function createflash() { There's no error, but it waits for the function to finish (it can take several minutes) before finally displaying me the result . As if there wasn't the "nohup". It looks like an instantiation behaviour problem, but I can't find where, since I'm far from being a specialist Thx. problem with shell_exec in a library. - El Forum - 10-19-2008 [eluser]antonumia[/eluser] If by 'library' you mean a model you need to include it in your controller constructer: function MYClassname(){ $this->load->model->modelname; } then in your function: $PID = $this->modelname->functionname(); Also if you're doing flv encoding using ffmpeg you should also install flvtool2 to insert the metadata after the flv has been created e.g. shell_exec("flvtool2 -UP ".$filepath ); problem with shell_exec in a library. - El Forum - 10-20-2008 [eluser]oll[/eluser] Thank you for the answer (and for flvtool2 tip !). Yes, actually, I spoke about a library ( I created an extension from the php_ffmpeg one). But anyway, it finally apperas to be a shell_exec problem when using the redirection in the script (It's a real mess to make that work), so unrelated to CI, sorry. The test I did : Code: <?php Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); The results : http://videos/index.php/testbg/testfgcontroller : 5.0071 http://videos/index.php/testbg/testbgcontroller : 0.0063 http://videos/index.php/testbg/testbglib: 5.0068 http://videos/index.php/testbg/testbglib : 0.0065 There's so absolutly no problem with CI |