Since I learned how to do this once, promptly forgot, and then had to learn all over again, it only makes sense to document this procedure so I don't have to reinvent the wheel again and again and again. Heck, maybe other people can benefit from this, as well. There does not seem to be one particular site on the Internet that strings these commands together towards this same purpose.

To make a one minute mp3 sample from another, full length, mp3, you'll need something to decode the mp3 into raw audio, something else to process the raw audio, and finally, something to encode the resulting audio back into the mp3 format.

I use mpg123 to decode the particular portion of the mp3 I wish to sample.sox is used to massage the sample and add fades. Apparently, there is an mp3 plugin module for sox that might allow one to skip using mpg123. However, I'm not sure you would have the same control over where to start playing the mp3 and how much to play.lame is the mp3 encoder I installed on my system. Most likely, any other would work just fine.

The general form of the command line looks like this:mpg123 -s -v --skip 3216 --frames 2340 <input.mp3> \ | sox -t raw -r44100 -sw -c 2 - -t .wav - fade t 3 60 5 \ | /usr/local/lame/bin/lame - <output.mp3>The mpg123 command line reads like this: Use mpg123; send its output to stdout; use verbose output; skip ahead x-number of frames before starting to play; play x-number of frames. There are somewhere in the range of 38-39 frames per second of audio. So, in the example above, I'm skipping ahead roughly 83 seconds in the audio stream, and playing for roughly sixty-one seconds.

The sox command line tells sox that audio input is coming in raw, sample rate of 44100 Hertz, 16-bit words, signed-linear encoding, two channels on stdin. The audio should be sent to stdout in .wav format. Fade the audio using a linear fade. Fade in for three seconds, play for sixty seconds, and start a fade out 55 seconds into the audio.

This is the easiest part. Tell lame to take the incoming audio on stdin, encode it into mp3, and then stream it into the filename given on the command line. </output.mp3></input.mp3>