Is it possible to send frames from picamera2 to a queue and then create a file using 10 seconds worth of those frames?

179 views Asked by At

I want to be able to record frames using picamera2 on the pi camera module 3 and send them to a thread message queue. When in this queue i want to join them and when the file reaches 2 minutes long i want to write the file as an mp4.Once the file it is written it will undergo some post processing so preferable to keep it as an mp4 .I am using a raspberry pi camera v3 with a raspberry pi 4B using bookworm and the picamera2 module in python 3.12.0.

The code I have tried is as follows:

camera = Picamera2()
videoConfig = camera.create_video_configuration({"size": 
(1920,1080)})
camera.configure(videoConfig)
encoder = H264Encoder(1000000)
camera.start()
camera.start_encoder(encoder)

def frameCap() -> None:
    while 1:
        cur = camera.capture_buffer()
        queue.put(cur)
    

def frameProcess(recordingTime) -> None:
    while 1:
        if(queue.qsize == 3600):
            queue.get(cur)
            #somehow join the frames
            cur = "Video.mp4"`

I have tried using the circular buffer and fileOutput but with no success. I have looked through the Picamera2 manual but i have not found anything useful on the buffers. I was wondering if someone could point me in the right direction.

0

There are 0 answers