Sunday, February 27, 2011

Re: how to redirect and let the server do some lengthy job in the background?

On Feb 27, 2011, at 09:06, Tan Cheng wrote:

> I have a question. I'm using cakephp to develop a video site, like
> youtube, I want the user to upload their video to the site, but I only
> want them to wait for the upload, after it is uploaded, I hope the
> converting process ( using ffmpeg ) run in the background and they
> will be redirected to a different page.

You will want your video conversion to happen in a separate process that has nothing to do with the web server. PHP in a web server imposes execution time limits which are not appropriate for lengthy operations like video encoding.

In your web page, after the file has been uploaded, you'll probably want to enter the new video into the database and indicate with a flag column that the video has not yet been encoded. Then you have some other process (a CakePHP shell, if you like) that runs on the server as a daemon. It would find all videos in the database that have not yet been encoded, encodes them, and then marks them in the database as having been encoded, then sleeps for awhile before checking again.


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: