Following my previous post, I attached a video camera to the composite input of my tv tuner. One good thing I didn’t noticed yesterday is that mplayer can be told to directly use
pvr:// as a source instead of the generic
tv:// (with many options). So you just have to enter
mplayer pvr:// -tv device=/dev/video1:input=0 in order to watch tv.
input=0 above? This tells the tuner to take the video signal from the tv (read the mplayer man page to see how to change the channel). Now, since I connected my video camera to the composite video in, I need to tell mplayer to use it with
input=1. One last thing: taking a screenshot in mplayer is done by pressing the ‘s’ key (with option
-vf screenshot. In summary, the image below was taken with
mplayer pvr:// -tv device=/dev/video1:input=1:noaudio -vo x11 -vf screenshot (camera facing the screen).
Now I want to take one screenshot every 5 seconds, even when I’m not there to press the ‘s’ key! For this purpose, we need to use a fifo file and mplayer in slave mode. Mplayer in slave mode will listen to commands we automatically send into the fifo file (by a different process, see below). This is how we do this:
mplayer -slave -input file=myfifofile.tmp pvr:// -tv device=/dev/video1:input=1:noaudio -vo x11 -vf screenshot
And from another console, we can type
echo "screenshot 0" >> myfifofile.tmp to take the screenshot. To automate all this, the following simple bash code is sufficient:
# will send mplayer screenshot command every 5 seconds to fifo file
# stop this with Ctrl + C
while [ $LIMIT -lt 1 ]; do
echo "screenshot 0" >> myfifofile.tmp
In the end, stop the bash script with Ctrl + C and quit mplayer with
echo "quit" >> myfifofile.tmp.