...making Linux just a little more fun!

<-- prev | next -->

The Mailbag

HELP WANTED : Article Ideas
Submit comments about articles, or articles themselves (after reading our guidelines) to The Editors of Linux Gazette, and technical answers and tips about Linux to The Answer Gang.

Digital camera audio files

Fri Jul 22 11:43:02 2005
Bob van der Poel (bvdp at uniserve.com)
Answered By Lew Pitcher, Ben Okopnik

I've recently gotten a digital camera (yes, I know I'm sort of late coming into the digital revolution). This is a HP R607 and lets you add audio tags to still images.

[Lew] Kewl.

I would have thought that the audio would be a wav or mp3 file with the same name as the image, but life is never easy. I can only assume that the audio is embbedded into the jpg. I've checked, and the only files on the camera (other than some short XML files) are the jpgs.

[Lew] Yah. The JFIF format (that's the file format that "JPEG" pictures are stored in) supports a bunch of metadata. Many (I'm tempted to say most) cameras store a 'thumbnail' photo in the jpg along with the full photo. They also store camera information (make, model) and photo metadata (date/time of photo, focal of lens, exposure time, photographers comments, picture orientation, and a whole lot more). It wouldn't surprise me if the HP camera also stored an audio clip as metadata in the picture jpg.
[Ben] When you say that you've checked, do you mean that you used something like "camedia", or did you actually mount it as a storage device and looked at the files on it? The former may only show the JPG files, while the latter should show everything. My Olympus D-40, for example, produces discrete files for audio, stills, and movies.
If you're actually looking at the files on the device, then I'd have to agree with the previous post - it's stored as EXIF data.

Yes. It is definitely stored as EXIF data. Ran a jpg file into emacs and had a look. There's a nice RIFF/WAV header block right in the file. Of course, the picture files without audio don't have the header.

More reading leads me to think that some cameras use 2 files and others embed the audio into the picture. Mine is that later :)

So, is there a way to play the audio in the pictures on Linux?

[Lew] I'm not sure, but it's likely that the audio is stored in one of the EXIF (JFIF metadata) tags. There are tools available that can extract EXIF tag data, ranging from the digikam/gphoto2/libgphoto tools to standalone tools like jhead. Perhaps one of these tools can extract out the audio, and you can play it from there.

Yes, it helps. Problem is to find a tool to do the extraction. digikam, etc (based on gphoto2) do NOT seem to support audio play/extraction.

[Ben] 'gphoto2' supports a '--get-audio-data' option. There are probably a number of other programs; googling for "exif audio extract linux" comes up with 40,500 hits. :)

I think from reading and a bit of testing that --get-audio-data just copies .wav files if they are on the camera. I could be wrong, but I could not get this program to extract data.

I did the google as well :) I found 2 candidate programs:

dphotox - this appears to be a great program, but I can't access the download site ftp://ftp.mostang.com/pub/dphotox I sent David.Mosberger @acm.org a note, but no reply as of yet. This is being distributed as a binary only ... something to do with non-disclosure according to the web page (which is accessable http://www.mostang.com/dphotox )

EXIFutilsLinux2.6.2.tgz is another package which works. Installed and tried it. It is shareware and they want a bit of money to unlock all the features.

Amazing, the files I did extract sounded not bad at all.

I can't imagine that getting the audio out is much more than trivial. I just don't have time right now, but I did compare the extracted file to the data in the camera file and it is identical. Just a matter of figuring an offset and the size.

[Jimmy] I shouldn't imagine it's even that difficult: the audio is stored as an EXIF tag, so you really just need to extract the contents of a specific tag. (Hint: with Perl, Image::EXIF and Data::Dumper are your friends).
If you want to send along a sample file, I'd be happy to give it a stab/eat my words :)
[Heather] dd has a very nice 'skip' option as well as 'count'. if your 'blocksize' is set to 1 and you are otherwise able to calculate how long to make the cut, you should be able to do something like substring extraction, on a file basis.
If our gentle readers have more ideas, or someone would like to do an article on really getting the most out of your camera under Linux, it'd be just the kind of thing to make Linux just a little more fun :)

Problems with tcsh scripting

Mon Jun 27 01:39:00 2005
Aengus Walton (ventolin at gmail.com)
Answered By Ben Okopnik

I have a number of issues with tcsh (not my choice..) shell scripting I need help with.

Basically I'm writing a shell script that automates a long setup procedure. This top-level script is in bash, however the bulk of it is comprised of commands that are fed to a program which is, in essence, a tcsh shell. I've achieved this by using the << redirector. I need help on two points:

1) Is there any way of suspending input redirection, taking input from the keyboard, and then resuming input from the tcsh script?

[Ben] There is, but it is Fraught With Large Problems. I'm not that familiar with TCSH, but I've just had to do that in Perl - essentially, I was writing a Perl version of 'more' and had to answer the question of 'how do you take user input from STDIN when the stream being paged is STDIN?' It requires duplicating the STDIN filehandle... but before you start even trying to do it, let me point you to "CSH Programming Considered Harmful" - Tom Christiansen's famous essay on Why You Shouldn't Do That. If it's not your choice, then tell the people whose choice it is that They Shouldn't Do That. The task is complex enough, and has enough touchy problems of its own, that introducing CSH into the equation is like the Roadrunner handing an anvil to the Coyote when he's already standing on shaky ground over a cliff.
To give you some useful direction, however - the answer lies in using 'stty'.

2) There comes a point towards the end of the script when two shell scripts are run simultaneously. These shell scripts open up individual xterm windows to run inside. I'm wondering, is there anyway of having the tcsh script monitor stdout of one xterm, and upon the output of a certain piece of text, echoing a command into the stdin of the other xterm?

[Ben] Why not 'tee' the output of the script - one 'branch' into the xterm and the other into a pipemill (or whatever you want to run 'grep' in)?

Any insight or knowledge on the matter would be very much appreciated. I hope I have provided sufficient details.

[Ben] You have - from my perspective, anyway.
If the gentle readers have more to say, please let Aengus know, and cc The Answer Gang so we can comment on the results or see his answer in a later issue. Artciles on working with shells beyond bash are always welcome. -- Heather


Correction to WSGI article

Fri Jul 8 14:51:26 2005
Sluggo (mso at oz.net)

There's a mistake in my "WSGI Explorations in Python" article. http://linuxgazette.net/115/orr.html It says,


But both sides of WSGI must be in the same process, for the simple reason that the spec requires an open file object in the dictionary, and you can't pickle a file object and transmit it to another process.


Actually, the spec requires a file-like object, so an emulation like StringIO is allowed. StringIO is pickleable:

>>> from StringIO import StringIO
>>> sio = StringIO("abc")
>>> p = pickle.dumps(sio)
>>> p
>>> sio.read()
>>> sio.read()
"                   # End of file.
>>> sio2 = pickle.loads(p)
>>> sio2.read()

cStringIO, however, is not pickleable.

> He also requests that Ben slip an editor's note to this effect into 115's instance of the article. If your mirror doesn't contain a note about it by next month... sorry, we can advise our mirrors when the archives update, but it's their bandwidth. -- Heather

Debian kernels without devfs

Fri Jul 8 21:15:29 2005
Kapil Hari Paranjape (kapil at imsc.res.in)

This is regarding Hugo Mills query on how to build a Debian initrd without devfs.

Now why would you be wanting to build a Debian kernel without devfs.
Surely you haven't bought all that stuff by Greg K.-H. about devfs
being bad design?
[Rick] Surely, it would be rude to speak ill of the dead. As we say in Norwegian, "Aluv ha sholem." ;->

I assume that you are planning to use Debian's kernel-package (make-kpkg) utility to build the kernel. This you can do without worrying about anything. Just build a kernel without devfs and other options as you want them.

The initrd that is installed along with the kernel is built (providing you specified that you wanted it to be built) at the time when you install the kernel-image-x.x.x-y package.

This initrd is build by a set of tools called (what else) initrd-tools; the principal among them being "mkinitrd". Now "mkinitrd" takes a conf file /etc/mkinitrd/mkinitrd.conf so you can make some changes there.

I haven't tried this but you would need to create a script in /etc/mkinitrd/scripts that would setup the necessary device files in the $INITRDDIR/dev.

More importantly, the script /usr/share/initrd-tools/init is the "init" that is put on the initrd image. You would need to replace this with your own version as the default one makes use of devfs.

If you are keen on sorting out all these issues you should probably contact the maintainer of initrd-tools as Debian's initrd will have to give up "devfs" at some stage since Linux 2.8 won't have "devfs".

Re: [LG 116] mailbag #1

Fri Jul 8 16:08:00 2005
Dan Linder (dan from linder.org)

Just a thought, but how about if he compiles a plain-jane Pentium I kernel? It could be that the more recent kernels (and GCC?) might be putting in CPU instructions that didn?t get called before, or they are called more often now and are causing other errors. My experience is if the system is locked hard like he implies, then it's probably a hung CPU not answering interrupts (as he alluded to).

[Heather] Except for the part about how it answers them just fine under 2.4.x kernels, this seems plausible. It'll be tried.

He might also try limiting his use to the 768MB of RAM that his MB officially supports. Either by using the kernel command line "mem=768M" or put in only 768MB of RAM.

