I am trying to record a video in 720p at 60 FPS or 1080p at 30 FPS, However when using the C920 webcam and OpenCV on python I can only get about 10 fps on 720p and 5fps on 1080p.
I have tried a lot different settings for openCV, none change the FPS however of the output.
import cv2
import time
FPS = 0
cap = cv2.VideoCapture(0)
fourcc = cv2.VideoWriter_fourcc(*'MJPG')
if(not cap.isOpened()):
exit()
cap.set(cv2.CAP_PROP_FOURCC, fourcc);
cap.open(cv2.CAP_ANY);
cap.set(cv2.CAP_PROP_CONVERT_RGB, 0);
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
cap.set(cv2.CAP_PROP_FPS, 60)
last = time.time()
for i in range(0,100):
before = time.time()
rval, frame = cap.read()
now = time.time()
print("cap.read() took: " + str(now - before))
if(now - last >= 1):
print(FPS)
last = now
FPS = 0
else:
FPS += 1
cap.release()
I expect it to output 60fps but it only gives 9 or 10 fps