0

I'm new to raspberry and raspberry pi camera. I'm using OpenCV and pi for a project; Using OpenCV and python, I want to get a high resolution video feed to process. On the official web page, it says It supports 1080p30, 720p60

Even without no image processing, only getting feed and writing it with VideoWriter_fourcc I can't get 720p 60fps or 1080p 30fps. It's missing frames.

Here's an example of my basic test code for getting video.

import cv2 as cv
import time
cap = cv.VideoCapture(0)
cap.set(3,1280)
cap.set(4,720)
cap.set(5,60.0)

fourcc = cv.VideoWriter_fourcc(*"MJPG")
out = cv.VideoWriter('output.avi', fourcc, 60.0, (1280,720))

start = int(time.time())
dur = 10
frame_count = 0

while ((int(time.time())-start)<=dur): #While loop that runs for 10 seconds
    ret, frame = cap.read()
    frame_count += 1
    out.write(frame)

cap.release()
out.release()
print(frame_count)

This code should print a value around 600, but it gives 96. I've tried this with 360, 480, 720 and 1080p resolutions, after 480p30fps, It starts to missing frames like this one. And the output video is like fast-forwarding.

I dont know is this the right way to measure frame count but this seemed simple.

How can I improve this the get "high resolution" 1080p30 or 720p60 video modes?

Thanks in advance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.