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

Streams limited to around 5fps #83

Closed
craggyh opened this issue Sep 3, 2020 · 9 comments
Closed

Streams limited to around 5fps #83

craggyh opened this issue Sep 3, 2020 · 9 comments
Labels
question Further information is requested

Comments

@craggyh
Copy link

craggyh commented Sep 3, 2020

It seems that the cameras imported into Homeassistant are limited to a very low frame rate, around 5fps.
I've played with every setting I can find in the Blueiris backend but nothing seems to change it. Viewing cameras in the BI Windows app or via web browser all show 30fps but not Homeassistant.

Update. I've discovered that the h264 stream doesn't seem to be working and the addon seems to fall back to mjpeg. However, the mjpeg stream is somehow generating about 200Mbps traffic when streaming from BlueIris server.
Not sure what's going on here at all...

@elad-bar
Copy link
Owner

the component is generating the basic camera component, is it working for you better in case you are configuring all the cameras manually?

thanks

@elad-bar elad-bar added the question Further information is requested label Sep 17, 2020
@elad-bar
Copy link
Owner

@craigueh any update?

@lsochanowski
Copy link

i have same issue and i can do some debuging but how to create cameras manualy?

@mjoshd
Copy link

mjoshd commented Feb 14, 2021

@craigueh @lsochanowski,
Hopefully these examples can help get you on the right track for testing manually created cameras.

@elad-bar,
I would be happy to help with discovering the root cause.. I am affected by it as well but should not be. Both BI & HA are running on bare-metal with plenty of horse-power/resources available but the streams created by this integration still display at a very low fps rate compared to the same BI camera via mjpeg stream. Just let me know what info you need.

#####################
# ### Blue Iris mjpeg (plays instantly & smoothly but not compatible with HA Stream service) 
#####################
# - platform: mjpeg 
#   mjpeg_url: "http://{username}:{password}@{bi_address:port}/mjpg/{cam-short-name}/video.mjpg"
#   name: "HA Name"
#####################
- platform: mjpeg 
  mjpeg_url: "http://BiAdminHA:sup3rS3kr3t@192.168.1.23:81/mjpg/dahua/video.mjpg"
  name: "Dahua MJPEG"
#####################
#####################
### Blue Iris m3u8 (compatible with HA Stream service but incurs 10+ sec delay due to HLS streaming) 
#####################
# - platform: ffmpeg 
#   input: "http://{username}:{password}@{bi_address:port}/h264/{cam_short_name}/temp.m3u8"
#   name: "HA Name"
#####################
- platform: ffmpeg 
  input: "http://BiAdminHA:sup3rS3kr3t@192.168.1.23:81/h264/dahua/temp.m3u8"
  name: "name: "Dahua FFMPEG"
#####################
#####################

@elad-bar
Copy link
Owner

Is it working without delay with the ffmpeg component?
I've managed to stream BI to VLC without delay but when integrating the same stream into HA there is huge delay,
I've strong servers for both apps,
CPU of BI is 20% for 16 camera (using GPU that its usage is just 15%),
HA machine load is less than 1 (16 cores),
Network is gigabit...

@mjoshd
Copy link

mjoshd commented Feb 14, 2021

Is it working without delay with the ffmpeg component?
No. As noted in the examples above, in Home Assistant the FFMPEG camera has a huge delay.

I believe this delay on the FFMPEG camera is 100% due to how the 'stream' component of Home Assistant works. It seems to buffer input so you can start a recording from before when motion was detected.. they call it lookback

I do not think that has anything to do with the low fps of the cameras created by this custom_component.

@elad-bar
Copy link
Owner

This custom component just generates generic or mjpeg camera component, i did not implement a camera component by myself, i will check the ffmpeg later this weekend, thanks

@mjoshd
Copy link

mjoshd commented Feb 15, 2021

I would not recommend spending time investigating ffmpeg cameras in HA, there is a huge delay (~10s) due to the stream component and, from what I have found in various threads, it is working 'as designed'.

This custom component just generates generic or mjpeg camera component, i did not implement a camera component by myself

I guess that is where things get strange.

I can open two browsers, right next to each other, and have the camera created by this custom_component and the exact same Blue Iris camera created using yaml, as shown in the examples, and the difference is clear to see.

The camera created by this component plays very choppy at a very low framerate, I'd guess ~1-3 fps, whereas the camera created in yaml plays smoothly, at what I would guess is the full 15 fps as configured in Blue Iris.
.
.
.
.
.
After some digging and tinkering I found out how to make the cameras created by this component play at the full 15 fps as configured in Blue Iris... no more choppy/low-fps playback 😃

Inside config/custom_components/blueiris/camera.py , change line 72

        # from
        self._frame_interval = 1 / device_info[CONF_FRAMERATE]
        # to
        self._frame_interval = 15

then I deleted the integration through the UI, restarted Home Assistant, and re-added the integration through the UI.

I'm not super familiar with python but it looks like that line is setting the frame interval to a fraction of whatever is configured in Blue Iris.
e.g. if, in Blue Iris, a camera is set to 15fps then the original code would set it to 1/15 of 15 which equals 1... and 1fps is pretty much what I observed when viewing the camera feed prior to the change.

I don't know if arbitrarily setting all cameras to 15fps (frame_interval) is a good, or bad, idea... I do know that is what is generally recommended as the sweet-spot for Blue Iris cameras, as noted at ipcamtalk. Perhaps that could be configurable, per-camera, at some point in the future but for now I think arbitrarily setting them to 15 is probably the way to go.

@elad-bar
Copy link
Owner

thanks for the detailed explination, it assisted me to get to the solution.

Before the fix, I set the FPS to 2 hard coded and as result it had just 0.5 seconds interval 1 / 2,
with the fix, H264 streams will get the FPS from the camera settings.

in general, frame interval is the number of seconds between each frame, meaning 15fps = 0.06 seconds, therefore the calculation should remain as is.

please note that Stream component still creates huge delay because of the implmentation of HA for streaming (make sure you are unticking the Stream component in the BI integration's settings)

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants