Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Live Streams Component #21473
This MVP provides a stream component which enables cameras with a new
The component was written in a way so that video segments are kept in memory, and CPU consumption is very low. Other formats can be added with relative ease in the future, as well as enabling transcoding.
The frontend can access these streams via the WebSocket request, and display them across all major browsers with the help of hls.js. There is also a new service introduced that will call
Related issue (if applicable): home-assistant/architecture#113
Example entry for
@Kane610 - He was making a commit comment on an
Alright, have been doing some local testing. I don't know if it's my Mac/ffmpeg or camera (using UVC G3 Flex), but there is quite some delay.
Also at the end of the stream my Google Home got some bad login attempts. I don't think that we should mark them as bad login attempts.
We should listen to the
The delay is for a couple of reasons, the initial delay is opening the stream and starting the worker thread, then waiting for the first segment to be ready before serving the endpoint. The video delay is due to HLS requiring a buffer of video segments before starting playback. Without that buffer, you would get a "buffering" wheel consistently after every segment.
The delay is dependent on the length of the segments. If you manually open the
HikVision cameras let you set this in the camera options. My cameras are set to 12 FPS with a I Frame interval of 30 frames, which gives me a keyframe every 2.5 seconds, so I get 2.5 second segments. The default HLS provider I have in this PR returns the 3 most recent segments. For me, this means a maximum delay of 8 seconds + load and network latency, so real world delay of 8-10 seconds. If you are seeing a 20s delay, I would imagine your per-segment duration is ~6 seconds. I do not know if that can be configured in UniFi cameras.
What can be changed is this component can make the number of segments to persist and serve configurable, with a default of 3. The user can work backwards from there until their network conditions give them buffering issues to reduce delay.
Near instant opening because the worker was already started. I want to add a "preload" config option that would open and begin processing streams on Home Assistant startup eventually. The question is where to put it. A per-camera config option or global stream config?
I agree here. I silenced them manually in my
Mar 12, 2019
Not a comment on the code but curious if theres still a delay in the stream and what we can do to combat that? I used HLS with nginx from a RTSP stream and found the delay made it useless - would love this feature but not if we're just going to see the same result by different means - I too am using unifi video like @balloob.
Please open an issue if you suspect a bug.
If you want to suggest an enhancement please open a feature request in the Feature Requests section of our community forum.
Merged PRs should not be used for enhancement discussion or bug reports. If you've found a bug it's ok to make a review with inline comments and link to an issue that reports the bug.