Reduce the "check signal" interval when no signal detected, or provide users to set interval.

  • Just got into Hyperion and it's great. Very easy to use.


    I've put this in feature requests as I believe it's working as intended but I'm seeing high CPU usage (RPI3) even when Hyperion correctly identifies "no signal".

    This is idle/suspended. (no Signal)


    This is active/processing LED's. (signal detected)


    It took some tweaking to identify no signal as my capture card outputs a black screen, but after setting them up it's for sure working fine.


    Code
    2024-02-05T13:03:12.479Z [V4L2] (INFO) Signal detected
    2024-02-05T13:03:12.482Z [LEDDEVICE|Hue Lights] (INFO) Switching device philipshue ON
    2024-02-05T13:04:39.151Z [V4L2] (INFO) Signal lost
    2024-02-05T13:04:40.070Z [LEDDEVICE|Hue Lights] (INFO) Switching device philipshue OFF

    What I think is happening, and I may be wrong, is that Hyperion is still polling the black screen at the same rate it's configured to capture at. So 30fps. The slightly lower CPU usage is probably just because there are less changes to process. Would it better to save CPU resources and poll slower when a no signal state is detected? Even once a second would probably be acceptable for most users. In fact for me, my Firestick takes 10-15 seconds to boot up so every 5 seconds would be fine.


    If I'm wrong then I can post in support. It's no major issue, I was going to use a GPIO pin to trigger start/stop the service, and I can see new update has integrated OS event support so probably something I can use in there.


    Alternatively, if the above is true but the CPU usage is unavoidable as it's locked to the capture settings (1024x768 MJPG 30FPS) then perhaps an option to switch to a lower capture when detecting no signal? 640x480 YUYV 5FPS is a much more respectable 3-4% CPU usage and Hyperion is able to detect signal. Once it detects, switch back to the higher quality user configured settings.

    Edited once, last by AMJ: Merged a post created by AMJ into this post. ().

    • Official Post

    640x480 MJPG 30 FPS Size decimation 6

    Hyperion does not require a high resolution, minimum one pixel per LED, and the CPU load is reduced.


    Have you looked at hyperion-remote or the control options via the Json API

    hyperion-remote --help

    JSON RPC Introduction | Hyperion


    regards pclin

  • I was just testing really, and something I noticed. Using the above reduces loaded CPU to about 25% and idle to around 13-14%, which is in improvement, but can't help think that it's just wasted resources when it seems to be just watching a black screen for activity. It would be more of a problem, say, if I was using my Pi Zero (all my Pi's are multipurpose so on all the time/servicing other tasks & apps) as it's got much more limited CPU resources.


    If there's no appetite to change this (or if I'm wrong entirely) then that's fine. That command line utility looks useful, if the idle CPU usage bothers me in the future I'll throw something together that disables it through a GPIO pin.

    • Official Post

    AMJ As you rightly assumed, the capturing is not throttled currently when a black screen was detected.

    That would be a new feature.


    With 2.0.16 you can also use your Remote and put Hyperion into Suspend mode.

    Just enable CEC events.

    Might be easier and out of the box than a GPIO solution.

  • Quote

    AMJ As you rightly assumed, the capturing is not throttled currently when a black screen was detected.

    That would be a new feature.


    Thanks for the confirmation/clarification. I believe it's a valid request for new feature then, though seeing as no one else has requested it then it doesn't seem like it'd be very important.


    Quote

    With 2.0.16 you can also use your Remote and put Hyperion into Suspend mode.

    Just enable CEC events.

    Might be easier and out of the box than a GPIO solution.


    Thanks. I'll look into the remote CLI in more detail and will probably be handy for what I am thinking of doing. I'm a special case due to my setup which is why I'm thinking using a GPIO pin to turn on/off Hyperion when going high/low. CEC is a no (my HDMI splitter doesn't support it) and all my entertainment devices share the same 5v supply, some which come on/off with the TV (Via the TV's USB power & a couple of relays) so it's a ready made source for an on/off trigger.

  • Hi,


    how about that:



    Drops CPU usage from 40% to 3% if no signal detected.


    wbr

    • Official Post

    Thinner It is a good idea to reduce processing, if the non-signal scenario has been detected.

    Would it not even better to stop reading from Grabber with current fps, but change to a "no-Signal" frequency?

    i.e. not read with 25 fps but read e.g. one frame every 30 seconds and test, if there is now a signal...

    That would further reduce unnecessary processing....

    Here the "read/streaming" frequency is set:
    https://github.com/hyperion-pr…v4l2/V4L2Grabber.cpp#L627

    I do not know, if that can be easily switched on the fly when the non-signal scenario is identified.
    Not sure if a numerator = 30 and denominator = 1 would work....

    Maybe worth a try....

  • Hi Lord-Grey,


    i've tried setting some hardcoded values to numerator/denominator, but it looks like one can only set FPS that are supported by the V4L2 device drivers for the given resolution and pixelformat.


    See output of v4l2-ctl -d /dev/videoX --list-formats-ext


    For my webcam i can't go lower than 15 FPS because that's the minimum FPS supported.


    wbr


    PS:

    For my internal laptop webcam:

    v4l2-ctl -d /dev/video0 --set-parm 2

    -> Frame rate set to 15.000 fps

    = no chance to set lower values than supported



    For Raspberry Pi Camera v2.1:

    v4l2-ctl -d /dev/video1 --set-parm 2

    -> Frame rate set to 2.000 fps

    = works if supported


    Edited once, last by Thinner ().

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!