mainsail-crew / crowsnest

Webcam Service for multiple Cams
GNU General Public License v3.0
302 stars 71 forks source link

Unable to add webcam in Mainsail - RPI 5 and Working ov5647 module #241

Open LadPack opened 4 months ago

LadPack commented 4 months ago

What happened

When attempting to add in a ov5647 camera on mainsail, there is consistently a no-signal when adding via the mainsail UI. Tested the camera module via CLI and was able to receive pictures.

What did you expect to happen

Normally when I have done this in the past (including with this camera module on a Pi4) it would pick up the picam with no intervention on my end.

How to reproduce

Fresh Pi5 install, via KIAUH, plug in camera.

Additional information

[02/08/24 19:18:27] crowsnest: crowsnest - A webcam Service for multiple Cams and Stream Services. [02/08/24 19:18:27] crowsnest: Version: v4.1.3-1-gc0c9c41 [02/08/24 19:18:27] crowsnest: Prepare Startup ... [02/08/24 19:18:27] crowsnest: INFO: Host information: [02/08/24 19:18:27] crowsnest: Host Info: Distribution: Debian GNU/Linux 12 (bookworm) [02/08/24 19:18:27] crowsnest: Host Info: Kernel: Linux 6.1.0-rpi7-rpi-2712 aarch64 [02/08/24 19:18:27] crowsnest: Host Info: Model: Raspberry Pi 5 Model B Rev 1.0 [02/08/24 19:18:27] crowsnest: Host Info: Available CPU Cores: 4 [02/08/24 19:18:27] crowsnest: Host Info: Available Memory: 4143600 kB [02/08/24 19:18:27] crowsnest: Host Info: Diskspace (avail. / total): 18G / 29G [02/08/24 19:18:27] crowsnest: INFO: Checking Dependencies [02/08/24 19:18:27] crowsnest: Dependency: 'crudini' found in /usr/bin/crudini. [02/08/24 19:18:27] crowsnest: Dependency: 'find' found in /usr/bin/find. [02/08/24 19:18:27] crowsnest: Dependency: 'xargs' found in /usr/bin/xargs. [02/08/24 19:18:27] crowsnest: Dependency: 'ustreamer' found in bin/ustreamer/ustreamer. [02/08/24 19:18:27] crowsnest: Version Control: ustreamer new version available: b578e98 (v5.49). [02/08/24 19:18:27] crowsnest: INFO: Print Configfile: '/home/david/printer_data/config/crowsnest.conf' [02/08/24 19:18:27] crowsnest: [crowsnest] [02/08/24 19:18:27] crowsnest: log_path: /home/david/printer_data/logs/crowsnest.log [02/08/24 19:18:27] crowsnest: log_level: verbose [02/08/24 19:18:27] crowsnest: delete_log: true [02/08/24 19:18:27] crowsnest: no_proxy: false [02/08/24 19:18:27] crowsnest:
[02/08/24 19:18:27] crowsnest: [cam 1] [02/08/24 19:18:27] crowsnest: mode: ustreamer [02/08/24 19:18:27] crowsnest:
[02/08/24 19:18:27] crowsnest: enable_rtsp: false [02/08/24 19:18:27] crowsnest: rtsp_port: 8554 [02/08/24 19:18:27] crowsnest: port: 8080 [02/08/24 19:18:27] crowsnest: device: /dev/video0 [02/08/24 19:18:27] crowsnest: resolution: 640x480 [02/08/24 19:18:27] crowsnest: max_fps: 15 [02/08/24 19:18:27] crowsnest: INFO: Detect available Devices [02/08/24 19:18:27] crowsnest: INFO: Found 1 total available Device(s) [02/08/24 19:18:27] crowsnest: ================================================================ [02/08/24 19:18:27] crowsnest: WARN: 'libcamera' devices are currently not supported on Pi 5! [02/08/24 19:18:27] crowsnest: ================================================================ [02/08/24 19:18:27] crowsnest: Detected 'libcamera' device -> /base/axi/pcie@120000/rp1/i2c@80000/ov5647@36 [02/08/24 19:18:27] crowsnest: Try to start configured Cams / Services... [02/08/24 19:18:27] crowsnest: INFO: Configuration of Section [cam 1] looks good. Continue ... [02/08/24 19:18:28] crowsnest: V4L2 Control: No parameters set for [cam 1]. Skipped. [02/08/24 19:18:28] crowsnest: Starting ustreamer with Device /dev/video0 ... [02/08/24 19:18:30] crowsnest: ... Done!

mryel00 commented 4 months ago

Tested the camera module via CLI and was able to receive pictures.

Please elaborate further on this. What exact command did you run? This won't change anything below, I'm just curious.

As you can read on your log snippet, we don't support libcamera devices on the Pi5. Therefore no CSI cam support atm.

If you used the legacy stack to get an image, you have to know that we cannot make it work consistently with the legacy stack on Bookworm. Also that legacy stack will be removed in future versions of Raspberry Pi OS, so it shouldn't be used.

