0

I'm using Windows Server 2016

This is the PHP code I use:

exec('"' . $ffmpeg . '" -y -i "' . $inputFile . '" -vcodec copy -acodec copy -ss 00:00:00 -to ' . $till . ' "' . $temp . '" 2>&1', $output, $return_var);

It works but after that I get 500 Internal Server Error which lasts about 2 - 3 seconds.

I tried to change 2>&1 to > /dev/null 2>&1 & based on this answer so:

exec('"' . $ffmpeg . '" -y -i "' . $inputFile . '" -vcodec copy -acodec copy -ss 00:00:00 -to ' . $till . ' "' . $temp . '" > /dev/null 2>&1 &', $output, $return_var);

but now the conversion doesn't work any more.

EDIT:

I should add that the 500 Internal Server Error doesn't happen when I run the script but when I open the website within 2 - 3 seconds after conversion

  • Can you echo the complete exec string? Maybe someone can find in error in user ffmpeg? – Marco Mar 22 '22 at 09:16
  • You mean echo $output? Because echo exec('"' . $ffmpeg . '" -y -i input.mp4 -vcodec copy -acodec copy -ss 00:00:00 -to ' . $till . ' finish.mp4 > /dev/null &', $output, $return_var); doesn't show anything –  Mar 22 '22 at 09:37
  • @Marco but echo the old way: echo exec('"' . $ffmpeg . '" -y -i input.mp4 -vcodec copy -acodec copy -ss 00:00:00 -to ' . $till . ' finish.mp4 2>&1', $output, $return_var); shows: video:77kB audio:178kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 7.572839% –  Mar 22 '22 at 09:40
  • hmm... It seems to run, but are you quite sure, that the internal server error occurs within the exec? – Marco Mar 22 '22 at 10:00
  • Yes, I'm testing it by only having this in a PHP file @Marco –  Mar 22 '22 at 10:29
  • The linked post indicate that your issue is php timing out while waiting for ffmpeg to finish the job. The OP fixed it by "execut[ing] the php script using the php-cli command with a scheduled cron job" (however way it is as I don't know php) – kesh Mar 22 '22 at 14:25
  • Hmm I can't imagine it having anything to do with timing out since the conversion only takes 2 seconds max @kesh –  Mar 22 '22 at 18:50

0 Answers0