Outbound Link Summary:
6 days ago
p3k dots

p3k home office cam

aka little sister is watching you…


<img src='https://6dc7e7ac.ngrok.io/' width=160 height=120 title='p3k home office cam'>

This is probably a stupid idea privacy-wise but as I am currently made to work from / stay at home for the time being, I would like to give my colleagues (and also the friends) a way of checking if I am available at the desktop right now.

“Right now” meaning during the last ~3 seconds as the image is not updated that often (by purpose – to at least counter the “stupid idea privacy-wise” a wee bit).

But one thing after another.

I am using the software motion to capture my laptop camera’s image every few seconds. If you are using a Debian-based Linux it should be straight-forward to install it via their package managers.

For macos the docs provide steps how to compile it with the help of brew. Probably not for the faint of heart…

If you are on an unsupported platform you might look out for a different software with similar features (forget about the first three ones in the list, they look like a mistake).

After successfully installing motion you need a configuration file under ~/.motion/motion.conf.

This is the one I am using:

stream_quality 75
stream_maxrate 5
stream_port 8888
stream_localhost on

output_pictures off

framerate 1
minimum_frame_time 3
ffmpeg_video_codec mpeg4

width 160
height 120

auto_brightness off
contrast 0
saturation 0

text_left "Stay inside\nWash your hands\n\n\n\n\n\n\n\n\n\n\n"

Now start motion in your terminal simply by entering motion and return. You should see an output similar to this:

→ motion
[-877287536:motion] [NTC] [ALL] conf_load: Processing thread 0 - config file /home/tobi/.motion/motion.conf
[-877287536:motion] [NTC] [ALL] motion_startup: Using default log level (NTC) (6)
[-877287536:motion] [NTC] [ALL] motion_startup: Motion 4.0 Started
[-877287536:motion] [NTC] [ALL] motion_startup: Logging to syslog
[-877287536:motion] [NTC] [ALL] motion_startup: Using default log type (ALL)
[-877287536:motion] [NTC] [ALL] motion_startup: Using log type (ALL) log level (NTC)
[-877287536:motion] [NTC] [ENC] ffmpeg_init: ffmpeg libavcodec version 57.48.101 libavformat version 57.41.100
[0:motion] [NTC] [ALL] main: Camera 0 is from /home/tobi/.motion/motion.conf
[0:motion] [NTC] [ALL] main: Camera 0 is device: /dev/video0 input -1
[0:motion] [NTC] [ALL] main: Stream port 8888
[0:motion] [NTC] [ALL] main: Waiting for threads to finish, pid: 15509
[1:ml1] [NTC] [ALL] motion_init: Camera 0 started: motion detection Enabled
[1:ml1] [NTC] [VID] vid_v4lx_start: Using videodevice /dev/video0 and input -1
[1:ml1] [NTC] [VID] v4l2_get_capability:
cap.driver: "uvcvideo"
cap.card: "FaceTime HD Camera (Built-in): "
cap.bus_info: "usb-0000:00:1a.0-1.1"
[1:ml1] [NTC] [VID] v4l2_get_capability: - VIDEO_CAPTURE
[1:ml1] [NTC] [VID] v4l2_get_capability: - STREAMING
[1:ml1] [NTC] [VID] v4l2_select_input: name = "Camera 1", type 0x00000002, status 00000000
[1:ml1] [NTC] [VID] v4l2_select_input: - CAMERA
[1:ml1] [WRN] [VID] v4l2_select_input: Device doesn't support VIDIOC_G_STD
[1:ml1] [NTC] [VID] v4l2_set_pix_format: Config palette index 17 (YU12) doesn't work.
[1:ml1] [NTC] [VID] v4l2_set_pix_format: Supported palettes:
[1:ml1] [NTC] [VID] v4l2_set_pix_format: (0) YUYV (YUYV 4:2:2)
[1:ml1] [NTC] [VID] v4l2_set_pix_format: 0 - YUYV 4:2:2 (compressed : 0) (0x56595559)
[1:ml1] [NTC] [VID] v4l2_set_pix_format: (1) MJPG (Motion-JPEG)
[1:ml1] [NTC] [VID] v4l2_set_pix_format: 1 - Motion-JPEG (compressed : 1) (0x47504a4d)
[1:ml1] [NTC] [VID] v4l2_set_pix_format Selected palette YUYV
[1:ml1] [NTC] [VID] v4l2_do_set_pix_format: Testing palette YUYV (160x120)
[1:ml1] [NTC] [VID] v4l2_do_set_pix_format: Using palette YUYV (160x120) bytesperlines 320 sizeimage 38400 colorspace 00000008
[1:ml1] [NTC] [VID] v4l2_scan_controls: found control 0x00980900, "Brightness", range -127,127
[1:ml1] [NTC] [VID] v4l2_scan_controls:         "Brightness", default 0, current 0
[1:ml1] [NTC] [VID] v4l2_scan_controls: found control 0x00980901, "Contrast", range 0,64
[1:ml1] [NTC] [VID] v4l2_scan_controls:         "Contrast", default 32, current 32
[1:ml1] [NTC] [VID] v4l2_scan_controls: found control 0x00980902, "Saturation", range 0,128
[1:ml1] [NTC] [VID] v4l2_scan_controls:         "Saturation", default 64, current 64
[1:ml1] [NTC] [VID] v4l2_scan_controls: found control 0x00980903, "Hue", range -4500,4500
[1:ml1] [NTC] [VID] v4l2_scan_controls:         "Hue", default 0, current 0
[1:ml1] [NTC] [VID] v4l2_scan_controls: found control 0x00980918, "Power Line Frequency", range 0,2
[1:ml1] [NTC] [VID] v4l2_scan_controls:         "Power Line Frequency", default 3, current 1
[1:ml1] [NTC] [VID] v4l2_scan_controls: found control 0x00980910, "Gamma", range 100,220
[1:ml1] [NTC] [VID] v4l2_scan_controls:         "Gamma", default 220, current 220
[1:ml1] [NTC] [VID] vid_v4lx_start: Using V4L2
[1:ml1] [NTC] [ALL] image_ring_resize: Resizing pre_capture buffer to 1 items
[1:ml1] [NTC] [STR] http_bindsock: listening on port 8888
[1:ml1] [NTC] [ALL] motion_init: Started motion-stream server on port 8888 (auth Disabled)

