使用 ffmpeg、PHP 和 beanstalk
我对 ffmpeg 和 beanstalk 非常陌生,我需要一些帮助。我想使用 beanstalk 将文件排队以供 ffmpeg 转换。我已经下载、安装并启动了 beanstalkd(还按照建议安装了 libevent),并且我已经下载了 beanstalkd 的 PHP 客户端;
http://sourceforge.net/projects/beanstalk/
现在下载客户端并将其放在我的服务器,我什么也没做,只是使用客户端的示例,但出现此错误;
致命错误:第 1138 行 /Users/wasimkhamlichi/Sites/vibenation/beanstalk/src/BeanStalk.class.php 中超出了最大执行时间 30 秒
这是示例中的代码;
$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.
非常简单的快速脚本只是为了打个招呼,但它超时了。有人可以帮忙吗?
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 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Beanstalk 只是传递消息。您将某些内容放入队列中的一个位置,然后稍后将其从其他地方取出。
您可以将文件名放入名为“ffmpeg-convert”的管中。从命令行运行的 PHP 脚本会保留队列中的下一个项目,并执行所需的操作,将完成的文件放在适当的位置。
如果您需要更多信息(例如,将完成的文件放在哪里、质量设置或新的输出文件名),您可以对信息进行编码 - 转换为 Json 字符串的信息数组(使用
json_encode($array)
)是一个不错的选择。您将编码后的字符串放入 Beanstalk 中,然后 cli 脚本对字符串进行解码并完成工作。作为基于命令行的脚本运行工作程序通常可以避免任何超时问题。与网页请求不同,它没有默认超时,而且内存使用也有更多的自由度。
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.