Raspberry Pi Streaming Video Loopback

As part of spiffing my video presence for SquidWrench Zoom meetings, I put a knockoff RPi V1 camera into an Az-El mount, stuck it to a Raspberry Pi, installed the latest OS Formerly Known as Raspbian, did a little setup, and perched it on the I-beam over the workbench:

Raspberry Pi - workbench camera setup
Raspberry Pi – workbench camera setup

The toothbrush head has a convenient pair of neodymium magnets affixing the RPi’s power cable to the beam, thereby preventing the whole lashup from falling off. The Pi, being an old Model B V 1.1, lacks onboard WiFi and requires a USB WiFi dongle. The white button at the lower right of the heatsink properly shuts the OS down and starts it up again.

Zoom can show video only from video devices / cameras attached to the laptop, so the trick is to make video from the RPi look like it’s coming from a local laptop device.

Start by exporting video from the Raspberry Pi:

raspivid --nopreview -t 0 -rot 180 -awb sun --sharpness -50 --flicker 60hz -w 1920 -h 1080 -ae 48 -a 1032 -a 'RPi Cam1 %Y-%m-%d %X'  -b 1000000 -l -o tcp://

The -rot 180 -awb sun --sharpness -50 --flicker 60hz parameters make the picture look better. The bottom of the video image There is no way to predict which side of the video will be on the same side as the cable, if that’s any help figuring out which end is up, and the 6500 K LED tubes apparently fill the shop with “sun”.

The -l parameter causes raspivid to wait until it gets an incoming tcp connection on port 5000 from any other IP address, whereupon it begins capturing video and sending it out.

Then, on the laptop, create a V4L loopback device:

sudo modprobe v4l2loopback devices=1 video_nr=10 exclusive_caps=1 card_label="Workbench"

Zoom will then include a video source identified as “Workbench” in its list of cameras.

Now fetch video from the RPi and ram it into the loopback device:

ffmpeg -f h264 -i tcp:// -f v4l2 -pix_fmt yuv420p /dev/video10

VLC knows it as /dev/video10:

RPi - V4L loopback - screen grab
RPi – V4L loopback – screen grab

That’s the edge of the workbench over there on the left, looking distinctly like a cliff.

The RPi will happily stream video all day long to ffmpeg while you start / stop the display program pulling the bits from the video device. However, killing ffmpeg also kills raspivid, requiring a manual restart of both programs. This isn’t a dealbreaker for my simple needs, but it makes unattended streaming from, say, a yard camera somewhat tricky.

There appear to be an infinite number of variations on this theme, not all of which work, and some of which rest upon an unsteady ziggurat of sketchy / unmaintained software.

Addendum: If you have a couple of RPi cameras, it’s handy to run the matching ssh and ffmpeg sessions in screen / tmux / whatever terminal multiplexer you prefer. I find it easier to flip through those sessions with Ctrl-A N, rather than manage half a dozen tabs in a single terminal window. Your mileage may differ.

10 thoughts on “Raspberry Pi Streaming Video Loopback

  1. You, sir, have achieved Perfect Victory.

    The only question in my mind is “can I throw an instance of all this together before my 2:00pm Zoom call?”

    1. Nothing like a good new problem to take your mind off all your other problems!

      Glad to be of service …

    1. USB connectivity isn’t what I need to scatter cameras all over the shop, alas, although I may need hardwired network connections to some of ’em.

      I keep wanting to like the Zero W, but it’s not wonderful enough to let me ignore a box o’ 3B boards, even the B+ with WiFi, because running several WiFi cameras simultaneously suggests they should use 5 GHz WiFi: there’s just not enough bandwidth for all that TCP traffic at 2.4 GHz. I must add some 5 GHz USB dongles to the mix and see what happens.

Comments are closed.