php sequential exec() processes not working (ffmpeg encode)
===

I am trying to run a php script from shell that will query a table of videos, check if the encoded version of that video exists, and if not, encode one. I have tested all of the contents of the exec() commands outside of php so I know they work fine. My problem is when the ffmpeg line runs, it finishes but the script quits. I want it to run the next exec() and I don't understand why it won't.

Also to avoid confusion, I am not trying to run these simultaneously, and I don't care about running in the background since this is running from the shell anyway. I just want these 4 commands to execute sequentially and then continue to the next file.

    include 'inc/functions.php';
    
    $result = mysql_query("SELECT * FROM videos") or die(mysql_error());
    
    while ($row = mysql_fetch_array($result)) {
    	if(!file_exists('/opt/lampp/htdocs/videos/'.$row['file_folder'].'/'.$row['file_name'].'.mp4')) {
    		exec('ffmpeg -i "/opt/lampp/htdocs/videos/'.$row['file_folder'].'/'.$row['file_name'].'" -vcodec libx264 -vpre fast -b 512k -acodec libfaac -ab 128k -ac 2 "/opt/lampp/htdocs/videos/'.$row['file_folder'].'/output.mp4"') or die('could not encode movie');
    		exec('/usr/lib/qt-faststart "/opt/lampp/htdocs/videos/'.$row['file_folder'].'/output.mp4" "/opt/lampp/htdocs/videos/'.$row['file_folder'].'/'.$row['file_name'].'.mp4"') or die('could not move mp4 atoms');
    		exec('rm -f "/opt/lampp/htdocs/videos/'.$row['file_folder'].'/output.mp4"') or die('could not delete original encode');
    		exec('ffmpeg -ss 00:00:30.00 -i "/opt/lampp/htdocs/videos/'.$row['file_folder'].'/'.$row['file_name'].'" -y -f image2 -vcodec mjpeg -vframes 1 "'.$row['file_name'].'.jpg"') or die('could not create screenshot');
    	}
    }