-
Notifications
You must be signed in to change notification settings - Fork 163
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
"Consumers" fluctuating between 1 and 2, causing stutters #167
Comments
Alright, I found the culprit. As long as Discord is open in the background, it will consume the fake exactly 4 times in an instant, approximately every 3 seconds, which makes the camera stutter. Very weird... Anyone else have the same issue? Any suggestions for a workaround? |
The |
This (#162) would have improved the issue, but it causes the script to crash. |
Right, I was planning to try that. That does indeed solve the problem, but it also causes too much CPU activity to keep this script always running. I guess I'll wrap this up into a script I can run while doing video meeting. Unrelated - I just rebooted my machine, and for some reason I'm now capped to exactly 15 FPS no matter the FPS value I choose. This is the exact same command I was running earlier:
Output:
Before I rebooted, I was getting 30 FPS with fairly low CPU usage. It seems to be capped to 15 FPS for some reason. Any ideas? |
Can you get your Discord to use another webcam? I am a bit busy right now. I don't have time to move inotify to another thread. Why don't you run the benchmark script to see if it is webcam problem? Have a look at #160 It could be lighting or some other issue that causes the real webcam to lock up at 15 FPS. |
That makes a lot of sense, I'll keep that in mind. On an unrelated topic, I made a script to automate setting up the loopback interface and start fake.py: #!/bin/bash
FAKER_PATH="$HOME/src/github/fangfufu/Linux-Fake-Background-Webcam"
# Print an informational status message to the user
function inform() {
if [[ -t 1 ]]; then
echo -e "\e[34;1m ==> $*\e[0m"
else
echo " ==> $*"
fi
}
# Print an error message
function error() {
if [[ -t 1 ]]; then
echo -e "\e[31;1m ==> $*\e[0m" >&2
else
echo " ==> $*" >&2
fi
}
function blurred_cam_video_nr() {
v4l2-ctl --list-devices \
| grep -F -A1 "Blurred background virtual cam" \
| tail -n1 \
| tr -d '[:space:]'
}
function create_loopback_cam() {
sudo modprobe -r v4l2loopback
sudo modprobe v4l2loopback \
devices=1 \
exclusive_caps=1 \
card_label="Blurred background virtual cam"
}
function start_fake_cam() {
local LOOPBACK_DEVICE="$1"
cd "$FAKER_PATH"
exec python3 fake.py \
--no-ondemand \
-W 1920 -H 1080 -F 30 \
--no-background \
--no-foreground \
--background-blur 30 \
-w /dev/video0 \
-v "$LOOPBACK_DEVICE"
}
function check_dependencies() {
local ERROR=no
if ! which v4l2-ctl &>/dev/null; then
error "Missing required command: v4l2-ctl"
ERROR=yes
fi
if [[ ! -d $FAKER_PATH ]]; then
error "Missing Linux-Fake-Background-Webcam checked out at:"
error "$FAKER_PATH"
ERROR=yes
fi
if [[ $ERROR == "yes" ]]; then
error "One or more dependencies missing, exiting"
exit 1
fi
}
function main() {
check_dependencies
local LOOPBACK_VIDEO="$(blurred_cam_video_nr)"
if [[ -z "$LOOPBACK_VIDEO" ]]; then
inform "No V4L2 loopback device found, creating one..."
create_loopback_cam
sleep 0.2
LOOPBACK_VIDEO="$(blurred_cam_video_nr)"
inform "Created V4L2 loopback device on $LOOPBACK_VIDEO"
fi
inform "Starting fake cam on $LOOPBACK_VIDEO"
start_fake_cam "$LOOPBACK_VIDEO"
}
main |
Reopening the issue because it contains an interesting script, I might incorporate it in future 🙂 |
Would just like to add that this was my exact issue as well. Closing Discord solved the problem. Would love to have discord open in the background as well though. |
When not consuming the fake webcam, "Consumers" seems to fluctuate between 0 and 1:
These 8 lines of output are printed approximately every 3 seconds.
When I do consume the webcam, for example via Chrome, the output changes to:
These 8 lines of output are again printed approximately every 3 seconds. Right before they are printed, the fake webcam output freezes for almost half a second. The end result is that every 3 seconds, the webcam stutters.
During those 3 seconds though, I'm getting a completely solid, stable 30 FPS and the camera is looking great!
Since I can't see that anybody else has this problem, I assume there's something weird with my setup. How can I start troubleshooting?
The text was updated successfully, but these errors were encountered: