0

I have a PHP script that use the ffmpeg to compress mov file and convert in mp4.

When I upload a 1gb file, this is converted and in the end appears in console 504 (Gateway Timeout). The instruction I use is this:

$cmd = shell_exec("$ffmpegPath -i $UploadedFilePath -vcodec libx264 -preset ultrafast  -filter:v scale=426:-2 $convertUrl 2>&1");

How can I do? I would like the videos to be reduced considerably while maintaining good quality and without overloading the server. The PHP parameters can be found at this link: https://artruism.me/test.php

UPDATE

The call to the script is with ajaxForm

enfix
  • 6,680
  • 12
  • 55
  • 80
  • 504 happens when the loadbalancer drops the IP connection after it detected no traffic on the wire for X minutes (max LB timeout is 5 minutes). So, if your code is working for 5 minutes straight, and does not make any output, the LB will think "oh, the webserver won't respond" and drops the connection... others are also in need :) – Honk der Hase May 18 '22 at 06:23
  • Ok but what parameters should I increase to prevent it from going into timeout? The PHP parameters can be found at this link: https://artruism.me/test.php – enfix May 18 '22 at 06:48
  • Parameters are irrelevant... the code must not run longer than the timeout or it needs to send data to the client ( heartbeat). If it takes longer than the timeout, don't start it through the web. A cronjob would do... – Honk der Hase May 18 '22 at 06:57
  • The script does not exceed the timeout time. The script ended all the operations. The client gives 504 after the server has finished – enfix May 18 '22 at 06:59
  • then there is another server in the chain of communication, which disconnects... – Honk der Hase May 18 '22 at 07:07
  • There is no other server. This error only gives it for very large files and if I insert the compression with ffmpeg. If I set max_execution_time to 0, the error ERR_NETWORK_IO_SUSPENDED appears. The call to the script is with ajaxForm – enfix May 18 '22 at 07:24

0 Answers0