Ask Your Question

Revision history [back]

Frame Rate Issue

There is a issue I'm facing regarding saving a video. I currently have a camera that can capture up to 120fps. When I recorded a 10s video, the video duration was being cut by half and The video looks like it's being sped up.

The specs of my camera: https://m.aliexpress.com/item-desc/32363729557.html

I have written my code in python as follow:

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

fourcc = cv2.VideoWriter_fourcc(*'MJPG')
out = cv2.VideoWriter('output004.mjpg',fourcc, 120, (640,480))

while(cap.isOpened()):
    ret, frame = cap.read()
    if ret==True:
        frame = cv2.flip(frame,0)
        out.write(frame)
        cv2.imshow('frame',frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    else:
        break

cap.release()
out.release()
cv2.destroyAllWindows()