Thanks, interesting.Actually another amusing way to split a video recording is to use the "SplittableOutput", which lets you create a seamless collection of files with no gaps at all between them. Example here. But we seem to be wandering a bit off-topic...!Sandyols code with 3 minute splits...
...
Code:
#!/usr/bin/python3import timefrom picamera2 import Picamera2from picamera2.encoders import H264Encoderfrom picamera2.outputs import PyavOutput, SplittableOutputimport datetimepicam2 = Picamera2()config = picam2.create_video_configuration()picam2.configure(config)encoder = H264Encoder(bitrate=5000000)video_length = 180 # in secondsnow = datetime.datetime.now()timestamp = now.strftime("%y%m%d%H%M%S")splitter = SplittableOutput(output=PyavOutput(timestamp + ".mp4"))# Start writing initially to one file, and then we'll switch seamlessly to another.# You can omit the initial output, and use split_output later to start the first output.picam2.start_recording(encoder, splitter)time.sleep(video_length) # 3 minuteswhile True: # This returns only when the split has happened and the first file has been closed. # The second file is guaranteed to continue at an I frame with no frame drops. print("Waiting for switchover...") now = datetime.datetime.now() timestamp = now.strftime("%y%m%d%H%M%S") splitter.split_output(PyavOutput(timestamp + ".mp4")) print("Switched to new output!") time.sleep(video_length) Statistics: Posted by gordon77 — Wed Nov 26, 2025 10:39 am