Elgato Camlink and Linux

An Elgato Camlink 4K wouldn’t work under Ubuntu 22.04. It would show up with lsusb, but Cheese wouldn’t list it as a device and OBS studio would show it as a disabled device. A little stream conversion magic [RED]

#!/usr/bin/env bash
# You need to run
# sudo apt install v4l2loopback-utils v4l2loopback-dkms
# once and restart your computer after that so that it reloads the kernel (just in case)

# Creates a dummy device
sudo modprobe v4l2loopback devices=1 exclusive_caps=1

# Find the dummy device file path
V4LOOP=$(v4l2-ctl --list-devices | grep Dummy -A 1 | tail -n 1 | tr -d '\t')
[[ -z "$V4LOOP" ]] && echo "No v4l2 loop device found" && exit 1
echo "Video4Linux loop device is $V4LOOP"

# Find the cam link device file path
ELGATO=$(v4l2-ctl --list-devices | grep 'Cam Link' -A 1 | tail -n 1 | tr -d '\t')
[[ -z "$ELGATO" ]] && echo "No Elgato Camlink device found" && exit 1
echo "Elgato Cam Link loop device is $ELGATO"

# Streams the elgato to the dummy, mapping the correct pixel format
# Don't change the resolution/framerate, the driver will change it back anyway
ffmpeg -f v4l2 -input_format yuyv422 -framerate 60 -video_size 1920x1080 -i $ELGATO -pix_fmt yuyv422 -codec copy -f v4l2 $V4LOOP
 

After that, a new video source will show up as a webcam which can be used in both Cheese and OBS Studio. Note that ffmpeg keep running continuously, if you close the terminal, the video source will break. Surprisingly, after stopping ffmpeg, the Camlink video source suddenly shows up as a regular device and can be used by all programmes.

Update 2024.08.08: WARNING: On my system, an Ubuntu 22.04, this caused the file /var/log/uvcdynctrl-udev.log to grow uncontrollably and take up all space on the file system. Some people have opinions [UVC] about that…

Update 2024.11.24: This post was renamed to “Elgato Camlink and Linux”. Furthermore, supposedly newer kernels work around this issue which seems to be a bug in the Camlink’s firmware, but with Ubuntu 24.04 it still doesn’t work.

Resources

[RED] Did anyone tried an Elgato Cam Link 4K on GNU/Linux?
https://www.reddit.com/r/linuxhardware/comments/dzqmvq/did_anyone_tried_an_elgato_cam_link_4k_on_gnulinux/

[UVC] Filesystem filling up due to large uvcydnctrl-udev.log file
https://askubuntu.com/questions/177312/filesystem-filling-up-due-to-large-uvcydnctrl-udev-log-file

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.