2

私はffmpegとbeanstalkに非常に慣れていないので、少し助けが必要です. Beanstalk を使用して、ffmpeg が変換するファイルをキューに入れたいと考えています。私はbeanstalkdをダウンロードしてインストールし、起動しました(それが示唆するようにlibeventもインストールしました)。beanstalkd用のPHPクライアントをダウンロードしました。

http://sourceforge.net/projects/beanstalk/

クライアントをダウンロードしてサーバーに配置した後、クライアントからの例を使用するだけで、このエラーが発生します。

致命的なエラー: 1138 行目の /Users/wasimkhamlici/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-script が文字列をデコードし、作業を行います。

通常、ワーカーをコマンドライン ベースのスクリプトとして実行すると、タイムアウトの問題が回避されます。Web ページ リクエストとは異なり、デフォルトのタイムアウトはなく、メモリの使用に関しても自由度があります。

于 2011-04-12T23:04:21.940 に答える