2

我对 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.

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

4

1 回答 1

2

Beanstalk 只是传递消息。您将某样东西放在一个地方的队列中,稍后再从其他地方取出。

您可以将文件名放入名为“ffmpeg-convert”的管中。从命令行运行的 PHP 脚本会保留队列中的下一项,并执行所需的操作,将完成的文件放在适当的位置。

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

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.

于 2011-04-12T23:04:21.940 回答