Editing File Headers

Hey Guys,

Absolute neewbie here. I am trying to see if it is possible to edit headers/meta-data of files in Mac OSX. I am basically trying to change an audio file header to read 16bit instead of 24bit.

We have an issue with some of our software and it regularly exports 16bit audio files with 24bit headers (so any other software will read the file as 24bit when in fact it is 16bit).

I am trying to see if it is possible to edit the meta-data/header to read 16bit without making another generation of the file. If I want another generation I can use afconvert in terminal. I would like to edit the data of the file without recreating it.

I hope you guys can help.

With Kind Regards

Andy

If you know the differences, you can move the data to a new file using the byte or character options of head and tail, and insert the different bytes in the middle. If they are not text bytes, you can use tr to turn text to binary, like a to 21 octal:

echo a|tr a '\21'

To mangle it in place, use C or PERL to seek and write the correct bytes. I would doubt the file has a checksum on the header/metadata.

Dear DGPickett,

Many thanks for the reply.

I am still trying to get my head around all of this. Like I said I am a complete newbee. Are you suggesting moving the audio data to a new file with correct headers?

With Kind Regards

Andy

Yes, the effect is the same, give or takes some renaming. Update in place destroys the original if anything goes wrong, and requires much more sophisticated tools. Most text tools truncate as they write. You need a very serious language, like PERL or C, to update the middle. Maybe it is a mindset hangover from tape, where, generally, the last thing you wrote is implicitly just before EOF.

A header could contain a file length and checksum as well as data type and format type magic strings, making updates more complex, but they are less popular in audio/video as you do not know these until the end, long after the header is written, and they do not want to go back and update, either.

Getting a patch to the software would be even nicer. I have patched stings in library file object code using a binary find and replace copier, and scary thing is, no checksum alarms went off! Maybe we need secure ELF? But these few bits are harder to locate and may break other things if you change them.