ffmpeg create video thumbnail php function

by Prakash 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);
1272
like
0
dislike
0
mail
flag

You must LOGIN to add comments