Watch out for error messages. If your camera is not found you need to do some digging and additional configuring using the motion documentation.

If you are lucky like me everything works out of the box and you should be able to open the link localhost:8888 in your browser…

OK. So hopefully now you can see yourself in a browser window showing yourself sitting in front of your computer. Now let others join in the privacy-nightmarish fun.

I assume your computer sits behind a router inaccessible from the outer space of TEH Intarwebs. (If not, I am sure you know what you are doing and you won’t need the next steps.)

Of course generally, that is a good thing! And we certainly don’t want to compromise this setup too much.

That’s why I am using a popular tool called ngrok hoping they know what they are doing or otherwise already would have gone out of business… (fingers crossed.)

If you are still with me just get a free account at ngrok and follow the installation instructions.

There should be only one small change regarding the “fire it up” part. The motion webserver runs on port 8888, so ngrok should be started like this:

./ngrok http 8888

…and if everything works as expected you should see something like this in your terminal:


Furthermore – and that’s what we were striving for – you should now be able to open your webcam page from any computer out there by using the URLs displayed under “Forwarding“ (I recommend using the secure one starting with https).



Some final words about the privacy implications:

  • Be sure you really want to expose yourself in this way in the wide-open World-Wide Web; everyone might be able to see your webcam output, maybe even undesired folks – even if you think you only sent the link to trustworthy and decent human beings.
  • I made the motion configuration quite bad by purpose to counter the privacy issues a little bit: small image, mediocre quality, one frame each 3 seconds. You could still worsen that if you want to.
  • Even if you decide to run motion don’t feel pressured to run it all the time. Turn it off if you feel the need for invisibility. You are still in charge of providing the surveillance – other than all those cameras out there doing it without your control or even consent.
  • Don’t do this if you got a nasty boss.