Get video dimension in python-opencv
<p>I can get size of image, like this:</p>

<pre><code>import cv2

img = cv2.imread('my_image.jpg',0)
height, width = img.shape[:2]
</code></pre>

<p>How about video?</p>

<p>It gives <code>width</code> and <code>height</code> of file or camera as float (so you may have to convert to integer)</p>

<p>But it always gives me <code>0.0 FPS</code>.</p>

<pre><code>import cv2

vcap = cv2.VideoCapture('video.avi') # 0=camera

if vcap.isOpened(): 
    # get vcap property 
    width = vcap.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH)   # float
    height = vcap.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT) # float

    # or
    width = vcap.get(3)  # float
    height = vcap.get(4) # float

    # it gives me 0.0 :/
    fps = vcap.get(cv2.cv.CV_CAP_PROP_FPS)
</code></pre>

<hr>

<p>It seems it can works <code>fps = vcap.get(7)</code> but I checked this only on one file.</p>

python opencv video