Checking Video Quality using WP Code, Forminator and FFmpeg is not working [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 3 hours ago. Improve this question I have a WordPress website where users should be able to upload videos. The quality of the videos should be checked upon upload, meaning the videos must have a 16:9 aspect ratio and be in HD. If a video does not meet these conditions, the upload should not be allowed, and the user should be informed of the reason. I am using the WordPress plugin Forminator for the video upload form and WP Code with a code snippet that contains PHP code. FFmpeg version 4.4.2 is installed on my server. ffmpeg version Form to upload a Video My provider is DreamHost, and I can connect to the server via Terminal on my MacBook and run ffmpeg commands without any issues. I added the form to a page and when I upload invalid videos, unfortunately, I do not receive any error messages, which should be happening according to my code, and I do not know why. Uploading the Video Success Message after uploading the Video Can someone help me? add_filter('forminator_custom_form_submit_before_set_fields', 'forminator_video_validation', 10, 3); function forminator_video_validation($entry, $form_id, $field_data) { foreach ($field_data as $field) { if ($field['name'] === 'upload-1') { // 'upload-1' is the ID of the Datei-Upload-Field in Forminator $file = $field['value']['file']['file_path']; // check if the file exists if (!file_exists($file)) { wp_die('File does not exist'); } // ffmpeg command to check video size and resolution $command = "ffmpeg -i " . escapeshellarg($file) . " 2>&1"; $output = shell_exec($command); // extract resoltion from the ffmpeg output if (preg_match('/Stream #0:0.*Video:.* (\d+)x(\d+)/', $output, $matches)) { $width = (int) $matches[1]; $height = (int) $matches[2]; $aspect_ratio = $width / $height; $allowed_aspect_ratio = 16 / 9; $min_width = 1280; $min_height = 720; // check if the video fullfills the criterias if ($width < $min_width || $height < $min_height || round($aspect_ratio, 2) != round($allowed_aspect_ratio, 2)) { wp_die('The video must be at least in HD (1280x720) and must have the format 16:9. (Found: ' . $width . 'x' . $height . ')'); } } else { // If the video could not be analysed wp_die('The Video could not be analysed'); } } } } PHP Code Snippet in WPCode WPCode Settings

Comment (0)

You’ll be in good company