Quantcast
Viewing all articles
Browse latest Browse all 5103

Camera board • Camera Module 3 on RPi Zero 2W Not Recording Video for Specified Time

Hi all,

I record daily from some raspberry pi zero 2ws with camera module 3 and the libcam/picamera2 updated packages. Code below, in python, and called every day at 1pm with crontab.

Code:

#!/usr/bin/python3from picamera2.encoders import H264Encoder, Qualityfrom picamera2 import Picamera2, MappedArrayimport timeimport datetime as dtimport osimport cv2from send2trash import send2trashpicam2 = Picamera2()picam2.configure(picam2.create_video_configuration())#define filename as datestampfile_name = dt.datetime.now().strftime('%m-%d-%Y_piz1.h264')file_path = '/home/pi/'vidname = os.path.join(file_path, file_name)#define timestamp within the videocolour = (0, 255, 0)origin = (0, 30)font = cv2.FONT_HERSHEY_SIMPLEXscale = 1thickness = 2def apply_timestamp(request):        timestamp = time.strftime("%Y-%m-%d %X")        with MappedArray(request, "main") as m:                cv2.putText(m.array, timestamp, origin, font, scale, colour, th>picam2.pre_callback = apply_timestamp#enable encoderencoder = H264Encoder(10000000)picam2.start_recording(encoder, vidname)print('recording')time.sleep(1800) #change this to the length of your videopicam2.stop_recording()print('uploading')os.system('rclone sync /home/pi/*.h264 gdmedia:aggression_development_assay_tes>send2trash(vidname)
My issue is that sometimes, the video will not record for the full 30 minutes and will sort of stall out at any point. I'll still have the hard copy video for whatever length of time that was; sometimes 1 minute, sometimes 20 minutes, but it will not upload with rclone and it won't film for the full time I need it to. The issue is really stumping me, especially as it only occurs on one of my pis (I use 4) and it still occurs after a complete OS reinstall to the latest version of Raspberry OS. The pi isn't running out of storage space either, and my updates are all up to date. Any ideas of how to fix would be appreciated. Thanks all!

Statistics: Posted by moelwe — Sun Apr 28, 2024 12:01 am



Viewing all articles
Browse latest Browse all 5103

Trending Articles