使用ffmpeg,PHP和beanstalk [英] Using ffmpeg, PHP and beanstalk

查看:190
本文介绍了使用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'
));

//和协议文档一样。
$ beanstalk-> use_tube('foo');

//和协议文档一样。
$ beanstalk-> put(0,0,120,'say hello world'); //将作业添加到优先级最高的队列中,
//无延迟,120秒TTR,内容为
//'say hello world'。

//注意:这里的put()方法支持一个最终可选的
//参数,一个管名。如果提供,服务器将
//首先切换到该管,写入作业,然后再次切换
//返回旧管。

//和协议文档一样。
$ job = $ beanstalk-> reserve(); //假设在
//之前的队列中没有任何东西,我们开始,这将给我们我们的'你好世界'
//返回。

//这是一个BeanQueueJob对象。
echo $ job-> get(); //输出:'say hello world'

Beanstalk :: delete($ job); //删除作业。

非常简单的快速脚本只是打个招呼,但它是超时的。任何人都可以帮忙吗?

解决方案

Beanstalk只是传递消息。你可以在某个地方将东西放在队列中,然后把它放在别的地方。



你可以把一个文件名放在一个名为'ffmpeg-convert'的管中。从命令行运行的PHP脚本将从队列中保留下一个项目,并执行所需的操作,将完成的文件放在合适的位置。



如果需要更多信息(例如,将完成的文件,质量设置或新的输出文件名放在哪里),您可以对信息进行编码 - 将信息数组转换为Json字符串(使用 json_encode($ array) )是一个不错的选择。您将编码的字符串放入Beanstalk中,cli脚本解码字符串,并进行工作。



以基于命令行为基础的脚本运行worker通常可以避免任何超时问题。与网页请求不同,没有默认超时,还有关于内存使用的更多纬度。


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?

解决方案

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.

这篇关于使用ffmpeg,PHP和beanstalk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