Skip to main content

OpenCV - Show Video Properties with python

Hi Guyz,

In this tutorial, I will discuss the video properties and how to view the video properties of any video file using OpenCV. 

A video file contains different types of properties like width, height, frames, etc. Sometimes it is required to take out these basic video details. In order to make this work, easy OpenCV comes with built-in properties to ease out the work for developers.

video = cv.VideoCapture("video.mp4")video.get(0)

OpenCV has a function named get(propId).
Which takes property Identifier as an argument.

There are total 22 property identifiers that OpenCV supports. 

List of Property Identifiers

One can also modify the properties of video file using set function.

This function takes two arguments.

 1. Index
 2. Property Identifier

In case, You want to modify the width and height of the video file.

video.set(3,320) # Width
video.set(4,480) # Height

Program

#import cv2 moduleimport cv2 as cv#This function shows the properties of a video filedef showProperties():    print('Current position - '+str(video.get(0)))    print('Frames POS - '+str(video.get(1)))    print('Ratio - '+str(video.get(2)))    print('Width - '+str(video.get(3)))    print('Height - '+str(video.get(4)))    print('FPS - '+str(video.get(5)))    print('FOURCC - '+str(video.get(6)))    print('Frame Count - '+str(video.get(7)))    print('Format - '+str(video.get(8)))    print('Mode - '+str(video.get(9)))    print('Brightness - '+str(video.get(10)))    print('Contrast - '+str(video.get(11)))    print('Saturation - '+str(video.get(12)))    print('Hue - '+str(video.get(13)))    print('Gain - '+str(video.get(14)))    print('Exposure - '+str(video.get(15)))    print('Convert RGB - '+str(video.get(16)))    print('White Balance U - '+str(video.get(17)))    print('White Balance V - '+str(video.get(18)))    print('Rectification - '+str(video.get(19)))    print('ISO SPEED - '+str(video.get(20)))    print('Buffer Size - '+str(video.get(21)))            while True:    ret,frame = video.read()    cv.imshow('video',frame)    if cv.waitKey(30) & 0xFF == ord('q'):        #Click q key will trigger this function.        showProperties()        breakvideo.release()cv.destroyAllWindows()

Don’t forget to check my other OpenCV Tutorials

Thanks for reading 🙂 🙂

Comments

Popular posts from this blog

Automation - Update Naukri Profile Using Selenium

Recently one of my friend came to me with a problem. He is looking out for new job but he feels quite boring to update  his profile on daily basis. As some people says updating profile in the morning gives you more calls as it keeps the newly updated profile on top (Although i don’t know whether naukri works this way or not 😀 ). As i was more interested to solve his problem.  After listening his problem i came to solution that instead of updating it manually lets make this job automatic. And it is quite interesting how we can automate our daily boring task with automation. Another day i came with the solution . And the solution was to make it automatic using selenium (Those who are not aware about selenium do check this link) In short, Selenium is a Testing automation Framework. And it is for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can (and should) also be automated as well....

OpenCV - Drawing a Circle with python

In this tutorial, I will show you how to draw a circle in OpenCV. OpenCV comes with lots of built-in functions that make our life easier especially when we are working on image processing .  And there is a function called circle in OpenCV which is used to draw a circle. This function takes following parameters: 1. Image : Takes an image object 2. Center : Center point coordinates 3. Radius : Radius of the circle 4. Color : Takes color in BGR format 5. Thickness : By default set to 1 (optional) 6. Line Type : By default set to 8-connected.It can also be  LINE_AA  or  4-connected  (Optional) 7. Shift:  Shifts fractional bits in the point coordinates of center and radius (Optional) Especially when we are creating closed shapes. Thickness plays an important role. Here if the negative thickness is passed in this function or any other function which creates a closed shape(rectangle, polygon, etc). Then it creates a filled shape (filled with color). Negative Thickness Filled Circle Positive ...

Basic BIOS password crack

This is a password hack but it clears the BIOS such that the next time you start the PC, the CMOS does not ask for any password. Now if you are able to bring the DOS prompt up, then you will be able to change the BIOS setting to the default. To clear the CMOS do the following: Get DOS prompt and type: DEBUG hit enter -o 70 2e hit enter -o 71 ff hit enter -q hit enter exit hit enter Restart the computer