0

I have to get the thumbnail from upload video I downloaded the FFmpeg and I moved into my project folder. I got the code from the internet and I upload the video and echo the result it's saying success but in the folder, the image is not saving or not created. I can't understand what is the issue is, please help to fix this issue.

Code

<?php

$ffmpeg = "../../ffmpeg/bin/ffmpeg";
$myFile1   = $_FILES["video_path"]["tmp_name"];
$imageFile = "../../student_videos/1.jpg";
$size = "120x90";
$getFrameSecond = 20;

echo $cmd = "$ffmpeg -i $myFile1 -an -ss $getFrameSecond -s $size $imageFile";

if(!shell_exec($cmd)){
    echo "success";
}else{
    echo "Error";
}

?>

Result is

http://localhost/nibm/ffmpeg/bin/ffmpeg -i C:\xampp\tmp\php3267.tmp -ss 20 -s 120x90 ../../student_videos/1.jpg

success
Jerad Arul
  • 73
  • 1
  • 9

1 Answers1

0

I try this code it's working...

$ffmpeg = 'C:\\ffmpeg\\bin\\ffmpeg';
$myFile1   = $_FILES["video_path"]["tmp_name"];
$imageFile = 'output.jpeg';
$size = "350x350";
$getFrameSecond = 20;

//$cmd = "$ffmpeg -i $myFile1 -an -ss $getFrameSecond -s $size $imageFile";
$cmd = "{$ffmpeg} -i {$myFile1} -deinterlace -an -ss {$getFrameSecond} -t 00:00:40  -s {$size} -r 1 -y -vcodec mjpeg -f mjpeg {$imageFile} 2>&1";

if(shell_exec($cmd)){
    echo '<img src="http://localhost/nibm/student_videos/output.jpeg">';
    echo "success";
}else{
    echo "Error";
    //echo shell_exec($cmd);
}
Jerad Arul
  • 73
  • 1
  • 9