It does not work because you never perform $cmd. To perform $cmdyou need to either use popen(), proc_open()or exec().
Try this feature. It should generate an image while ffmpeg is available. To make it available, add it to $pathon linux, put it in a folder windows/system32on Windows. Or add it to the environment variables in the control panel in Windows.
/ **
* ExtractThumb, extracts a thumbnail from a video
*
* This function loads a video and extracts an image from a frame 4
* seconds into the clip
* @param $in string the input path to the video being processed
* @param $out string the path where the output image is saved
*/
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 . "
\n";
}
}
if (!empty($errors))
{
foreach ($errors as $error)
{
echo $error . "
\n";
}
}
}
$thumb_stdout - , CLI. , , ffmpeg, , , .
$errors - , CLI (IE, ffmpeg ).