获取隐藏视频的高度和宽度

get height and width of hidden video

我试过:

video.height // never worked
video.offsetHeight // worked when video was visible, now returning 0

为了只显示处理过的视频,我隐藏了视频元素,如果我以特定的间隔在屏幕上绘制它,下面的代码就可以工作(即使没有隐藏视频),

var video = document.getElementById('someVid');
var canvas = document.getElementById('someCanvas');
var ctx = canvas.getContext('2d');
ctx.drawImage(video, 0, 0, canvas.height, canvas.width);

我需要一些处理的高度和宽度,在绘制之前,所以新的绘制线是:

ctx.drawImage(video, x, y, w, h, 0, 0, canvas.height, canvas.width);

为了计算那个 x,y,w,h 我需要隐藏视频的高度、宽度。

p.s: 不需要IE支持,只需要firefox和chrome.

好的,找到解决方案,

var height = video.videoHeight;
var width =  video.videoWidth;

returns 内在价值...

source