Get OpenCV video properties

C++

//Loading video
cv::VideoCapture video("filename");

//width
int W = video.get(CV_CAP_PROP_FRAME_WIDTH);
//height
int H = video.get(CV_CAP_PROP_FRAME_HEIGHT);
//Total number of frames
int count = video.get(CV_CAP_PROP_FRAME_COUNT);
// fps
double fps = video.get(CV_CAP_PROP_FPS);

Python

#Loading video
video = cv2.VideoCapture("filename")

#width
W = video.get(cv2.CAP_PROP_FRAME_WIDTH)
#height
H = video.get(cv2.CAP_PROP_FRAME_HEIGHT)
#Total number of frames
count = video.get(cv2.CAP_PROP_FRAME_COUNT)
# fps
fps = video.get(cv2.CAP_PROP_FPS)

References

Recommended Posts

Get OpenCV video properties
Loop video loading with opencv
Get image features with OpenCV
Get video file information with ffmpeg-python
Make a video player with PySimpleGUI + OpenCV
Save video frame by frame with Python OpenCV
Video processing using Python + OpenCV on Mac