Hello,
I want to record encoded frames in a binary file. Below is the recording snippet. After recording the raw video, I transform the encoded file to .mp4 using ffmpeg.
When I set the camera's framerate at 10FPS all is ok but when I increase, I lose frames. A solution I thought about is to increase callback queues but I don't know how to do it with the SDK. Can you help me or do oy have any idea why I have problems?
Thank you,
François
# Initialize records file
self.videoFileRgb = open('raw_color.bin', 'wb')
self.videoFileLeft = open('raw_left.bin', 'wb')
self.videoFileRight = open('raw_right.bin', 'wb')
self.records_fd = {'rgb': self.videoFileRgb, 'left': self.videoFileLeft, 'right': self.videoFileRight}
# Intilialize, configure and start camera
self.oak = OakCamera()
color = self.oak.create_camera('color', resolution='800p', fps=10, encode=True)
left = self.oak.create_camera('left', resolution='800p', fps=10, encode=True)
right = self.oak.create_camera('right', resolution='800p', fps=10, encode=True)
self.oak.callback(color.out.encoded, callback=lambda x: self.cb_camera(x, 'rgb'))
self.oak.callback(left.out.encoded, callback=lambda x: self.cb_camera(x, 'left'))
self.oak.callback(right.out.encoded, callback=lambda x: self.cb_camera(x, 'right'))
self.oak.start()
# Define calback function (if recording activated, save frame in the coresponding file)
def cb_camera(self, packet: FramePacket, camera_name):
if self.is_recording.value == 1:
fd_camera = self.records_fd[camera_name]
packet.frame.tofile(fd_camera)
# Main loop where "self.is_recording" can be set to record raw frames
while True:
self.oak.poll()