title: PHP exec to convert all files in directory using ffmpeg
body: <p>How do i loop thru video files in a directory with extension .flv and use exec to convert each one of them (one at a time ) to mpg using <code>ffmpeg -i original.avi final.mpg</code></p>
  
  <p>While current file is converting, the next filename in the array should wait until exec process is complete before moving on and converting other filename in the array.   </p>
  
  <p>I know i can use <code>scandir($dir)</code> to make an array of all filenames, then maybe use split to only target <code>.flv</code> files. Is this the best way to do it. If i use a while loop to run thru each filename and do an exec on it, how do i make sure exec file is fully converted before moving on to the next file in the array.</p>