One approach might be a variation of the dual_encode.py example in https://github.com/raspberrypi/picamera ... _encode.py
A simple version as below encodes the 1fps stream to an mjpeg file while the full 120fps stream is being recorded to an .h264 file.
Seems to cope without dropping any frames from the 'Fast' file, although isn't doing any Wallclock/timestamp capturing.
A simple version as below encodes the 1fps stream to an mjpeg file while the full 120fps stream is being recorded to an .h264 file.
Seems to cope without dropping any frames from the 'Fast' file, although isn't doing any Wallclock/timestamp capturing.
Code:
#!/usr/bin/python3import timefrom picamera2 import Picamera2from picamera2.encoders import H264Encoder, MJPEGEncoderfrom picamera2.outputs import FileOutputduration =30framesize=(1200,900)picam2 = Picamera2()mode=picam2.sensor_modes[0]sensor={'output_size': mode['size'],'bit_depth':mode['bit_depth']}main= {'format' :'YUV420','size': framesize}lores={'format':"YUV420",'size': framesize}config=picam2.create_video_configuration(main,sensor=sensor,lores=lores)picam2.configure(config)picam2.set_controls({"FrameRate":120})fastencoder = H264Encoder(framerate=120,bitrate=10000000)mjpeg_encoder = MJPEGEncoder()mjpeg_encoder.framerate = 1mjpeg_encoder.size = config["lores"]["size"]mjpeg_encoder.format = config["lores"]["format"]mjpeg_encoder.bitrate = 500000mjpeg_encoder.output = FileOutput("Slow.mjpeg")picam2.start()time.sleep(2)picam2.start_encoder(fastencoder, "Fast.h264")mjpeg_encoder.start()start = time.time()while time.time() - start < duration: time.sleep (1) request = picam2.capture_request() mjpeg_encoder.encode("lores", request) request.release()mjpeg_encoder.stop()picam2.stop_recording()Statistics: Posted by sandyol — Sat May 03, 2025 9:31 pm