你可以使用’ffmpeg’.通过使用PHP来调用它.
shell_exec ("ffmpeg -i \"$FILENAME.flv\" -ss 00:00:04 -f image2 \"$FILENAME.jpg\"");
我很遗憾地说我没有测试过,所以先试试吧.
编辑:为了好玩,我把它变成了一个功能.这里是:
function GetThumbnailFileName($FileName, $ScreenShortSecond = 10) {
$VDOLastModifiedDate = filemtime($FileName);
$Thumbnail_FileName = sprintf("%s-(%s::%02d).jpg", $FileName, $VDOLastModifiedDate, $ScreenShortSecond);
if (!file_exists($Thumbnail_FileName)) {
$FFMPEG_Command = sprintf(
"ffmpeg -i \"%s\" -y -ss \"00:00:%02d\" -f image2 \"%s\" > /dev/null 2>&1",
$FileName, 0 + $ScreenShortSecond, $Thumbnail_FileName
);
system($FFMPEG_Command);
}
if (!file_exists($Thumbnail_FileName))
return null;
return $Thumbnail_FileName;
}
$FileName = "Test.flv";
$Thumbnail = GetThumbnailFileName($FileName);
if ($Thumbnail != null)
echo "Thumbnail file is: \"$Thumbnail\"\n";
else echo "Fail creating a Thumbnail of \"$FileName\".";
?>
此功能还会缓存缩略图,并确保在修改VDO时重新创建更新缩略图.
请享用