«« Keeping Unused Fields Around Removable Media »»
blog header image
Getting Ahead of MP3

To make testing files for AudioMan, often I only need the first 20k or so of a 5MB file. So I transfer the file to my Mac and use the command:

head -n 50 file.mp3 > clip.mp3

The Unix utility head is used to send an arbitrary number of lines of a text file to stdout, so it counts 50 end of line characters into the original file and (after redirecting stdout it) outputs the result into clip.mp3. Odds are the original file will have bytes that are the same as end of line characters, so all you have to do is adjust the -n number to get the output file size you want. Then you get the head of the mp3 file without modifying it.

I originally tried tools like mp3splt to get the start of an audio file but it modified the tag of the output file. So it wasn't much use to me when I wanted to keep iTunes tags, for instance.

Posted at February 27, 2004 at 05:37 PM EST
Last updated February 27, 2004 at 05:37 PM EST
Comments

Instead of always copying the file to your Mac, you could install Cygwin on your PC, that should allow you to run basic Unix commands.

http://www.cygwin.com/

» Posted by: Patrick Ritchie at February 28, 2004 12:35 AM

Ya, I use that at uhh, NOT work... and it works great.

My question about this is are you reattaching the id3v1 tags (since they are at the end of the file), or are you just dropping them? If you want to keep them, you'd probably just have to figure out how to keep the last 128 bytes and append it to your clip.

» Posted by: Jim at February 28, 2004 09:57 AM

Yes, I am dropping the id3v1 tag. I'm not using these files to test conflict resolution between id3v1 and id3v2 yet.

However, when I want to do that I can just use the Unix "tail" command the same way as "head" and then "cat" the head and the tail together to make a complete file.

» Posted by: Ryan at February 28, 2004 10:11 AM
Google
 
Search scope: Web ryanlowe.ca