title: Run a ffmpeg process in the background
body: <p>I am wanting to use ffmpeg to convert video to .flv in php.  Currently I have this working, but it hangs the browser until the file is uploaded and is finished.  I have been looking at the php docs on how to run an exec() process in the background, while updating the process using the returned PID.  Here is what I found:</p>
  
  <pre><code>//Run linux command in background and return the PID created by the OS
  function run_in_background($Command, $Priority = 0)
  {
      if($Priority)
          $PID = shell_exec("nohup nice -n $Priority $Command &gt; /dev/null &amp; echo $!");
      else
          $PID = shell_exec("nohup $Command &gt; /dev/null &amp; echo $!");
      return($PID);
  }
  </code></pre>
  
  <p>There is also a trick which  I use to track if the background task is running using the returned PID :</p>
  
  <pre><code>//Verifies if a process is running in linux
  function is_process_running($PID)
  {
      exec("ps $PID", $ProcessState);
      return(count($ProcessState) &gt;= 2);
  }
  </code></pre>
  
  <p>Am I suppose to create a separate .php file which then runs from the php cli to execute one of these functions?  I just need a little nudge in getting this working and then I can take it from there.</p>
  
  <p>Thanks!</p>