I am currently trying to convert various video files using FFmpeg with the help of my server (Windows Server 2016). PHP is supposed to initiate the process.
Whenever I start FFmpeg via CMD, everything works fine and the video file converts perfectly. But when I trigger the same process with PHP, FFmpeg aborts the conversion after a while and exits by itself.
I neither get an error in the log nor can I recognize system errors from Windows Server. It doesn't matter if I run the command through shell_exec, exec, or system.
For converting I actually use this code:
ffmpeg -loglevel error -i $video -vf scale=1920:1080 -crf 10 -c:v libx264 -preset veryfast -threads 2 $output > NUL 2>&1 < NUL
This is my full php code:
ignore_user_abort(true);
set_time_limit(0);
error_reporting( E_ALL | E_STRICT );
$path = 'C:/inetpub/vhosts/confident-tharp.xx-xx-xxx-xxx.plesk.page/httpdocs';
$ffmpeg = $path . '/ffmpeg/ffmpeg.exe';
$video = $path . '/convert/myoldfile.mp4';
$output = $path . '/convertedfile.mp4';
$dimension = 'scale=1920:1080';
$command = "ffmpeg -loglevel error -i $video -vf scale=1920:1080 -crf 10 -c:v libx264 -preset veryfast -threads 2 $output > NUL 2>&1 < NUL";
shell_exec( $command );
I'm currently using FFmpeg 5, but there was no change with FFmpeg 4 either. The use of other codecs or file formats (e.g. .avi) also has no influence on the behavior of FFmpeg. Previously I tried to use the php-ffmpeg library. Again, I get the same "error".
Hope you guys can help.