I'm running Rasbian os + PHP 7.3 on Nginx and I'm facing a problem when uploading and generating a thumbnail of a video file. I have FFMpeg on my OS, I chmod 777 the folders, I even visudo and added permition to www-data /usr/local/bin/ffmpeg and /usr/local/bin/ffprobe but nothing works.
ini_set('display_errors', 'On'); error_reporting(E_ALL);
require_once '../../vendor/autoload.php' ;
if($_FILES["upload_file"]["name"] != '')
{
$data = explode(".", $_FILES["upload_file"]["name"]);
$extension = $data[1];
$allowed_extension = array("mp4");
if(in_array($extension, $allowed_extension))
{
$name_only = pathinfo($_FILES["upload_file"]['name'], PATHINFO_FILENAME) ; // Main Name Only
$new_video_name = $name_only.'.mp4';
$new_img_name = $name_only.'.jpg';
$path = $_POST["hidden_folder_name"] .'/'. $new_video_name;
$img_path = $_POST["hidden_folder_name"] .'/'.$new_img_name ;
if(move_uploaded_file($_FILES["upload_file"]["tmp_name"], $path))
{
$ffmpeg = FFMpeg\FFMpeg::create();
'ffmpeg.binaries' => '/usr/local/bin/ffmpeg',
'ffprobe.binaries' => '/usr/local/bin/ffprobe',
'timeout' => 3600,
'ffmpeg.threads' => 12,
'temporary_directory' => '/var/ffmpeg-tmp'
$video = $ffmpeg->open($path);
$video->filters()->resize(new FFMpeg\Coordinate\Dimension(320, 180))->synchronize();
$video->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(2))->save($img_path);
echo 'FILE UPLOADED';
}
else
{
echo 'THERE IS AN ERROR';
}
}
else
{
echo 'INVALID FILE';
}
}
else
{
echo 'PLEASE SELECT FILE';
}