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 a delay or proper detection of video streams for auto-toggle #19

Open
gentoo-root opened this issue Dec 4, 2024 · 6 comments
Open

Comments

@gentoo-root
Copy link

Follow-up to timrogers/litra-rs#84 (comment)

Some applications open /dev/video* devices briefly to query something, without even starting the video stream. Known examples:

  1. Chromium does it when opening https://youtube.com/ (Firefox doesn't).
  2. Telegram does it when switching between chats (the reason is unknown yet).
    Telegram opens camera devices /dev/video* every time I open or close a chat telegramdesktop/tdesktop#28733

Litra Glow blinks for a split second every time when that happens.

Therefore, it would be useful if litra-autotoggle could either:

  • delay turning on the camera by 100 ms, or
  • detect whether the actual video stream has started, rather than just detect an opened file
    (not sure that the latter is possible).
@timrogers
Copy link
Owner

I've noticed occasional flickers too, but I hadn't figured out what was causing it 👀

Are you running on Linux or macOS? They have very different backends for detecting camera usage.

@timrogers
Copy link
Owner

There is some interesting code here designed to solve this kind of problem: https://git.math.uzh.ch/thinlinc/tl-webcam/-/blob/B16753_monitor_active_readers/research/inotify-02.py. I think a delay is probably the most sensible way.

@gentoo-root
Copy link
Author

Are you running on Linux or macOS?

Linux.

@timrogers
Copy link
Owner

I'd be open to a PR to add a delay ❤

I might implement it myself over Christmas if I have some time, but it's a bit of a pain to test for me because I use macOS.

@gentoo-root
Copy link
Author

Sure, if I find some time for this, I'll send you a PR, it shouldn't be hard to implement, I just don't know when it happens 😅

@timrogers
Copy link
Owner

I just implemented a fix for a similar problem in macOS, using a delay, in #23. It's probably a good template for your own PR, if you're able to put it together and test it on Linux.

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

No branches or pull requests

2 participants