【问题标题】:Poster image for video embedding用于视频嵌入的海报图像
【发布时间】:2013-12-29 06:23:57
【问题描述】:

在我的主页上,我有 4 个嵌入视频。为了减少加载时间,我想生成链接到具有真实嵌入视频的其他页面的缩略图。

如何生成这些缩略图?

注意:

  • 嵌入式视频来自多个视频共享网站(dailymotion、youtube、vimeo 或例如:this video ...)
  • 网站管理员每天都在动态添加视频,他无法为每个视频手动制作缩略图。

【问题讨论】:

  • 视频分享网站已经为此提供了解决方案。 youtube 示例:google.about.com/od/youtube/ss/embed-share-YouTube-videos.htm
  • 是的,但是嵌入的视频来自几个网站,例如这个视频:letelegramme.fr/fil_region/fil_bretagne/…,它们没有为此提供解决方案。
  • 正如 Dan 所说,缩略图由视频网站提供。如果您尝试为任何视频自动生成缩略图,祝您好​​运。如果你只是想创建一个嵌入机制,你可以看到大多数嵌入的视频都是flash播放器,像这样构建的<div><object><param/><param/>...这可以是一个线索。
  • 好的,我得想办法检索每个视频共享网站的缩略图。

标签: php jquery html video loading


【解决方案1】:

如果您需要本地视频 try this linkthis can also help 的海报/缩略图,这可以为您提供帮助,这里描述了我们如何在 php 中使用 ff-mpeg 获取海报图片、大小、长度、视频的标题

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';
}

【讨论】:

  • 虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接的答案可能会失效。
  • 我已经提供了一些关于页面包含的内容和代码的信息
【解决方案2】:

请注意,来自其他网站的嵌入视频并不会真正减慢加载时间。当嵌入来自其他网站(如 YouTube)的视频时,它通常是 flash,它会在播放器内显示缩略图,并且在用户单击播放之前视频不会加载。如果您只想要图形,我知道至少 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

【讨论】:

  • 感谢您的回复,问题是视频可能来自许多不同的网站,就像我在问题中给出的示例一样。而且他们不提供这些缩略图。
  • 只使用每个站点自己的嵌入缩略图而不是图像有什么问题?
  • 事实上他们确实提供了缩略图。我必须想办法从每个视频共享网站中检索缩略图,这会很麻烦……
  • "...他们不提供那些缩略图..." => "...事实上他们确实提供了缩略图..." 那么?当您嵌入视频时,您不必管理缩略图,提供站点会为您完成。
  • 对于 vimeo - stackoverflow.com/questions/1361149/… ,来自 Dailymotion - stackoverflow.com/questions/13173641/… 。结合上面的 YouTube 链接应该可以为您处理,对吧?
猜你喜欢
  • 2019-07-24
  • 1970-01-01
  • 2015-04-11
  • 2017-10-22
  • 2015-11-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多