We will add some support in the future but for now we cannot support it.

mryel00 commented 4 months ago

I changed it to a feature request, as we currently don't support it as clearly stated in the log.

LadPack commented 4 months ago

I used libcamera-hello to get a picture file.

Ah got it, so any and all of the pi cameras are no longer supported as of the pi5? Is that more of a Pi5 thing or just because it is new? Is there a workaround potentially to have the pi serve up some sort of ip camera to look at?

I tried camera-streamer which didn't work either for this purpose.

mryel00 commented 4 months ago

It's an overall Pi5 issue atm. We are using camera-streamer as our backend. As that doesn't work with the Pi5, we don't support it. The problem with the Pi5 is the missing JPEG, MJPG and H264 hardware encoders, that's why camera-streamer doesn't support it.

Some kind of workaround/alternative would be spyglass with some adjustments. I might go into detail about it later today. Basically you need to change one of the includes that it's using the software encoder instead of the hardware encoder.

We will add spyglass in an upcoming update, but, like I wrote earlier, that's currently not possible for us.

LadPack commented 4 months ago

So interim, if I have the option to use a pi4, then its probably better to use it? Just for ease of use

mryel00 commented 4 months ago

Exactly a Pi4 would work as expected. It's really just the Pi5 with it's hardware limitations (sounds wrong as it's the newer device but it's actually like that).

To the Spyglass workaround: Only use this for picams/CSI cams on a Pi5! This doesn't have WebRTC support! You need to install some packages for spyglass to work.

sudo apt update
sudo apt install python3-libcamera python3-kms++ python3-picamera2

Then clone the repository and follow the instructions on how to install as a service. To get the best performance, you should change line 11 inside ~/spyglass/spyglass/cli.py from

from picamera2.encoders import MJPEGEncoder

to

from picamera2.encoders import JpegEncoder as MJPEGEncoder

Make sure to comment out the picam/csi cam in crowsnest or stop/disable crowsnest completely. You should also adjust the spyglass.conf (found at the same place as the crowsnest.conf) to the correct streaming and snapshot url.

Like written above someone should only use this for picams/CSI cams. Spyglass only supports one cam at the same time.

I won't give support on this workaround in this issue or in this repository. If you need some help, join our Discord or use the spyglass issue tracker. This should only be treated as a workaround and not as a final solution.

We do not recommend to use a Pi5!

chalb0 commented 9 hours ago

This is a +1 from me with the same issue now.

I only have a pi5 available which is why I'm trying to use it. Would this feature request more accurately be described as using an H.265 codec method for streaming for Pi5's?

FYI Spyglass isn't a workaround for me, as last time I tried it, this wouldn't stream to Obico which is the main reason I use a webcam.

My logs are the same...

LOGS

[07/02/24 23:06:25] crowsnest: INFO: Found 1 total available Device(s) [07/02/24 23:06:25] crowsnest: ================================================================ [07/02/24 23:06:25] crowsnest: WARN: 'libcamera' devices are currently not supported on Pi 5! [07/02/24 23:06:25] crowsnest: ================================================================ [07/02/24 23:06:25] crowsnest: Detected 'libcamera' device -> /base/axi/pcie@120000/rp1/i2c@88000/imx519@1a [07/02/24 23:06:25] crowsnest: Try to start configured Cams / Services... [07/02/24 23:06:26] crowsnest: INFO: Configuration of Section [cam 1] looks good. Continue ... [07/02/24 23:06:26] crowsnest: WARN: Mode 'camera-streamer' is not supported on your device! [07/02/24 23:06:26] crowsnest: WARN: Falling back to Mode 'ustreamer' [07/02/24 23:06:26] crowsnest: V4L2 Control: No parameters set for [cam 1]. Skipped. [07/02/24 23:06:26] crowsnest: Starting ustreamer with Device /base/axi/pcie@120000/rp1/i2c@88000/imx519@1a ... [07/02/24 23:06:28] crowsnest: ... Done! [07/02/24 23:06:28] crowsnest: WATCHDOG: Lost Device: '/base/axi/pcie@120000/rp1/i2c@88000/imx519@1a'

mryel00 commented 1 hour ago

If you read the log, you would understand, why you have the same problem. It's still not supported.

There is no reason why Spyglass shouldn't work with Obico. Crowsnest (ustreamer/camera-streamer) do nothing special compared to Spyglass. (I already wrote, how to get help for Spyglass but it's more like a Obico topic)

Would this feature request more accurately be described as using an H.265 codec method for streaming for Pi5's?

There is no intention from us to use H265 encoding, and we are not aware of any backend that is able to do this easily with the Pi5 encoder, but we didn't really search for it. H265 isn't available in some browsers by default, therefore that's no solution we will consider atm.

Our solution will be Spyglass, as we will add it with the next big version update, that has no current ETA, for multiple reasons.