I am trying to use this script to create thumbnail of a video using ffmpeg. At first I used phpinfo();
and I found ffmpeg is installed on my se
Looked over the code, made it simpler and runnable, maybe this helps some of you.
class VideoTile
{
public static function createMovieThumb($srcFile, $destFile = "test.jpg")
{
// Change the path according to your server.
$ffmpeg_path = 'D:\\ffmpeg\\bin\\';
$output = array();
$cmd = sprintf('%sffmpeg -i %s -an -ss 00:00:05 -r 1 -vframes 1 -y %s',
$ffmpeg_path, $srcFile, $destFile);
if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN'))
$cmd = str_replace('/', DIRECTORY_SEPARATOR, $cmd);
else
$cmd = str_replace('\\', DIRECTORY_SEPARATOR, $cmd);
exec($cmd, $output, $retval);
if ($retval)
return false;
return $destFile;
}
}
Usage is
$file = VideoTile::createMovieThumb("../video3.mp4");