Using ffmpeg, PHP and beanstalk

I am very new to ffmpeg and beanstalk and I need a little help. I want to use beanstalk for file queue for ffmpeg for conversion. I downloaded, installed and started beanstalkd (also installed libevent, as it suggests), and I downloaded the PHP client for beanstalkd;

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

Now, after loading the client and placing it on my server, I did nothing but an example from the client, and I get this error;

Fatal error : maximum run 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 fast script just say hello, but this time. Can anyone help?

+2
source share
1 answer

Beanstalk just sends messages. You queue something in one place and take it out somewhere else, later.

You can put the file name in the handset called "ffmpeg-convert". A PHP script launched from the command line reserves the next element from the queue and does what it needs by placing the finished file in the right place.

If you need additional information (for example, where to put the finished file, quality parameters or a new name for the output file), you can encode information - an array of information converted to a Json string (with json_encode($array) ), a good choice. You put the encoded string in Beanstalk, and the cli- script decodes the string and does the work.

Running a worker as a script-based command line usually avoids any timeout problems. Unlike requesting a webpage, there is no default timeout; there is also a lot of freedom regarding memory usage.

+2
source

Source: https://habr.com/ru/post/1391630/


All Articles