| Server IP : 208.122.213.31 / Your IP : 216.73.216.45 Web Server : Apache System : Linux msd6191.mjhst.com 4.18.0-553.137.1.el8_10.x86_64 #1 SMP Wed Jun 24 11:40:24 UTC 2026 x86_64 User : WHMCS_MIA_382 ( 1001) PHP Version : 7.4.33 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/httpd/html/store.tiacyrusxxx.com/public_html/dev/ffmpeg-php-master/ |
Upload File : |
<?php
$_POST['filename'] = "test/data/test3.mp4";
if (isset($_POST['filename'])) {
$movie_file = filter_var($_POST['filename'], FILTER_SANITIZE_STRING);
require_once 'FFmpegAutoloader.php';
if (!extension_loaded('ffmpeg')) {
exit ('ffmpeg was not loaded');
}
$movie = new ffmpeg_movie($movie_file);
$audio_channels = $movie->getAudioChannels();
$audio_bitrate = $movie->getAudioBitRate();
$original_width = $movie->getFrameWidth();
$original_height = $movie->getFrameHeight();
$thumbnail_width = 293;
$thumbnail_height = 180;
echo "Original Dimensions: " . $original_width . "x" . $original_height . "<br />";
echo "Video Bitrate: " . $movie->getVideoBitRate() . "<br />";
echo "Audio Bitrate: " . $audio_bitrate . "<br />";
echo "Audio Channels: " . $audio_channels . "<br />";
$frameCount = $movie->getFrameCount();
echo "total frames: " . $frameCount . "<br />";
$frameIncrement = floor($frameCount / 9);
echo "frameIncrement: " . $frameIncrement . "<br />";
$frameCounter = 0;
while($frameCounter < 9) {
$proceed = FALSE;
if ($frameCounter == 0) {
$thumbnailOf = 1;
} else {
$thumbnailOf = floor($frameIncrement * $frameCounter);
}
$frameImg = $movie->GetFrame($thumbnailOf);
if (is_object($frameImg)) {
$proceed = TRUE;
} else {
$incrementFrames = 1;
while($incrementFrames < 20) {
$newFrame = $thumbnailOf + $incrementFrames;
$frameImg = $movie->GetFrame($newFrame);
if (is_object($frameImg)) {
$proceed = TRUE;
break;
}
$incrementFrames++;
}
}
if ($proceed) {
$image = $frameImg->toGDImage();
$ratio_orig = $original_width/$original_height;
if ($thumbnail_width/$thumbnail_height > $ratio_orig) {
$new_height = $thumbnail_width/$ratio_orig;
$new_width = $thumbnail_width;
} else {
$new_width = $thumbnail_height*$ratio_orig;
$new_height = $thumbnail_height;
}
$x_mid = $new_width/2;
$y_mid = $new_height/2;
$image_p = imagecreatetruecolor($thumbnail_width, $thumbnail_height);
imagecopyresampled($image_p, $image, 0, 0, ($x_mid-($thumbnail_width/2)), ($y_mid-($thumbnail_height/2)), $thumbnail_width, $thumbnail_height, $original_width, $original_height);
imagejpeg($image_p, 'test/data/test' . $frameCounter . '.jpg', 90);
imagedestroy($image_p);
imagedestroy($image);
echo '<img src="test/data/test' . $frameCounter . '.jpg" style="margin-right: 10px; margin-bottom: 10px;">';
}
$frameCounter++;
}
echo "\r\n" . "Starting ffmpeg..." . "\r\n";
// echo exec("ffmpeg -i " . $movie_file . " -codec:a libvorbis -b:a 128k -codec:v libvpx -b:v 600k test/data/output_medium.webm &");
// echo exec("ffmpeg -i " . $movie_file . " -codec:a libvorbis -b:a 128k -codec:v libvpx -b:v 1200k test/data/output_high.webm &");
// echo shell_exec("ffmpeg -i " . $movie_file . " -codec:a libfaac -b:a 128k -codec:v mpeg4 -b:v 1200k -flags +aic+mv4 test/data/output_high.mp4 &");
// exec('ffmpeg -i ' . $movie_file . ' test/data/output_high1.mp4');
$cmd = 'ffmpeg -i ' . $movie_file . ' -vcodec libx264 -r 29.97 -g 160 -cmp 2 -subcmp 2 -mbd 2 -flags +aic+cbp+mv0+mv4 -trellis 1 -b 700k -acodec aac -strict experimental -ac ' . $audio_channels . ' -ar 44100 -ab ' . $audio_bitrate . ' -y test/data/output_high.mp4 2>&1';
exec($cmd, $output, $value);
echo "<pre>";
var_dump($output);
echo "</pre>";
echo "\r\n" . "Done.";
} else {
echo 'No file selected.';
}