3 min read

Raspberry Pi as a cheap UVC (USB) to HDMI adapter

How to use a Raspberry Pi 4 or later to output a USB webcam over the HDMI port of a Pi for use with an Atem mini pro.
Raspberry Pi as a cheap UVC (USB) to HDMI adapter
Photo by Jainath Ponnala / Unsplash

I've bought a insta link360 4k webcam a few years ago and added an Atem mini pro to my collection of tech recently. Now the insta link is a USB webcam. I figured with so many hdmi to usb capture cards and dongles a reverse would also be available. In my search I found the OBSBOT UVC to HDMI adapter, a single purpose device costing €199,-.

I also came across a bunch of old form posts dating back ±7 years to previous and first generations of Raspberry Pi's. Now I had an old Pi3 collecting dust and a Pi4 not doing much either so I thought it was worth a shot.

The Pi3 was just to slow, but with the Pi4 it was a somewhat decent result for 720p and 24fps tops, although it's a stable uvc to hdmi out. I don't know how the Pi5 would perform but that could very well be a higher fps or maybe even a decent 1080p and that would make it a economic competitive solution.

If you want to try it for yourself you can follow along with the steps below, I tried to document it as well as I could.

Step 1: Install the Necessary Tools

First off I started with a clean install of Raspberry Pi OS 64bit Desktop version, loaded on a sd card with Raspberry Pi Imager customized so it had the correct wifi credentials and such.

After that, start by updating your Pi and installing the required software:

sudo apt update
sudo apt install cheese
sudo apt install xdotool
sudo apt install wmctrl

Step 1b: Configure Cheese

Depending on the hardware you're using Cheese needs some setting changed. For my Raspberry Pi 4 I had to set the video resolution to 1280x720.
In Cheese click on the hamburger menu and then go to preferences.

Step 2: Create the Script

Next, create a script that will automate the boot process of Cheese and setting it to your fullscreen webcam.

nano ~/start_cheese.sh

I used the following code, I've added a lot of sleep in between each step because the Rpi4 is at times a bit slow or would throw errors without...

#!/bin/bash
sleep 10  # Wait a bit during boot just to be sure

# Start Cheese
cheese &

# Wait a few seconds to ensure Cheese is fully loaded
sleep 10

# Focus on the Cheese window
wmctrl -a "Cheese"

# Use xdotool to simulate Tab and Enter for video mode navigation
xdotool key Tab
sleep 1

xdotool key Tab
sleep 1

xdotool key Tab
sleep 1

xdotool key Return  # Select video mode
sleep 10

xdotool key F11  # Fullscreen shortcut
sleep 2

xdotool mousemove 1920 1080  # Move mouse off-screen

Save and exit by pressing Ctrl + X.

Then, make the script executable:

chmod +x ~/start_cheese.sh

Step 3: Add the Script to Autostart

To ensure the script runs at startup, add it to the autostart folder:

  1. The autostart folder probably doesn't exist, create it:
mkdir -p ~/.config/autostart
  1. Create the file in the autostart directory:
nano ~/.config/autostart/cheese.desktop
  1. Add the following code to the file:
[Desktop Entry]
Type=Application
Name=Cheese
Exec=/home/pi/start_cheese.sh
X-GNOME-Autostart-enabled=true

Make sure to replace /home/pi/start_cheese.sh with your actual script path if needed, especially if you use a different user than the default 'pi' name.

Step 4: Reboot & Test

Reboot your Raspberry Pi:

sudo reboot

If all is done correctly and with a bit of luck the program Cheese should start after boot, switch over to the video option and go fullscreen.

Conclusion

Is this the ultimate solution? Probably not, but it's worth trying if you have an unused Pi 4 or 5. The Pi 4 struggles a bit with performance, especially at 720p in fullscreen mode. However, it's a cheaper option compared to dedicated adapters like the OBSBOT UVC to HDMI Adapter or the RGBlink TAO, which costs around €199.

Alternatively, creating a webpage to display the webcam feed in kiosk mode -like described here- might be another viable solution to explore but I expect that to have the same performance limitations.

If you have a Pi 5, I'd love to hear your performance results in the comments!