Skip to content

Instantly share code, notes, and snippets.

@catrielmuller
Last active May 16, 2023 13:38
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save catrielmuller/71ae055871893d289476ee570fd953d8 to your computer and use it in GitHub Desktop.
Save catrielmuller/71ae055871893d289476ee570fd953d8 to your computer and use it in GitHub Desktop.
ArchLinux ElGato FaceCam - Chrome V4L2Loopback

ArchLinux ElGato FaceCam - Chrome V4L2Loopback

IMPORTANT

This is not required any more, you need upgrade your firmware to the version +4.09 using ElGato Cammera Hub

https://help.elgato.com/hc/en-us/articles/4406041241997-Elgato-Facecam-Firmware-Update

Changes in firmware 4.09

  • Added MJPEG as a fallback video format. MJPEG requires less USB bandwidth and improves compatibility with programs that cannot handle uncompressed video.

Loopback Config

I'm creating 3 Loopback devices, if you only need do this for the Facecam you can define only one like this:

options v4l2loopback video_nr=11 card_label="ElGato FaceCam"

WebCam Path

I'm using my serial as a path to not conflict with my another input devices /dev/v4l/by-id/usb-Elgato_Elgato_Facecam_FW42K1A07115-video-index0 on the facecam-init.sh.

You can check what is your correct path with this command:

ls /dev/v4l/by-id/

WebCam Config

On my facecam-init.sh, I set some parameters that make sense for my enviroment, this maybe cannot fit for you, so you can remove this line.

v4l2-ctl -d /dev/v4l/by-id/usb-Elgato_Elgato_Facecam_FW42K1A07115-video-index0 --set-ctrl="brightness=180,contrast=3,saturation=35,white_balance_temperature_auto=1,power_line_frequency=2,sharpness=1,exposure_auto=2,zoom_absolute=5"

or adjust the parameters that you want.

Run

You need start the script to create the pipe from the FaceCam Device to the LoopBack Virtual Device

  • Add execution permissions:
chmod +x facecam-init.sh
  • Run
./facecam-init.sh
#!/bin/bash
v4l2-ctl -d /dev/v4l/by-id/usb-Elgato_Elgato_Facecam_FW42K1A07115-video-index0 --set-ctrl="brightness=180,contrast=3,saturation=35,white_balance_temperature_auto=1,power_line_frequency=2,sharpness=1,exposure_auto=2,zoom_absolute=5"
ffmpeg -f v4l2 -input_format uyvy422 -framerate 60 -video_size 1920x1080 -i /dev/v4l/by-id/usb-Elgato_Elgato_Facecam_FW42K1A07115-video-index0 -pix_fmt yuyv422 -f v4l2 /dev/video11
# /etc/modules-load.d/v4l2loopback.conf
v4l2loopback
# /etc/modprobe.d/v4l2loopback.conf
options v4l2loopback video_nr=10,11,12 card_label="OBS Virtual","ElGato FaceCam","V4L2Loopback" exclusive_caps=1,1,1
@brandon099
Copy link

Thanks for this, it helped immensely, and I now have an excellent working setup!

I added a section before invoking ffmpeg in facecam-init.sh that re-establishes the USB connection to the camera for each script run, as the camera was unreliable, and about 50% of the time, FFMPEG would hang when starting the loopback camera device. So now it works 100% of the time without fail.

Here's what it looks like currently:

# The following lines re-establish the USB connection to the camera
# since occassionally the camera needs to be reconnected for ffmpeg
set -euo pipefail
IFS=$'\n\t'

# Get these values from `lsusb`
VENDOR="0fd9" # Elgato Vendor
PRODUCT="0078" # Facecam ID

for DIR in $(find /sys/bus/usb/devices/ -maxdepth 1 -type l); do
  if [[ -f $DIR/idVendor && -f $DIR/idProduct &&
        $(cat $DIR/idVendor) == $VENDOR && $(cat $DIR/idProduct) == $PRODUCT ]]; then
    echo 0 | sudo tee -a $DIR/authorized > /dev/null
    sleep 0.5
    echo 1 | sudo tee -a $DIR/authorized > /dev/null
  fi
done

@catrielmuller
Copy link
Author

@brandon099 thanks for the improvement. I notice that issue ( not the 50% of the time on my case) however it's a really good to have on the script.
This is an issue with Chrome, basically they don't like the new format. 🤷🏻‍♂️

@fu2re
Copy link

fu2re commented Apr 26, 2022

I have made some improvements as well. Here is the script to start the camera on demand.
Can be enabled as system daemon. The trick is to stream some video to virtual camera all the time
https://github.com/fu2re/LinuxFaceCam/blob/main/facecam.sh

@kouak
Copy link

kouak commented Dec 20, 2022

I believe loopback is not needed anymore with the latest Elgato Facecam firmware (4.09).

Webcamtests.com :
image

chrome://media-internals :
image

@catrielmuller
Copy link
Author

I believe loopback is not needed anymore with the latest Elgato Facecam firmware (4.09).

Webcamtests.com : image

chrome://media-internals : image

I will try to upgrade the firmware right now, Thanks to let us know

@catrielmuller
Copy link
Author

@kouak Confirmed the MJPEG Fallback mode works fine on Linux

@MaximeCheramy
Copy link

Any idea about how to upgrade the firmware if we only have Linux computers? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment