我想从Vimeo获得视频的缩略图。
当从Youtube上获得图像时,我只是这样做:
http://img.youtube.com/vi/HwP5NG-3e8I/2.jpg
你知道如何处理Vimeo吗?
同样的问题,没有答案。
我想从Vimeo获得视频的缩略图。
当从Youtube上获得图像时,我只是这样做:
http://img.youtube.com/vi/HwP5NG-3e8I/2.jpg
你知道如何处理Vimeo吗?
同样的问题,没有答案。
当前回答
对于那些仍然想要通过URL获取缩略图的人,就像Youtube一样,我构建了一个小应用程序,只使用Vimeo ID获取缩略图。
https://vumbnail.com/358629078.jpg
只要插入你的视频ID,它就会提取视频并缓存28天,所以它的服务速度很快。
下面是一些HTML中的例子:
简单图像示例 <img src="https://vumbnail.com/358629078.jpg" /> < br > < br > 现代响应图像示例 < img srcset = " https://vumbnail.com/358629078_large.jpg 640 w, https://vumbnail.com/358629078_medium.jpg 200 w, https://vumbnail.com/358629078_small.jpg 100 w " 尺寸="(max-width: 640px) 100vw, 640px" src = " https://vumbnail.com/358629078.jpg " />
如果你想自己旋转你可以在这里这样做。
Repo
其他回答
这是一种快速巧妙的方法,也是一种选择自定义大小的方法。
我去这里:
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
把它粘贴到你的浏览器搜索栏上,享受吧。
欢呼,
我创建了一个code depen来为您获取图像。
https://codepen.io/isramv/pen/gOpabXg
HTML
<input type="text" id="vimeoid" placeholder="257314493" value="257314493">
<button id="getVideo">Get Video</button>
<div id="output"></div>
JavaScript:
const videoIdInput = document.getElementById('vimeoid');
const getVideo = document.getElementById('getVideo');
const output = document.getElementById('output');
function getVideoThumbnails(videoid) {
fetch(`https://vimeo.com/api/v2/video/${videoid}.json`)
.then(response => {
return response.text();
})
.then(data => {
const { thumbnail_large, thumbnail_medium, thumbnail_small } = JSON.parse(data)[0];
const small = `<img src="${thumbnail_small}"/>`;
const medium = `<img src="${thumbnail_medium}"/>`;
const large = `<img src="${thumbnail_large}"/>`;
output.innerHTML = small + medium + large;
})
.catch(error => {
console.log(error);
});
}
getVideo.addEventListener('click', e => {
if (!isNaN(videoIdInput.value)) {
getVideoThumbnails(videoIdInput.value);
}
});
如果您不需要自动解决方案,您可以通过在这里输入vimeo ID: http://video.depone.eu/来找到缩略图URL
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");
使用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