We are trying to capture frames of video from the Luxonis OAK-1 Lite camera but while we are storing the video it is by default storing those recorded video frames in faster speed so how can we store the video in 25fps below is the code which we are using
import depthai as dai
from datetime import datetime
import cv2
#fourcc = cv2.VideoWriter_fourcc(*"mp4v")
fourcc = cv2.VideoWriter_fourcc('F', 'F', 'V', '1')
firstFrame = 0
full_video = None
def getQRTime():
return datetime.now().strftime('%H_%M_%S')
if name == 'main':
QR_Full_Video_Name = ""
firstFrame = 0
while True:
try:
# Create pipeline
pipeline = dai.Pipeline()
# Define sources and outputs
camRgb = pipeline.create(dai.node.ColorCamera)
camRgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_13_MP)
camRgb.setIspScale(1,4) # 1080P -> 720P
#camRgb.setFps(20)
controlIn = pipeline.create(dai.node.XLinkIn)
ispOut = pipeline.create(dai.node.XLinkOut)
controlIn.setStreamName('control')
ispOut.setStreamName('isp')
# Properties
#camRgb.setVideoSize(640,360)
# Linking
camRgb.isp.link(ispOut.input)
controlIn.out.link(camRgb.inputControl)
device = dai.Device(pipeline)
Video_fps = camRgb.getFps()
print("FPS : ", Video_fps)
# Get data queues
controlQueue = device.getInputQueue('control')
ispQueue = device.getOutputQueue('isp')
while True:
ispFrames = ispQueue.get()
raw_frame = ispFrames.getCvFrame()
if firstFrame == 0:
h, w, _ = raw_frame.shape
#QR_Full_Video_Name = f"GraphicCaptured\\\\{obj.getDate()}\\\\Full Video\\\\QR_Full_Video_{obj.getQRTime()}.mp4"
QR_Full_Video_Name = f"QR_Full_Video_{getQRTime()}.avi"
full_video = cv2.VideoWriter(QR_Full_Video_Name, fourcc, fps=Video_fps, frameSize=(w, h))
firstFrame += 1
full_video.write(raw_frame)
cv2.imshow('QR Detection', raw_frame)
if cv2.waitKey(1) == ord('q'):
full_video.release()
cv2.destroyAllWindows()
break
except Exception as e:
print(e)