Version 0 of Video babbleback machine

Updated 2004-01-01 23:05:09

Brian Theado - 01Jan04 - After writing the babbleback machine program, my daughter begged me daily for more than a month to play. Her interest is finally starting to wan. She still enjoys playing with it if I turn it on. Along the way, I got the idea of making a video camera version of the same program. I have a digital camera with Firewire (aka iLink, aka IEEE1394) connectivity. I searched to no avail for a program or set of programs that would make doing this easy on Microsoft Windows.

I turned my search to Linux and hit the jackpot. Linux has a command-line program called dvgrab that makes it simple to capture data from a digital video camera. A program called kino will playback video files. Both programs are available at http://kino.schirmacher.de . Tcl is a great languange to glue the two applications together into a program that constantly records video and plays it back with a 2 second delay.

Here's the sourcecode for the script

 #!/usr/bin/tclsh
 proc queueFile dv {
    # Read the line of output from dvgrab and extract the filename
    set line [gets $dv]
    puts $line
    regexp {(.+):} $line -> file

    # Queue the file for playback using the existing xine session
    exec xine -S mrl=$file

    # Delete the file when it is done playing (hopefully it will be done)
    variable delay
    after [expr ($delay * 1000) + 100] [list file delete $file]
 }
 # Launch xine
    set xinePid [exec xine --hide-gui &]
 # Launch dvgrab.  Configure it to split off a new file every $delay seconds
    set delay 2
    set framesPerSecond 30 ;# NTSC format
    set framesToGrab [expr $delay *  $framesPerSecond]
    set dv [open "|dvgrab --frames $framesToGrab --format dv2  --autosplit cinemaback"]

 # dvgrab outputs a line with the file name each time it splits off a new file
    fileevent $dv readable [list queueFile $dv]
    vwait forever

If you don't have Linux installed and you want to try this script out, then check out Knoppix (http://www.knoppix.org ). It is a live CD distribution of Linux that will run directly from a CD with no installation necessary. Just download the iso image and burn it to a CD. It comes with firewire drivers, dvgrab, and kino all pre-installed.

To activate the firewire drivers, just execute:

 sudo insmod ieee1394
 sudo insmod ohci1394
 sudo insmod raw1394

Camera idiosyncrasies: My camera is a Panasonic PV-DV202 and I found that if it has a tape in it and it isn't recording, then it shuts off after a few minutes. It doesn't seem to recognize that data is being sent across the firewire cable. I work around this by removing the tape.