ffmpeg create video thumbnail php function
by Prakash[ Edit ] 2013-06-29 12:51:42
The following code is a php function which creates a thumbnail of a video using ffmpeg
function createVideoThumbnail($video_filename,$size,$output_name){
$command = "ffmpeg -i '{$video_filename}' -r 1 -ss 00:00:05 {$size} -f image2 '{$output_name}'";
ob_start();
passthru($command);
$content_grabbed = ob_get_contents();
ob_end_clean();
if(!file_exists($output_name)){
return false;
}
return true;
}
Use the function as follows :
$video_filename = 'input.mp4';
$size = '120x72';
$output_name = 'output.jpg';
createVideoThumbnail($video_filename,$size,$output_name);