Using ffmpeg, PHP and beanstalk
I am very new to ffmpeg and beanstalk and I need a little help. I want to use beanstalk to queue files for ffmpeg to convert. I've downloaded, installed and started beanstalkd (also installed libevent as it suggests to) and i've downloaded a PHP client for beanstalkd;
http://sourceforge.net/projects/beanstalk/
Now after download the client and putting it on my 开发者_Go百科server, I have done nothing but use the example from the client and i'm getting this error;
Fatal error: Maximum execution time of 30 seconds exceeded in /Users/wasimkhamlichi/Sites/vibenation/beanstalk/src/BeanStalk.class.php on line 1138
This is the code from the example;
$beanstalk = BeanStalk::open(array(
'servers' => array( '127.0.0.1:11300' ),
'select' => 'random peek'
));
// As in the protocol doc.
$beanstalk->use_tube('foo');
// As in the protocol doc.
$beanstalk->put(0, 0, 120, 'say hello world'); // Add a job to the queue with highest priority,
// no delay, 120 seconds TTR, with the contents
// 'say hello world'.
// NOTE: the put() method here supports a final optional
// argument, a tube name. If supplied, the server will
// first switch to that tube, write the job, then switch
// back to the old tube again.
// As in the protocol doc.
$job = $beanstalk->reserve(); // Assuming there was nothing in the queue before
// we started, this will give us our 'hello world'
// job back.
// This is a BeanQueueJob object.
echo $job->get(); // Output: 'say hello world'
Beanstalk::delete($job); // Delete the job.
Very simple quick script just to say hello but it's timing out. Can anyone help please?
Beanstalk just passes messages around. You put something into the queue in one place, and take it out somewhere else, later.
You could put a filename into a tube called 'ffmpeg-convert'. A PHP script running from the command line reserves the next item from the queue, and does what it needs to, putting the finished file in an appropriate place.
If you needed more information (for example, where to put the finished file, quality settings or a new output filename), you can encode the information - an array of information converted into a Json string (with json_encode($array)
) is a good choice. You put the encoded string into Beanstalk, and the cli-script decodes the string, and does the work.
Running the worker as a command-line based script usually avoids any timeout issues. Unlike a webpage request, there is not a default timeout, also there is more latitude regarding memory use.
精彩评论