Glitch Webcam

Glitch Webcam* is a small script that was developed during my time at Databit.me as part of the Open Camera project, which aimed at finding inexpensive ways to take images. Since then it has been in the MEMIC exhibition in November 2012 and usually makes an appearance wherever my laptop goes.

At only five lines of code and ~254 bytes, this script is a very quick way to glitch photos taken automatically by a webcam. The project was originally demoed using a Raspberry Pi/Raspbian and a digital photo frame, though problems with USB have prevented me from doing that since.

Below is the script, which requires you to have installed Streamer, feh (1.3.4 used), sed and xdotools:

[sourcecode language=”bash”]#!/bin/bash
mkdir output & streamer -s 640×480 -o ./output/glitch_00000000.jpeg -t 1000000000000 -r 0.48 &
sleep 1.8 ; feh –action1 ";sed -i s/g/2/ %f" -F -r ./output/ –force-aliasing -Z -Y –reload 1 –slideshow-delay 2 &
while true ; do xdotool key –delay 200 1 ; done[/sourcecode]

The script works by using Streamer to capture sequentially-numbered images to a folder called “output”. feh is then used to display the image and also to run a sed command, thanks to the –action1 option. Actions in feh can only be run via a key press, so xdotools is used to automatically press a key (1). feh is then finally used to display each image full-screen.

It’s not the most efficient way of glitching from a webcam – e.g. you can get glitch plugins for Pure Data, Quartz Composer and other software – but as a small utility it works well. Also, it saves all of the images so you can make an animation out of it!

Glitch Webcam

*terribly unimaginative name, I know!