twolame - an optimised MPEG Audio Layer 2 (MP2) encoder
twolame [options] <infile> [outfile]
TwoLAME is an optimised MPEG Audio Layer 2 (MP2) encoder based on
tooLAME by Mike Cheng, which in turn is based upon the ISO dist10 code and
portions of LAME. Encoding is performed by the libtwolame library
twolame uses libsndfile for reading the input sound file, so the
input file can be in any format supported by libsndfile. To read raw PCM
audio from STDIN, then use - as the input filename.
If no output filename is specified, then suffix of the input
filename is automatically changed to .mp2. To write the encoded audio to
STDOUT then use - as the output filename.
Specifies that input is raw signed PCM audio. If audio is
stereo, than audio samples are interleaved between the two channels.
Force byte-swapping of the input. Endian detection is
performed automatically by libsndfile, so this option shouldn’t
normally be needed.
-s, --samplerate <int>
If inputting raw PCM sound, you must specify the sample
rate of the audio in Hz. Valid sample rates: 16000, 22050, 24000, 32000,
44100, 48000Hz. Default sample rate is 44100Hz.
Specifies the sample size (in bits) of the raw PCM audio.
Valid sample sizes: 8, 16, 24, 32. Default sample size is 16-bit.
-N, --channels <int>
If inputting raw PCM sound, you must specify the number
of channels in the input audio. Default number of channels is 2.
Swap the Left and Right channels of a stereo input
Scale the input audio prior to encoding. All of the input
audio is multiplied by specified value. Value between 0 and 1 will reduce the
audio gain, and a value above 1 will increase the gain of the audio.
Same as --scale, but only affects the left channel.
Same as --scale, but only affects the right
-m, --mode <char>
Choose the mode of the resulting audio. Default is auto.
•"a" auto - choose mode automatically
based on the input
•"d" dual channel
•"j" joint stereo
If the input file is stereo then, downmix the left and
right input channels into a single mono channel.
-b, --bitrate <int>
Sets the total bitrate (in kbps) for the output file. The
default bitrate depends on the number of input channels and samplerate.
Sample Rate Mono Stereo
48000 96 192
44100 96 192
32000 80 160
24000 48 96
22050 48 96
16000 32 64
-P, --psyc-mode <int>
Choose the psycho-acoustic model to use (-1 to 4). Model
number -1 is turns off psycho-acoustic modelling and uses fixed default values
instead. Please see the file psycho for a full description of each of
the models available. Default model is 3.
Enable VBR mode. See vbr documentation file for
details. Default VBR level is 5.0.
-V, --vbr-level <float>
Enable VBR mode and set quality level. The higher the
number the better the quality. Maximum range is -50 to 50 but useful range is
-10 to 10. See vbr documentation file for details.
-l, --ath <float>
Set the ATH level. Default level is 0.0.
-q, --quick <int>
Enable quick mode. Only re-calculate psycho-acoustic
model every specified number of frames.
Enables single frame mode: only a single frame of MPEG
audio is output and then the program terminates.
Turn on Copyright flag in output bitstream.
Turn off Original flag in output bitstream.
Turn on Original flag in output bitstream.
Enable CRC error protection in output bitstream. An extra
16-bit checksum is added to frames.
Turn on padding in output bitstream.
-R, --reserve <int>
Reserve specified number of bits in the each from of the
-e, --deemphasis <char>
Set the de-emphasis type (n/c/5). Default is none.
Turn on energy level extensions.
-t, --talkativity <int>
Set the amount of information to be displayed on stderr
(0 to 10). Default is 2.
Don’t send any messages to stderr, unless there is
an error. (Same as --talkativity=0)
Only display a minimal number of messages while encoding.
This setting is quieter than the default talkativity setting. (Same as
Display an increased number of messages on stderr. This
setting is useful to diagnose problems. (Same as --talkativity=4)
If encoding completes successfully, then twolame will return 0.
However if encoding is not successful, then it will return one of the
•1 (No encoding performed)
•2 (Error opening input file)
•4 (Error opening output file)
•6 (Error allocating memory)
•8 (Error in chosen encoding parameters)
•10 (Error reading input audio)
•12 (Error occurred while encoding)
•14 (Error writing output audio)
This will encode sound.wav to sound.mp2 using the default constant
bitrate of 192 kbps and using the default psycho-acoustic model (model
Constant bitrate of 160kbps and joint stereo encoding, saved to
twolame -b 160 -m j sound.aiff sound_160.mp2
Encode sound.wav to newfile.mp2 using psycho-acoustic model 2 and
encoding with variable bitrate:
twolame -P 2 -v sound.wav newfile.mp2
Same as example above, except that the negative value of the
"-V" argument means that the lower bitrates will be favoured over
the higher ones:
twolame -P 2 -V -5 sound.wav newfile.mp2
Resample audio file using sox and pipe straight through
sox sound_11025.aiff -t raw -r 16000 | twolame -r -s 16000 - - > out.mp2
The twolame frontend was (re)written by Nicholas J Humfrey. The
libtwolame library is based on toolame by Mike Cheng. For a full list of
authors, please see the AUTHORS file.
Copyright © 2004-2018 The TwoLAME Project. Free use of this
software is granted under the terms of the GNU Lesser General Public License
Nicholas J Humfrey <firstname.lastname@example.org>