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

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

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

你知道如何处理Vimeo吗?

同样的问题,没有答案。


当前回答

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");

其他回答

如果你想通过纯js/jquery没有api使用缩略图,你可以使用这个工具从视频中捕获一帧,瞧!插入url拇指在任何你喜欢的来源。

这是一支码笔:

http://codepen.io/alphalink/pen/epwZpJ

<img src="https://i.vimeocdn.com/video/531141496_640.jpg"` alt="" />

以下是获取缩略图的网站:

http://video.depone.eu/

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

“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下载文件。

来自Vimeo Simple API文档:

视频请求

为了获得特定视频的数据, 使用以下url: http://vimeo.com/api/v2/video/video_id.output video_id需要信息的视频ID。 指定 输出类型。我们目前提供JSON, PHP和XML格式。

获取这个URL http://vimeo.com/api/v2/video/6271487.xml

    <videos> 
      <video> 
        [skipped]
        <thumbnail_small>http://ts.vimeo.com.s3.amazonaws.com/235/662/23566238_100.jpg</thumbnail_small> 
        <thumbnail_medium>http://ts.vimeo.com.s3.amazonaws.com/235/662/23566238_200.jpg</thumbnail_medium> 
        <thumbnail_large>http://ts.vimeo.com.s3.amazonaws.com/235/662/23566238_640.jpg</thumbnail_large> 
        [skipped]
    </videos>

解析每个视频以获得缩略图

下面是PHP的近似代码

<?php

$imgid = 6271487;

$hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/$imgid.php"));

echo $hash[0]['thumbnail_medium'];  

如果你正在寻找一个替代的解决方案,可以管理vimeo帐户,还有另一种方式,你只需添加每个视频你想显示到一个相册,然后使用API请求相册的详细信息-然后显示所有的缩略图和链接。这不是理想的,但可能有帮助。

API端点(游乐场)

推特与@vimeoapi对话

使用Ruby,你可以做以下事情,比如:

url                      = "http://www.vimeo.com/7592893"
vimeo_video_id           = url.scan(/vimeo.com\/(\d+)\/?/).flatten.to_s               # extract the video id
vimeo_video_json_url     = "http://vimeo.com/api/v2/video/%s.json" % vimeo_video_id   # API call

# Parse the JSON and extract the thumbnail_large url
thumbnail_image_location = JSON.parse(open(vimeo_video_json_url).read).first['thumbnail_large'] rescue nil