我想从Vimeo获得视频的缩略图。

当从Youtube上获得图像时,我只是这样做:

http://img.youtube.com/vi/HwP5NG-3e8I/2.jpg

你知道如何处理Vimeo吗?

同样的问题,没有答案。


当前回答

这是一种快速巧妙的方法,也是一种选择自定义大小的方法。

我去这里:

http://vimeo.com/api/v2/video/[VIDEO ID].php

下载文件,打开它,找到640像素宽的缩略图,它的格式如下:

https://i.vimeocdn.com/video/[LONG NUMBER HERE]_640.jpg

你拿这个链接,把640改成——比如——1400,你就会得到这样的东西:

https://i.vimeocdn.com/video/[LONG NUMBER HERE]_1400.jpg

把它粘贴到你的浏览器搜索栏上,享受吧。

欢呼,

其他回答

你可能想看看马特·胡克斯的宝石。https://github.com/matthooks/vimeo

它为api提供了一个简单的vimeo包装器。

所有你需要的是存储video_id(和提供商,如果你也做其他视频网站)

你可以像这样提取vimeo视频id

def 
  get_vimeo_video_id (link)
        vimeo_video_id = nil
        vimeo_regex  = /http:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/
        vimeo_match = vimeo_regex.match(link)


if vimeo_match.nil?
  vimeo_regex  = /http:\/\/player.vimeo.com\/video\/([a-z0-9-]+)/
  vimeo_match = vimeo_regex.match(link)
end

    vimeo_video_id = vimeo_match[2] unless vimeo_match.nil?
    return vimeo_video_id
  end

如果你需要你的试管,你可能会发现这个很有用

def
 get_youtube_video_id (link)
    youtube_video_id = nil
    youtube_regex  = /^(https?:\/\/)?(www\.)?youtu.be\/([A-Za-z0-9._%-]*)(\&\S+)?/
    youtube_match = youtube_regex.match(link)

if youtube_match.nil?
  youtubecom_regex  = /^(https?:\/\/)?(www\.)?youtube.com\/watch\?v=([A-Za-z0-9._%-]*)(\&\S+)?/
  youtube_match = youtubecom_regex.match(link)
end

youtube_video_id = youtube_match[3] unless youtube_match.nil?
return youtube_video_id
end

这里有一个完美的解决方案

   URL Example : https://vumbnail.com/226020936.jpg
   URL method :  https://vumbnail.com/{video_id}.jpg

这对我很有效。

2020的解决方案:

我写了一个使用Vimeo Oembed API的PHP函数。

/**
 * Get Vimeo.com video thumbnail URL
 *
 * Set the referer parameter if your video is domain restricted.
 * 
 * @param  int    $videoid   Video id
 * @param  URL    $referer   Your website domain
 * @return bool/string       Thumbnail URL or false if can't access the video
 */
function get_vimeo_thumbnail_url( $videoid, $referer=null ){

    // if referer set, create context
    $ctx = null;
    if( isset($referer) ){
        $ctxa = array(
            'http' => array(
                'header' => array("Referer: $referer\r\n"),
                'request_fulluri' => true,
            ),
        );
        $ctx = stream_context_create($ctxa);
    }

    $resp = @file_get_contents("https://vimeo.com/api/oembed.json?url=https://vimeo.com/$videoid", False, $ctx);
    $resp = json_decode($resp, true);

return $resp["thumbnail_url"]??false;
}

用法:

echo get_vimeo_thumbnail_url("1084537");

如果您不需要自动解决方案,您可以通过在这里输入vimeo ID: http://video.depone.eu/来找到缩略图URL

事实上,问这个问题的人张贴了他自己的答案。

“Vimeo似乎想让我发出一个HTTP请求,并从他们返回的XML中提取缩略图URL……”

Vimeo API文档在这里:http://vimeo.com/api/docs/simple-api

简而言之,你的应用程序需要像下面这样对一个URL发出GET请求:

http://vimeo.com/api/v2/video/video_id.output

并解析返回的数据以获得所需的缩略图URL,然后在该URL下载文件。