Friday, February 15, 2008

Command Line Video Capture Linux

You can use v4lctl to select channel or input on the card. streamer from Xawtv is an easy command line to use but it doesn't have audio compression. ffmpeg can grab audio and compress it. I didn't have luck with their built-in audio codecs. So I downloaded and compiled lame into it.

The audio devices change from -f audio_device to -f oss . I used a quick shell script to find that mpeg2video offers the best compression without overtaxing the Athlon 1400 processor.

ffmpeg -t 00:00:10 -s 640x480 -r 30 -f video4linux -i
/dev/video0 -b 400k -vcodec mpeg2video -ac 2 -f oss -i /dev/dsp
-acodec libmp3lame -y tensec.mpg

For compressing DVDs to iPod format, don't forget to specify the -ac 2 flag to downsample from typical 5.1 audio.

Tuesday, February 05, 2008

Code Generation under Apache Ant

I was using Perl scripts to do Java code generation with Apache Ant. Based on an XML file, we'd generate *.java files. The tricky part is implementing a clean target.

Ant makes it easy to do really simply things like compile java. It's quite a brain-bender to do other things.

The code generation outputs a text file with all the files that it created. Ant doesn't really have an easy way of duplicating what I would have done with Unix shell: /bin/rm `cat [file]`. It is further complicated by the deep path structure that Java likes to have for its packages.

The real way of doing it with ant was to copy the XML files into the build directory and code generate there. Then you can just remove the build directory.