1TWOLAME(1) TWOLAME(1)
2
3
4
6 twolame - an optimised MPEG Audio Layer 2 (MP2) encoder
7
9 twolame [options] <infile> [outfile]
10
12 TwoLAME is an optimised MPEG Audio Layer 2 (MP2) encoder based on
13 tooLAME by Mike Cheng, which in turn is based upon the ISO dist10 code
14 and portions of LAME. Encoding is performed by the libtwolame library
15 backend.
16
18 Input File
19 twolame uses libsndfile for reading the input sound file, so the input
20 file can be in any format supported by libsndfile. To read raw PCM
21 audio from STDIN, then use - as the input filename.
22
23 Output File
24 If no output filename is specified, then suffix of the input filename
25 is automatically changed to .mp2. To write the encoded audio to STDOUT
26 then use - as the output filename.
27
28 Input Options
29 -r, --raw-input
30 Specifies that input is raw signed PCM audio. If audio is stereo,
31 than audio samples are interleaved between the two channels.
32
33 -x, --byte-swap
34 Force byte-swapping of the input. Endian detection is performed
35 automatically by libsndfile, so this option shouldn’t normally be
36 needed.
37
38 -s, --samplerate <int>
39 If inputting raw PCM sound, you must specify the sample rate of the
40 audio in Hz. Valid sample rates: 16000, 22050, 24000, 32000, 44100,
41 48000Hz. Default sample rate is 44100Hz.
42
43 --samplesize <int>
44 Specifies the sample size (in bits) of the raw PCM audio. Valid
45 sample sizes: 8, 16, 24, 32. Default sample size is 16-bit.
46
47 -N, --channels <int>
48 If inputting raw PCM sound, you must specify the number of channels
49 in the input audio. Default number of channels is 2.
50
51 -g, --swap-channels
52 Swap the Left and Right channels of a stereo input file.
53
54 --scale <float>
55 Scale the input audio prior to encoding. All of the input audio is
56 multiplied by specified value. Value between 0 and 1 will reduce
57 the audio gain, and a value above 1 will increase the gain of the
58 audio.
59
60 --scale-l <float>
61 Same as --scale, but only affects the left channel.
62
63 --scale-r <float>
64 Same as --scale, but only affects the right channel.
65
66 Output Options
67 -m, --mode <char>
68 Choose the mode of the resulting audio. Default is auto.
69
70 • "a" auto - choose mode automatically based on the input
71
72 • "s" stereo
73
74 • "d" dual channel
75
76 • "j" joint stereo
77
78 • "m" mono
79
80 -a, --downmix
81 If the input file is stereo then, downmix the left and right input
82 channels into a single mono channel.
83
84 -b, --bitrate <int>
85 Sets the total bitrate (in kbps) for the output file. The default
86 bitrate depends on the number of input channels and samplerate.
87
88 ------------------------------
89 Sample Rate Mono Stereo
90 ------------------------------
91 48000 96 192
92 44100 96 192
93 32000 80 160
94 24000 48 96
95 22050 48 96
96 16000 32 64
97 ------------------------------
98
99 -P, --psyc-mode <int>
100 Choose the psycho-acoustic model to use (-1 to 4). Model number -1
101 is turns off psycho-acoustic modelling and uses fixed default
102 values instead. Please see the file psycho for a full description
103 of each of the models available. Default model is 3.
104
105 -v, --vbr
106 Enable VBR mode. See vbr documentation file for details. Default
107 VBR level is 5.0.
108
109 -V, --vbr-level <float>
110 Enable VBR mode and set quality level. The higher the number the
111 better the quality. Maximum range is -50 to 50 but useful range is
112 -10 to 10. See vbr documentation file for details.
113
114 -l, --ath <float>
115 Set the ATH level. Default level is 0.0.
116
117 -q, --quick <int>
118 Enable quick mode. Only re-calculate psycho-acoustic model every
119 specified number of frames.
120
121 -S, --single-frame
122 Enables single frame mode: only a single frame of MPEG audio is
123 output and then the program terminates.
124
125 Miscellaneous Options
126 -c, --copyright
127 Turn on Copyright flag in output bitstream.
128
129 -o, --non-original
130 Turn off Original flag in output bitstream.
131
132 --original
133 Turn on Original flag in output bitstream.
134
135 -p, --protect
136 Enable CRC error protection in output bitstream. An extra 16-bit
137 checksum is added to frames.
138
139 -d, --padding
140 Turn on padding in output bitstream.
141
142 -R, --reserve <int>
143 Reserve specified number of bits in the each from of the output
144 bitstream.
145
146 -e, --deemphasis <char>
147 Set the de-emphasis type (n/c/5). Default is none.
148
149 -E, --energy
150 Turn on energy level extensions.
151
152 Verbosity Options
153 -t, --talkativity <int>
154 Set the amount of information to be displayed on stderr (0 to 10).
155 Default is 2.
156
157 --quiet
158 Don’t send any messages to stderr, unless there is an error. (Same
159 as --talkativity=0)
160
161 --brief
162 Only display a minimal number of messages while encoding. This
163 setting is quieter than the default talkativity setting. (Same as
164 --talkativity=1)
165
166 --verbose
167 Display an increased number of messages on stderr. This setting is
168 useful to diagnose problems. (Same as --talkativity=4)
169
171 If encoding completes successfully, then twolame will return 0. However
172 if encoding is not successful, then it will return one of the following
173 codes.
174
175 • 1 (No encoding performed)
176
177 • 2 (Error opening input file)
178
179 • 4 (Error opening output file)
180
181 • 6 (Error allocating memory)
182
183 • 8 (Error in chosen encoding parameters)
184
185 • 10 (Error reading input audio)
186
187 • 12 (Error occurred while encoding)
188
189 • 14 (Error writing output audio)
190
192 This will encode sound.wav to sound.mp2 using the default constant
193 bitrate of 192 kbps and using the default psycho-acoustic model (model
194 3):
195
196 twolame sound.wav
197
198 Constant bitrate of 160kbps and joint stereo encoding, saved to file
199 sound_160.mp2:
200
201 twolame -b 160 -m j sound.aiff sound_160.mp2
202
203 Encode sound.wav to newfile.mp2 using psycho-acoustic model 2 and
204 encoding with variable bitrate:
205
206 twolame -P 2 -v sound.wav newfile.mp2
207
208 Same as example above, except that the negative value of the "-V"
209 argument means that the lower bitrates will be favoured over the higher
210 ones:
211
212 twolame -P 2 -V -5 sound.wav newfile.mp2
213
214 Resample audio file using sox and pipe straight through twolame:
215
216 sox sound_11025.aiff -t raw -r 16000 | twolame -r -s 16000 - - > out.mp2
217
219 The twolame frontend was (re)written by Nicholas J Humfrey. The
220 libtwolame library is based on toolame by Mike Cheng. For a full list
221 of authors, please see the AUTHORS file.
222
224 TwoLAME web site: http://www.twolame.org/
225
227 lame(1), mpg123(1), madplay(1), sox(1)
228
230 Copyright © 2004-2018 The TwoLAME Project. Free use of this software is
231 granted under the terms of the GNU Lesser General Public License
232 (LGPL).
233
235 Nicholas J Humfrey <njh@aelius.com>
236 Author.
237
238
239
240 10/11/2019 TWOLAME(1)