在我的主页上,我有4个嵌入式视频。为了减少加载时间,我想生成链接到具有真实嵌入视频的其他页面的缩略图。
如何生成这些缩略图?
注意到:
答案 0 :(得分:1)
请注意,来自其他网站的嵌入视频并不会真正减慢加载时间。当嵌入来自YouTube等其他网站的视频时,它通常是闪存,并显示播放器内的缩略图,直到用户点击播放时视频才会加载。我知道,如果你只是想要图片,至少YouTube有可预测的缩略图位置。他们可以在
找到http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
答案 1 :(得分:1)
如果您需要本地视频try this link和this can also help的海报/缩略图,这可以为您提供帮助。这里介绍了如何使用ff-mpeg获取海报图片,大小,长度,视频标题PHP
function captureVideoPosterImg($movie_file = '')
{
extension_loaded('ffmpeg');
$movie_file = 'E:\wamp new\www\projects\indiemade_live\developer\uploads\comments\11\14\video\04072011094613_24062011234404_s Sporting Goods- Teams Come Alive.flv';
// Instantiates the class ffmpeg_movie so we can get the information you want the video
$movie = new ffmpeg_movie($movie_file);
// Get The duration of the video in seconds
echo $Duration = round($movie->getDuration(), 0);
// Get the number of frames of the video
$TotalFrames = $movie->getFrameCount();
// Get the height in pixels Video
$height = $movie->getFrameHeight();
// Get the width of the video in pixels
$width = $movie->getFrameWidth();
//Receiving the frame from the video and saving
// Need to create a GD image ffmpeg-php to work on it
$image = imagecreatetruecolor($width, $height);
// Create an instance of the frame with the class ffmpeg_frame
$Frame = new ffmpeg_frame($image);
// Choose the frame you want to save as jpeg
$thumbnailOf = (int) round($movie->getFrameCount() / 2.5);
// Receives the frame
$frame = $movie->GetFrame($thumbnailOf);
// Convert to a GD image
$image = $frame->toGDImage();
// Save to disk.
//echo $movie_file.'.jpg';
imagejpeg($image, $movie_file.'.jpg', 100);
return $movie_file.'.jpg';
}