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

Add support RTSP over WebSocket (ex. for Axis cameras) #415

Closed
drott opened this issue May 4, 2023 · 9 comments
Closed

Add support RTSP over WebSocket (ex. for Axis cameras) #415

drott opened this issue May 4, 2023 · 9 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@drott
Copy link

drott commented May 4, 2023

Axis Cameras support a mode where they provide an RTP endpoint / stream over websockets.
Some more info may be found here:
https://github.com/AxisCommunications/media-stream-library-js/tree/main/player

Example endpoint:
ws://{camera host and http port}/rtsp-over-websocket

It would be convenient to be able to extract the stream from there and use it in home assistant without transcoding.

@AlexxIT AlexxIT added the enhancement New feature or request label May 5, 2023
@AlexxIT
Copy link
Owner

AlexxIT commented May 5, 2023

Why is this necessary? Cameras can't handle another protocol?
Can you record the network dump via Wireshark? The first few seconds.

@drott
Copy link
Author

drott commented May 5, 2023

On cameras for which a user does not have admin access and which are firewalled or only have HTTP(S) access, the rtsp stream (that the camera supports) may not be accessible. One alternative is still the MJPEG stream which works but uses higher bandwidth / less efficient encoding / image quality. That's why I would find it useful to access the H264 stream. I'll try to record a dump.

@drott
Copy link
Author

drott commented May 5, 2023

Can you record the network dump via Wireshark? The first few seconds.

I shared a pcap trace with you in email.

@AlexxIT
Copy link
Owner

AlexxIT commented May 6, 2023

You have a difficult situation. This is a WebSocket with Digest authorization. The standard libraries do not support this.
And I can't emulate this behavior somewhere in my own environment.
I need access to the camera. Through port forwarding on router or through a tunnel for the http port:
https://github.com/AlexxIT/go2rtc/wiki/Tunnel-RTSP-camera-to-Intenet

@drott
Copy link
Author

drott commented May 6, 2023

Do you mean you can't emulate the server side of this behaviour for testing?

@AlexxIT
Copy link
Owner

AlexxIT commented May 6, 2023

You can try latest master version.
Your camera has auth for WebSocket and has no auth for RTSP.
My camera (Dahua) has no auth for WebSocket but has auth for RTSP.

streams:
  axis-rtsp-ws:  rtsp://192.168.1.123:4567/axis-media/media.amp?overview=0&camera=1&resolution=1280x720&videoframeskipmode=empty&Axis-Orig-Sw=true#transport=ws://user:pass@192.168.1.123:4567/rtsp-over-websocket
  dahua-rtsp-ws: rtsp://user:pass@192.168.1.123/cam/realmonitor?channel=1&subtype=1&proto=Private3#transport=ws://192.168.1.123/rtspoverwebsocket

@AlexxIT AlexxIT self-assigned this May 6, 2023
@AlexxIT AlexxIT changed the title Feature Request: Support for Axis' RTSP over websocket Add support RTSP over WebSocket (ex. for Axis cameras) May 6, 2023
@drott
Copy link
Author

drott commented May 6, 2023

axis-rtsp-ws: rtsp://192.168.1.123:4567/axis-media/media.amp?overview=0&camera=1&resolution=1280x720&videoframeskipmode=empty&Axis-Orig-Sw=true#transport=ws://user:pass@192.168.1.123:4567/rtsp-over-websocket

🤩🥳 Amazing, thank you so much for adding that so quickly. Great work!

That's working well for me. For now, I am locally mirroring this specific camera using go2rtc master, and then feeding that via an rtsp:// link pointing to localhost to home assistant (while HA doesn't have the latest master yet). Is that the most efficient way to connect the two instances, or how do I best forward?

@AlexxIT
Copy link
Owner

AlexxIT commented May 7, 2023

I don't know why even need to add cameras as an RTSP stream in HA at all.
WebRTC Camera integration can work without it.
Snapshots and record you can also do without it.

@AlexxIT
Copy link
Owner

AlexxIT commented Jul 11, 2023

@AlexxIT AlexxIT closed this as completed Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants