So I read throug this article: https://trac.ffmpeg.org/wiki/PHP and found this:
        
You might want to use flush before you do your shell_exec. There are a few caveats to using this which are well explained in the php documentation page. Hope this helps.
/dev/null 2>/dev/null");
  // a sleep could effectively be the same as your shell_exec operation
  // sleep(5);
  echo "Done.\n";
  ob_end_flush();