FFMpeg + Beanstalk: How to pass the processes to it
===

I'm working around on the video web site! I have a simple PHP function that is used to start complicated conversion processes. The problem is that FFMpeg and Mencoder are extremely resourceful and having one process of it is something that makes httpd slow down but multiple processes just hang it completely. I want to my conversion processes with Beanstalk (or anything else). Everything is working well right now: converting, logging and etc.

My concrete question is: How to transfer my current jobs to Beanstalk?

I have very simple PHP code:

 `RunInBackground('convert.php', array($initial_file_name, $vid), $LogFilePath);`

And the function looks also quite clear:

    function RunInBackground($sPHPFile, $aParam = array(), $sLogFile = '')
    {
        global $config;
    
        $sCmd = $config['phppath'] . ' ' . $config['BASE_DIR'] . '/' . $sPHPFile;
        foreach ($aParam as $s)
        {
            $sCmd .= ' ' . $s;
        }
    
    
            $sCmd .= ' > ' . ($sLogFile != '' ? $config['BASE_DIR'] . '/' . $sLogFile : '/dev/null');
    
            if ( iBgProc($sCmd) )
            {
                return true;
            }
            else
            {
                return false;
            }
        
    }
    
    function iBgProc($sCmd, $iPrio = 0)
    {
        if ($iPrio)
        {
            $iPID = shell_exec("nohup nice -n $iPrio $sCmd 2> /dev/null & echo $!");
        }
        else
        {
            $iPID = shell_exec("nohup $sCmd 2> /dev/null & echo $!");
        }
    
        return($iPID);
    }
`

Now what would Beanstalk correct code would look like so these processes would NOT start all at the same time if multiple videos are uploaded?

If you believe that for my needs is better to use something else but Beanstalk and you know how to implement it, I would be still happy to see it!

Thanks!