I'm trying to use FFMPEG on my website on localhost to take a thumbnail of a video that is being uploaded and save it to a folder on the server but it is not working.
I've tested if this code works by running the code on a video file in the same directory and it works fine but when I tried integrating it into my website it does not work.
<?php
$fileHead=$title."-".$artist;
$output = 'uploadedvidpics/'.$fileHead.'.jpg';
function make_jpg($fileTmpName, $output, $fromdurasec="05") {
global $ffmpegpath;
if(!file_exists($fileTmpName)) return false;
$command = "$ffmpegpath -i $fileTmpName -an -ss 00:00:$fromdurasec -r 1
-vframes 1 -f mjpeg -y $output";
@exec( $command, $ret );
if(!file_exists($output)) return false;
if(filesize($output)==0) return false;
return true;
}
if (make_jpg($fileTmpName, $output)){
#echo 'success';
}else{
array_push($errors,"There was an error creating thumbnail!");
}
?>
I expect the file to take a thumbnail, save it in a directory named uploadedvidpics