Skip to content
Fragmented Development

Using mpv to view webcam output

I work from home, and my wife commutes. Every day, in the afternoon, I find myself constantly leaning over and parting the shades to check and see if I hear her driving up the driveway, or if I'm just hearing random road noise. It's a silly problem, with an even sillier technical solution.

Every day, when I feel like she's getting close, I drop a USB webcam on my window sill and open up an instance of mpv media player to keep an eye out. This generally works okay, but has some drawbacks - mainly that I will accidentally pause it with media keys, or some other input, and it will cease to be a live feed and turn into a picture. As if I'm heisting something from myself, and hacked my own cameras.

After a couple attempts, I've discovered a way to protect myself from myself:

#!/bin/sh
mpv --input-builtin-bindings=no \
    --input-cursor=no \
    --input-default-bindings=no \
    --input-media-keys=no \
    --load-scripts=no \
    /dev/video0
    # Replace /dev/video0 with whatever video device you want to view

...and, voilà; a highly technical, complicated way to avoid leaning to the left and looking out a real window. You're welcome.

Tags: bash


Add Your Comment