我正在尝试使用OpenCV3和Python 3计算.mov视频文件中的帧速率和帧总数。我正在使用OpenCV的cv2.CAP_PROP_FRAME_COUNT来获取我的总帧数而我是使用OpenCV的cv2.CAP_PROP_FPS来获取帧速率。问题是我从这些函数中获取的值不准确。我的程序告诉我,我视频中的帧总数是115,帧速率是30 fps。但是,我使用60 fps的iPhone 7录制了视频。所以我的帧速率应该是60,我的总帧数应该是230.当我从以120 fps录制的视频中读取时,我的帧速率也是30 fps。任何人都可以解释为什么我会得到这些价值观吗?
import cv2
video_cap = cv2.VideoCapture('videos/SixtyFPS.mov')
video_cap.set(cv2.CAP_PROP_FPS, 60)
# The following method for counting the total number of frames in the video is
# inaccurate
number_of_frames = int(video_cap.get(cv2.CAP_PROP_FRAME_COUNT))
print("The total number of frames is: " + str(number_of_frames))
# The following methdd for calculating the video's frame rate is inaccurate
fps = int(video_cap.get(cv2.CAP_PROP_FPS))
print("The frame rate is: " + str(fps))