Frame Rate Issue

asked 2017-06-01 03:57:14 -0600

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/32...

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()
edit retag flag offensive close merge delete

Comments

there is no way to synchronize the videowriter to your input.

if you gave it a playback rate of 120 fps, it will just do that, irrespective of what happened in your camera loop.

so, if your recorded video is running too fast, most likely you did not get 120fps from your cam originally.

berak gravatar imageberak ( 2017-06-01 04:44:03 -0600 )edit