Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebRTC/RTSP camera support (crowsnest) #225

Open
spikeygg opened this issue Nov 20, 2023 · 9 comments
Open

WebRTC/RTSP camera support (crowsnest) #225

spikeygg opened this issue Nov 20, 2023 · 9 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@spikeygg
Copy link

I've recently learned about crowsnest (https://github.com/mainsail-crew/crowsnest) which supports alternative methods for serving up the cameras attached to a printer. It allows for webrtc cameras via camera-streamer. After upgrading my printer to use this package I noticed that the camera entities from the moonraker integration in Home Assistant no longer worked correctly - broken icon instead of the camera's image.

I swapped my configuration back to using ustreamer with the /webcam/?action=stream URL and deleted and reloaded the integration for moonraker and that made the camera entities work again.

The URL can be several different variations based on the source. The default for webcamd works in crowsnest if you don't change away from ustream:

####    Port 8080 equals /webcam/?action=[stream/snapshot]      #####
####    Port 8081 equals /webcam2/?action=[stream/snapshot]     #####
####    Port 8082 equals /webcam3/?action=[stream/snapshot]     #####
####    Port 8083 equals /webcam4/?action=[stream/snapshot]     #####

but you can also use camera-streamer and enable rtsp. The URLs are:
/webcam/webrtc for the camera-streamer
#### rtsp://<ip>:<rtsp_port>/stream.h264 #####

Describe your setup

I have a Voron 2.4 with Klipper, Moonraker, Fluidd and Mainsail running from a Raspberry Pi 4 and Octopus controller.

Describe the solution you'd like

Ideally, the camera entities served into Home Assistant would support all technologies served by the software.

@marcolivierarsenault marcolivierarsenault added the enhancement New feature or request label Nov 25, 2023
@WayneManion
Copy link

WayneManion commented Dec 4, 2023

I don't use Crowsnest. I have PoE IP cameras connected over Ethernet to keep an eye on my printers. I have the camera details set up in moonraker.conf. The camera is automatically populated in the fluidd UI when I visit any of my printers via fluidd, but the camera does not work in Home Assistant.

The [webcam] section in one of my printers' moonraker.conf looks like this (the printer is named Kevin):

[webcam kevinRakerCam]
location: outside
enabled: True
service: hlsstream
target_fps: 15
target_fps_idle: 5
stream_url: http://[NUMERIC_IP_ADDR]:8083/stream/kevin/channel/0/hlsll/live/index.m3u8
snapshot_url: http://[NUMERIC_IP_ADDR]:8083/stream/kevin/channel/0/hlsll/live/index.m3u8
flip_horizontal: False
flip_vertical: False
rotation: 0
aspect_ratio: 16:9

I have the cameras piped into RTSP2WebRTC running on another Linux box and then I stream them from there in Moonraker. Right now I use the Generic camera integration to 'catch' the feed from RTSP2WebRTC, but it would be cool if if the Home Assistant integration could 'figure out' that my camera stream is not MJPEG and just automatically work.

@marcolivierarsenault marcolivierarsenault added the help wanted Extra attention is needed label Dec 5, 2023
@marcolivierarsenault
Copy link
Owner

This is a good idea, but it's really tricky for us to implement since we don't have this hardware.

that being said if someone would implement it, we will happily merge that into the integration

@Codel1417
Copy link

There are multiple options. https://github.com/ayufan/camera-streamer/blob/main/docs/streaming.md

I had success with the /video endpoint but there is a delay. Using the RTSP url would return connection timed out in home assistant

@WayneManion
Copy link

This is a good idea, but it's really tricky for us to implement since we don't have this hardware.

that being said if someone would implement it, we will happily merge that into the integration

I don't think one would necessarily have to have this hardware to be able to implement this feature. I could very well be wrong, I'm not a Python expert.

class MoonrakerCamera(MjpegCamera):
It appears that the Moonraker integration currently assumes all video cameras are MJPEG, which is not necessarily true.

One could test by transcoding an MJPEG camer into another format supported by Moonraker/Fluidd/Mainsail (HLS, WebRTC, etc).

@Codel1417
Copy link

If it assumes mjpeg, Camera-Streamer has a mjpeg stream
http://:8080/stream

@WayneManion
Copy link

The Creality camera for my K1 finally arrived. The integrated camera in my K1 works automatically in the HA integration, but the IP camera that is defined in my moonraker.conf file does not work in the integration.

I believe this is supporting evidence to the notion that the HA integration assumes all cameras defined in moonraker.conf are mjpeg cameras.

@marcolivierarsenault
Copy link
Owner

The integration only supports mjpeg cameras

@TheManoeuvre
Copy link

Im using a Creality K1, rooted and the camera is set up and working in Fluidd in the UI as mjpeg adaptive however the HA integration shows it as a camera but it consistently idle. Do these need to be in the moonraker.conf file to work?

@EyalRotem
Copy link

I saw the last update added a way to configure camera links, any info about how to use it and in which cases? does it support webrtc/rtsp?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants