Camera memory repeated problem

March 28, 2024, 19:17

andersson4003

So when I run a stream function (seen below), my camera starts a stream and all is good. BUT after running it a few times a day and after a couple of days it stops working and I get this error code: mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM) mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1) Traceback (most recent call last): File "/usr/lib/python3/dist-packages/picamera/camera.py", line 456, in _init_camera self._camera = mo.MMALCamera() File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 2279, in init super(MMALCamera, self).init() File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 631, in init mmal_check( File "/usr/lib/python3/dist-packages/picamera/exc.py", line 184, in mmal_check raise PiCameraMMALError(status, prefix) picamera.exc.PiCameraMMALError: Failed to create MMAL component b'vc.ril.camera': Out of memory After allocating more memory to the GPU the script runs as espected again BUT after a few days it happens again! Why is this and how do i fix it? Rebooting does nothing. def main(): StreamProps = ps.StreamProps StreamProps.set_Page(StreamProps,HTML) address = (raspberry_ip, port) StreamProps.set_Mode(StreamProps,'picamera') with picamera.PiCamera(resolution='640x480', framerate=30) as camera: output = ps.StreamOut() StreamProps.set_Output(StreamProps,output) camera.rotation = 0 camera.start_recording(output, format='mjpeg') try: server = ps.Streamer(address, StreamProps) print('Server started at','http://'+address[0]+':'+str(address[1])) server.serve_forever() finally: camera.stop_recording()

andersson4003

full script: import picamera import pyshine as ps # pip3 install pyshine==0.0.9 import os import signal raspberry_ip = ip_of_choice port = 9000 HTML=""" <html> <head> <title>PyShine Live Streaming</title> <style> body, html { height: 100%; margin: 0; display: flex; align-items: center; justify-content: center; background: #000; } img { max-width: 100%; max-height: 100%; } </style> </head> <body> <img src="stream.mjpg" autoplay playsinline> </body> </html> """ def main(): StreamProps = ps.StreamProps StreamProps.set_Page(StreamProps,HTML) address = (raspberry_ip, port) StreamProps.set_Mode(StreamProps,'picamera') with picamera.PiCamera(resolution='640x480', framerate=30) as camera: output = ps.StreamOut() StreamProps.set_Output(StreamProps,output) camera.rotation = 0 camera.start_recording(output, format='mjpeg') try: server = ps.Streamer(address, StreamProps) print('Server started at','http://'+address[0]+':'+str(address[1])) server.serve_forever() finally: camera.stop_recording() kill_process_on_port() def kill_process_on_port(): # Find the process ID (PID) using lsof command = f'lsof -t -i:{port}' pid = os.popen(command).read().strip() if pid: # Kill the process os.kill(int(pid), signal.SIGKILL) print(f'Process on port {port} has been killed.') else: print(f'No process is running on port {port}.') kill_process_on_port() main() error happens at line 38 (with picamera....)

k9t33n

Is it just because it's stored in ram and eventually you ran out?