balena-labs-projects / balena-cam

Network Camera with Raspberry Pi and WebRTC. Tutorial:
https://balena.io/blog/build-a-raspberry-pi-based-network-camera/
MIT License
175 stars 78 forks source link

Error with "VIDIOC_STREAMON: Invalid argument" #91

Closed YosubShin closed 3 years ago

YosubShin commented 3 years ago

When I loaded the balena-cam to Raspberry Pi 4B, the balena-cam service dies and infinitely restarts.

When I ssh'd into the Docker container and tried to execute the Python logic, I could reproduce the same error by importing cv2 and running cv2.VideoCapture(0).read(). The returned values for read() are (False, None).

Following is a snippet of log from the balena-cam service:

21.04.21 19:14:17 (+0900) Restarting service 'balena-cam sha256:b3a28b820130d3f8a12e119100d0746b64bde60221fb1935c182cdf4b189186d'
21.04.21 19:14:18 (+0900)  balena-cam  /usr/local/lib/python3.5/dist-packages/aiortc/rtcdtlstransport.py:12: CryptographyDeprecationWarning: Python 3.5 support will be dropped in the next release of cryptography. Please upgrade your Python.
21.04.21 19:14:18 (+0900)  balena-cam    from cryptography.hazmat.backends import default_backend
21.04.21 19:14:18 (+0900)  balena-cam  Video device is ready
21.04.21 19:14:19 (+0900)  balena-cam  VIDIOC_STREAMON: Invalid argument
21.04.21 19:14:19 (+0900)  balena-cam  Failed to open default camera. Exiting...
21.04.21 19:14:19 (+0900) Service exited 'balena-cam sha256:b3a28b820130d3f8a12e119100d0746b64bde60221fb1935c182cdf4b189186d'
21.04.21 19:14:27 (+0900) Restarting service 'balena-cam sha256:b3a28b820130d3f8a12e119100d0746b64bde60221fb1935c182cdf4b189186d'
YosubShin commented 3 years ago

nvm, I think the issue might have been that my camera was defective. I was able to make it work using a USB camera.