OpenCV获取视频参数(Python/C++)
Python
import cv2
video = cv2.VideoCapture(video_path)
width = int(video.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(video.get(cv2.CAP_PROP_FRAME_HEIGHT))
fps = int(video.get(cv2.CAP_PROP_FPS))
print("Height x Width: {} x {} | FPS: {}".format(height, width, fps))
C++
cv::VideoCapture cap(video_path);
int N_frame = cap.get(cv::CAP_PROP_FRAME_COUNT);
int width = cap.get(cv::CAP_PROP_FRAME_WIDTH);
int height = cap.get(cv::CAP_PROP_FRAME_HEIGHT);
double fps = cap.get(cv::CAP_PROP_FPS);