Friends, I’m trying to create a thumb of the video “clock.avi”, but is returning the following error message: ‘ffmpeg’ is not recognized as an internal or external command, operable program or batch file.
My script:
<?php
extension_loaded('ffmpeg') or die('Error in loading ffmpeg');
function ExtractThumb($in, $out)
{
$thumb_stdout;
$errors;
$retval = 0;
// Delete the file if it already exists
if (file_exists($out)) { unlink($out); }
// Use ffmpeg to generate a thumbnail from the movie
$cmd = "ffmpeg -itsoffset -4 -i $in -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 $out 2>&1";
exec($cmd, $thumb_stdout, $retval);
// Queue up the error for processing
if ($retval != 0) { $errors[] = "FFMPEG thumbnail generation failed"; }
if (!empty($thumb_stdout))
{
foreach ($thumb_stdout as $line)
{
echo $line . "
\
";
}
}
if (!empty($errors))
{
foreach ($errors as $error)
{
echo $error . "
\
";
}
}
}
ExtractThumb('clock.avi', 'clock.jpg');
?>
The FFMPEG is installed correctly, otherwise return “Error in loading ffmpeg”.
Quoting the file path is how you use spaces. And since you need double quotes to surround the path, your string has to be single quotes (in order to avoid having to escape the double quote characters).
Add the .exe file extension to the file path. The windows binary typically has it. The linux servers with a linux binary do not. However, if this isn’t actually a Windows binary, note that you can’t use a linux binary on windows.
So, assuming that the path to ffmpeg is correct and that the correct binary for the operating system is being used, the command string should be something like this:
‘\“C:/Program Files (x86)/PHP/v5.2/ffmpeg\”’ is not recognized as an internal or external command, operable program or batch file. FFMPEG thumbnail generation failed