Im using uv4l to stream from my raspberry pi, and it works perfectly but if i wanna use a python script to record while streaming i'm getting this error:
mmal: mmal_vc_port_enable: failed to enable port vc.null_sink:in:0(OPQV): ENOSPC
mmal: mmal_port_enable: failed to enable connected port (vc.null_sink:in:0(OPQV))0x24a6300 (ENOSPC)
mmal: mmal_connection_enable: output port couldn't be enabled
Traceback (most recent call last):
File "app.py", line 3, in <module>
camera = picamera.PiCamera()
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 433, in __init__
self._init_preview()
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 513, in _init_preview
self, self._camera.outputs[self.CAMERA_PREVIEW_PORT])
File "/usr/lib/python3/dist-packages/picamera/renderers.py", line 558, in __init__
self.renderer.inputs[0].connect(source).enable()
File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 2212, in enable
prefix="Failed to enable connection")
File "/usr/lib/python3/dist-packages/picamera/exc.py", line 184, in mmal_check
raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Failed to enable connection: Out of resources
My guess is that two process can't use the same resource in this case the camera, so that leave me with the question: is there a way to do this with python? the thing i'm building a security system and using python and i'm trying to record video when you detect a person but i should be able to still stream the video while the system is recording it.
this is my code for recording video right now that i'm testing
import picamera
with picamera.PiCamera() as camera:
camera.resolution = (640, 480)
camera.start_recording('my_video.h264')
camera.wait_recording(6)
camera.stop_recording()
as you can see is a simple recording method to run on python3 i need to at least fetch the streaming and save it. But it seems imposible the most close i've found on internet is how to take a screenshot with an opencv code but not saving video.