提问人:leakedCrayon 提问时间:11/14/2023 最后编辑:leakedCrayon 更新时间:11/14/2023 访问量:27
是否可以将帧从 picamera2 发送到队列,然后使用这些帧的 10 秒创建一个文件?
Is it possible to send frames from picamera2 to a queue and then create a file using 10 seconds worth of those frames?
问:
我希望能够在 pi camera 模块 3 上使用 picamera2 记录帧,并将它们发送到线程消息队列。当在这个队列中时,我想加入他们,当文件达到 2 分钟长时,我想将文件写成 mp4。一旦文件被写入,它将经过一些后期处理,因此最好将其保留为 mp4 .我正在使用 naspberry pi 相机 v3 和 raspberry pi 4B 使用 bookworm 和 python 3.12.0 中的 picamera2 模块。
我尝试的代码如下:
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"`
我尝试使用循环缓冲区和 fileOutput,但没有成功。我已经浏览了 Picamera2 手册,但我在缓冲区上没有找到任何有用的东西。我想知道是否有人能为我指出正确的方向。
答: 暂无答案
评论