Hi! Do you remember blogs? Well, this used to be one. Now it just serves as an archive for my multiple Twitter accounts.

29 August 2004

It’s been hard, but I think my tvcam finally works fine on Linux.

For a while now I’ve been dealing with xawtv in order to make the TV captures that illustrate my blog (and also for my personal collection of nude actors, of course). That means I have to run X/Window all the time, I have to go to the menus every time I launch it in order to select the composite input, I have to press “J” to save a capture (could be worse: at least that’s one of the two special keys for the blind), and I have to turn the screen on and grab the mouse to select the video source again every time I’ve pressed another key than “J”, which happens a lot.

So yesterday I finally decided to google a bit for a command-line variant — because as a developer I know I would have made a command-line video capture utility. And, as Linux happens to be made by developers for developers, it does exist, and all I have to do is type apt-get install webcam. A little crontab addition and there you go, my tvcam is updated every minute. Magical!

Yeah. But no. Because I want to use the capture card both for the tvcam and my local personal captures. That’s the whole point of using the Linux version; otherwise I could as well set up an old video card on my Windows computer for the tvcam. Trouble is, if I use webcam both from the command line and from crontab, both quit working and say the video source is busy — go figure why both fail. So we’re back to square one.

And that’s when I stumble on a manual page I had once read and forgotten: man xawtv-remote. As long as xawtv is running (which still implies having X/Window and selecting the composite input at every launch, but those are the least annoying drawbacks) I can launch as many xawtv-remote as I want and they’ll communicate with the same xawtv instance, avoiding any conflicts. (At least that’s how I expect it to work.)

So I’m left with a tvcam picture I have to upload myself now, and that’s no simple feat either. I thought an obvious ftp ftpperso.free.fr < commands.txt would do, but it doesn’t seem to work at all. For some reason, C-kermit doesn’t work either (maybe some incompatibility with my proxy or something, I don’t know — since the Linux PC is my personal file server, I don’t want it to be directly connected to the Net). And you can automate ftp by creating a .netrc file, but when it fails (and it often fails due to a very unstable wifi connection) that dumb ftp goes back to interactive mode, stalling the script. Silly silly silly. Hack required.

So while I’m being geeky and all, why don’t I give you the scripts?

/usr/local/bin/tvcam makes a full-resolution local capture every time I press Enter:

while [ true ]
do
echo “*** Press ENTER to capture TV ***”
read toto
capturedatestamp = `date “+%Y%m%d-%H%M%S”`
xawtv-remote snap jpeg full /home/garoo/captures/$capturedatestamp.jpg
done

It’s so simple once xawtv is up and running — much simpler than the webcam configuration file that requires a valid [ftp] section even when you only want to use the dated archive function.

/home/garoo/tvcam/tvcam launches a capture every thirty seconds (I can’t crontab it, because then it can’t contact xaxtv — probably an option I missed, but it’s no big deal):

while [ true ]
do
./capture &
sleep 30
done

/home/garoo/tvcam/capture, called above, and there’s a reason it’s a separate script:

xawtv-remote snap jpeg 320x240 /home/garoo/tvcam/tvcam.jpg
ftp 10.10.10.64 &
sleep 10

The hack is that ftp is launched in the background and automatically killed after ten seconds, when the script exits (hurray for ten-year old Unix classes memories).

/home/garoo/.netrc finally, the configuration file used when you run ftp 10.10.10.64 :

machine 10.10.10.64 login garoo@ftpperso.free.fr password xxxxxx
macdef
init
binary
put tvcam.jpg tvcam.temp.jpg
rename tvcam.temp.jpg tvcam.jpg
quit

Wow. All this, just for that. Linux is good, but you gotta really want it. Next step, try putting the webcam on the server too.

Archives

2001 01 02 03 04 05 06 07 08 09 10 11 12

2002 01 02 03 04 05 06 07 08 09 10 11 12

2003 01 02 03 04 05 06 07 08 09 10 11 12

2004 01 02 03 04 05 06 07 08 09 10 11 12

2005 01 02 03 04 05 06 07 08 09 10 11 12

2006 01 02 03 04 05 06 07 08 09 10 11 12

2007 01 02 03 04 05 06 07 08 09 10 11 12

2008 01 02 03 04 05 06 07 08 09 10 11 12

2009 01 02 03 04 05 06 07 08 09 10 11 12

2010 01 02 03 04 05 06 07 08 09 10 11 12

2011 01 02 03 04 05 06 07 08 09 10 11 12

2012 01 02 03 04 05 06 07 08 09 10 11 12

2013 01 02 03 04 05 06 07 08 09 10 11 12

2014 01 02 03 04 05 06 07 08 09 10 11 12

2015 01 02 03 04 05 06 07 08 09 10 11 12

2016 01 02 03 04 05 06 07 08 09 10 11 12

2017 01 02 03 04 05 06 07 08 09 10 11 12

2018 01 02 03 04 05 06 07 08 09 10 11 12