I am using this camera: https://a.co/d/eq1SfY9 and want to record a video at 2 fps and start a motor the moment it starts recording. I have the code for the video but I've noticed that trying the camera starts recording about four seconds after the motor starts. This is the code I used to verify that. When I run that code, the video ends up being around 6-7 seconds long. Is there any way to wait until the camera is recording to run the motor? I mean something along the lines of this:
So that the motor runs for 10 seconds and the video is also exactly 10 seconds. Thanks.
Code:
#!.venv/bin/python3from picamera2.encoders import JpegEncoderfrom picamera2 import Picamera2from picamera2.outputs import FfmpegOutputimport timepicam2 = Picamera2()config = picam2.create_video_configuration(main={"size": (640, 480)}, lores={"size": (320,240)}, encode="main", controls={"FrameRate": 2})picam2.align_configuration(config)picam2.configure(config)output = FfmpegOutput("test.mp4")encoder = JpegEncoder(colour_subsampling="Gray")picam2.start_recording(encoder, output)#code to start motortime.sleep(10)#code to stop motorpicam2.stop_recording()
Code:
picam2.start_recording(encoder, output)#wait for recording to start#code to start motortime.sleep(10)#code to stop motorpicam2.stop_recording()
Statistics: Posted by carterc — Mon Dec 30, 2024 9:15 pm — Replies 0 — Views 14