Thanks for all the input!!! So much good information to learn. Due to
the tight budget and maybe the site traffic will not be so high, I am
still looking at a shard hosting which supports cron, and maybe let it
run a cake shell every 5 hours to encode and update the database. I
think I am going to do some testing on my ubuntu localhost first. My
goal here may to get my feet wet before thinking about vps with a
queue system.

Again, thanks for the help, I may still have questions to ask in the
process of doing this, it feels like one question always opens a bunch
of new questions...really appreciate all your time and knowledge!!

-David

On Feb 28, 5:37 am, Ryan Schmidt <[email protected]> wrote:
> On Feb 28, 2011, at 04:14, AD7six wrote:
>
>
>
> > On Feb 28, 8:14 am, Zaky Katalan-Ezra wrote:
> >> On a Linux machine  create a bash file like this
> >> -----
> >> #!/bin/sh
>
> >> ffmpeg -i $1 -r $2 $3 &
>
> >> -----
> >> The ampersand at the end tell the bash to run in the background.
> >> the $n is parameters.
>
> >> From php call it like  this:
> >> $command = mybashpath.sh inputfile.mpg 24 outputfile.flv;
> >> *exec* ( $command );
>
> > That's not going to work.
>
> > If the calling process (php http request) finishes before the child
> > ("ffmpeg ... &") then your child process will die immediately also.
> > For your example you'd want
>
> > exec('nohup ffmpeg ... &');
>
> This might depend on which web server you're using, and its settings. Some 
> web servers keep long-running processes that handle many requests in a row, 
> others might spawn a new process for each request.
>
> > however, IMO you're better off using a real queue system, if for no
> > other reason that it makes pushing logic into background processes so
> > much easier in general (sending emails, processing files, reindexing
> > data etc. etc.)
>
> Right. If you have 100 users upload their videos simultaneously, that's 
> great, but you probably don't want to then start 100 simultaneous video 
> encode jobs; your CPU will be overloaded, probably you'll run out of memory 
> too and slow things down further as you start thrashing virtual memory. 
> Better to enqueue each video encode request (e.g. by creating a record in the 
> videos table and setting the column encoded=0), and then have a separate 
> daemon that dequeues videos and encodes them (and marks them as encoded=1) 
> one at a time (or however many your system can handle at once, given how many 
> CPU cores and how much memory it has).

-- 
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
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to