As a side note, he might want to run "MEMTest86+" (http://www.memtest.org/) and see if that sees any RAM errors.

There just might be a reason the MB manufacturer didn't recommend >768MB RAM. :(

[Heather] The full gig worked under 2.4.x kernels however some time has passed. So, this is a very worthy suggestion. Also a current 2.4.x kernel will be tried, if the hardware is failing in this sense that might be affected too. Note to readers: the good folk at MEMTEST do occasionally update their test suite. Looks like the last update was in 2004 sometime - but some of the rescue disks might have an older edition in them.

TAG "playmidy plays silently" LG#116

Sat Jul 16 22:38:29 2005
Walt Reinemer (wmreinemer at tns.net)

Midi plays, but it is not easy. I am running Slackware 9.1 with a 2.4.28 kernel on a K6III 400.

I am using sfxload from the awesfx-0.5.0d package to load soundfonts on to a SBLive soundcard

the awesfx-0.5.0d package is available at:

If you load the soundfonts and play a midi, you may have to download the soundfonts from the SBLive card prior to playing a wav file. The soundfonts do not stay loaded very long, so you have to check the available SBLive memory prior to playing a midi.

Perhaps this will help.


Latest Gazette Issue

Wed Jul 6 06:02:15 2005
Martin Hooper (martinjh_linux at blueyonder.co.uk)
A tickler about last month's issue taking so long to publish... -- Heather

Any news on the when the latest Gazette is out? Or have I missed the announcement... Being subscribed on both of my accounts to the announcement list...

[Ben] I figured we'd get mail from our readers about now. :) The new issue should be out tonight, Martin; the problem was that - this being summer - many of our authors are on vacation, and we were a bit thin on articles. Several of the folks in The Answer Gang had, very capably, scrambled their jets and kicked in a bunch of material, and I've been working to get it all organized. Blame the delay on me.
For all our readers, if you've ever wanted to try your hand at writing - we're always looking for new authors. In the worst case, if your submission gets rejected - and this is part of my commitment to LG - you'll get a note explaining exactly why it was rejected, along with suggestions on how to improve your writing. That is, at the very least, you'll get to learn something useful - and you may well end up getting published, which is not a bad thing to have on your resume. :) So don't be shy, folks - read our Authors' FAQ and send'em in!

It is our preference to ship an issue somewhere around the first of the month. Our lives including work in the weekdays have led the last several issues to come out somewhere around the weekend that's nearest; with the articles that came in late, we ran a bit overtime even by that standard. Sorry. But I also encourage people with good articles that they feel need some work, to contact us and get into the sequence. You needn't always publish in the same month - we won't write your article for you, but our Articles@ staff may be able to point out some directions for improvement, and we get a new author out of the deal, too. So everyone wins :) -- Heather

London explosions

Fri Jul 8 14:23:39 2005
Benjamin A. Okopnik (ben at linuxgazette.net)

I know that Thomas, at least, is away from the City, but - just for my own peace of mind - are all the Answer Gangsters from England OK? That would be Mike Martin and Neil Youngman that I recall; if anyone else can think of others, I'd appreciate it if you could ping them and CC the list.

[Thomas] Aww, thanks, Ben. Actually, I was only 33 miles from London at the time. I was in Stevenage, a town around London visiting my Grandparents. Would you believe they have broadband? Heh. More modern than my parents.
But I'm well, and accounted for. :)

And I'm very glad to hear it!

[Thomas] I just hope Neil is, although as I know Neil is around the Pin-Green area (where my grandparents are), I would surmise he too is just as well. :)

Yes indeed; he's emailed me (and as I recall, cc'd the Gang on it.) I haven't heard back from Mike yet, though - it's a bit worrying. Since you live in the same small island, could you perhaps walk over and knock on his door? :)

[Neil] Ben your concern is appreciated. I was working from home that day, fortunately miles away from all the incidents. My wife was working in London as usual, and the first bomb was on her route in. Luckily she was already at work when it went off. Although she had a very unpleasant journey home, we are lucky it was no worse than an inconvenience for us. With 49 confirmed dead and more than 25 missing, our thoughts are with their families.
[Thomas] Small? Hehehe, Ben, sail your boat round these waters, I'll show you around this place. :)
(!) [Jimmy] There was a lot of off-topic chat in here too: enjoy the Launderette if you're interested

This page edited and maintained by the Editors of Linux Gazette
HTML script maintained by Heather Stern of Starshine Technical Services, http://www.starshine.org/


Copyright © 2005, . Released under the Open Publication license unless otherwise noted in the body of the article. Linux Gazette is not produced, sponsored, or endorsed by its prior host, SSC, Inc.

Published in Issue 117 of Linux Gazette, August 2005

<-- prev | next -->