MP3packer is a program which can rearrange the data within an MP3 to fulfill specific goals. By default, the program generates the smallest MP3 possible (with the least padding). However, many people also use it to turn VBR files into CBR for use with players which don't support VBR.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Please see gpl.txt for more details. Source code for this program should be available from the same place as the compiled version.
mp3packer
[ options
] in.mp3
[ out
]
Processes in.mp3
according to options
and saves the output to out
. If out
is a directory, mp3packer will keep the same name as in
but in the out
directory. If out
is not given, the -a
string will be appended to the file name (see below).
mp3packer
[ options
] inDir
[ outDir
]
Processes all files ending in ".mp3" in the directory
inDir
. This is not recursive. If outDir
is given, all output files will have the same name in the outDir
directory. If outDir
is not given, the files will have the -a
string appended to them, and will stay in inDir
.
options
, if specified, may be any of the following:
-b #
-b 129
will result in the smallest allowed frame size being a padded 128kbps frame. -b 117
will result in the smallest allowed frame size being an unpadded 128kbps frame. If -b 128
is used with 44100Hz files, the minimum bitrate will depend on the frame number. Assuming 44100Hz, for 2 frames out of 49 the minimum frame will be unpadded, for the other 47 it will be padded. All bitrates from 114 to 127 will result in the smallest frame being an unpadded 128kbps frame. For further clarifications, see below.-t
-s
and -t
to remove all tags.-s
-z
-z
switch is still completely lossless. MP3 files have a number of different methods to compress the data, and most encoders only choose between a few of them. The -z
switch will do a brute-force search for the most efficient compression setting. This guarantees that each frame is as small as it can get, but it takes longer to repack.--workers #
-z
processing. These workers will run in parallel with the rest of the program. 0 is a valid number, and corresponds to synchronous processing. The default is a function of the number of processors/cores the program detects, and will likely change in different versions of the program.-a "-vbr"
mp3packer -a "-food" in.mp3
is given, the output will be named in-food.mp3
. "-vbr"
is the default.-A
-a
string appended. The default prevents files from being processed twice (giving names like filename-vbr-vbr-vbr.mp3), but if you have changed settings to reprocess this may be useful.-u
mp3packer -u process.mp3 backup.mp3
, the file process.mp3
will contain the packed mp3, and backup.mp3
will be the same as the original process.mp3
. Note that if you don't specify an output file or change the -a
option, the original will have "-vbr"
appended to it, which may lead to confusion.-w
-r
, -R
-b
switch is used. The -r
switch will force minimization all the time, and the -R
switch will maximize the bit reservoir at every frame (which was the behavior before 1.16). Note that this will not change the size of the files at all, and has little purpose other than occasionally making CBR320 files easier to split.--keep-ok
[ out
| both
]out
will only keep the output file and will delete the input file, whereas both
will keep both files (the default)--keep-bad
[ in
| out
| both
]in
will only leave the input file and will discard the repacked file. out
does just the opposite. both
keeps both files (default). Note that buffer under/overflows and sync errors are counted as errors, whereas recompression errors (if using the -z
switch) are not.--copy-time
-f
-u
option, it will force overwriting the backup file.--process
[ base
| sse41
]-z
switch. The default is SSE4.1 (represented by "sse41"
) if your computer supports it. There is generally no reason to change the default unless you suspect there is an error in one of the algorithms.-i
--ib
-i
, but print only the minimum CBR bitrate.--nice #
Parameter | <=-16 | -15 | -14 | -13 | -12 | -11 | -10 | -9 | -8 | -7 | -6 | -5 | -4 | -3 | -2 | -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | >=19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Priority | 15 | 14 | 13 | 12 | 11 | 10 | 8/9 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | ||||||||||||||||||||||
Name | High | Above normal | Normal | Below Normal | Idle |
--nice
with Parameter will set the Windows priority to Priority, which shows up in the task manager as Name. The default niceness is 10, which corresponds to a Windows priority of 4, or "Below Normal". --debug
[ in
| out
| huff
| all
]--debug in
will report frame statistics about the input file. --debug out
will report on how the file was processed and written. --debug huff
will print debug information about the recompression of frames if the -z
option is given. --debug all
does all three. It is recommended that you redirect the output to a file, as the information gets quite verbose.By specifying the -i
option, the program will print data about the input file then exit. No files will be written and the output (if given) will be ignored. Example printout:
*** "test/APS.mp3" INFO: MPEG1 layer 3 21687 frames 44100 Hz 38.281250 frames per second 566.517551 seconds 12514543 bytes in file (176.722405 kbps) 12514126 bytes in MP3 frames (176.716516 kbps) = current bitrate 93784923 bits of payload data (165.546368 kbps) 11732617 bytes of payload data (165.680544 kbps) 76013 bits wasted from partially-full bytes (0.134176 kbps) 12513349 bytes of MP3 data (176.705544 kbps) = minimum bitrate possible 777 bytes of padding (0.010972 kbps) 417 bytes outside MP3 frames (0.005889 kbps) 1 sync error Bitrate distribution: 32: 9,0 128: 3641,0 160: 7691,0 192: 6700,0 224: 2736,0 256: 785,0 320: 125,0 Largest frame uses 8478 bits = 1060 bytes = 324.548437 kbps Smallest bitrate for CBR is 256
Using the --ib option will only print the smallest possible CBR bitrate, with no other information.
*** "test/APS.mp3"
MPEG1 layer 3
21687 frames
44100 Hz
38.281250 frames per second
566.517551 seconds
12514543 bytes in file (176.722405 kbps)
-s
and -t
options.12514126 bytes in MP3 frames (176.716516 kbps) = current bitrate
93784923 bits of payload data (165.546368 kbps)
11732617 bytes of payload data (165.680544 kbps)
76013 bits wasted from partially-full bytes (0.134176 kbps)
12513349 bytes of MP3 data (176.705544 kbps) = minimum bitrate possible
777 bytes of padding (0.010972 kbps)
417 bytes outside MP3 frames (0.005889 kbps)
1 sync error
32: 9,0
128: 3641,0
160: 7691,0
192: 6700,0
224: 2736,0
256: 785,0
320: 125,0
Largest frame uses 8478 bits = 1060 bytes = 324.548437 kbps
Smallest bitrate for CBR is 256
-z
switch may reduce the minimum, but will never increase it.In normal operation, mp3packer will iterate over the input frames and choose the smallest frame size which can store all the data needed. It will therefore minimize the file size by ensuring that the frames are as the smallest possible. This is actually somewhat difficult, as the frame size depends on how much of the current frame's data can be stored in previous frames, and how much space in the current frame is necessary to store data from following frames.
Whereas the default operation is to choose the minimum frame size to fit the data, using the -z
switch will also minimize the data size. This is completely lossless as long as the input file has no errors, and is equivalent to decompressing a ZIP file and recompressing with a more aggressive setting. It attempts to minimize the data by doing a brute-force search for the optimal parameters, so it takes much longer than it would normally.
Setting the -b
switch will set the minimum bitrate for each frame. Using this switch will make more room in small frames for other frames' data, so it will also generally reduce the maximum bitrate as well. There is no direct control over the maximum bitrate, since there may simply be too much data to fit into a smaller frame. The exact format of the parameter is a bit odd: if the bitrate given is a valid frame bitrate, the minimum bitrate is dithered between padded and unpadded frames. If the bitrate is one more than a valid frame bitrate, then the minimum is a padded frame of bitrate one less than the given. Anything else is rounded up to the next highest unpadded bitrate. An example table may be simpler to follow, assuming a 32, 44.1, or 48kHz file:
Parameter given to -b: | Resultant minimum frame size: |
---|---|
0-31 | unpadded 32kbps |
32 | exactly 32kbps |
33 | padded 32kbps |
34-39 | unpadded 40kbps |
40 | exactly 40kbps |
41 | padded 40kbps |
42-47 | unpadded 48kbps |
48 | exactly 48kbps |
49 | padded 48kbps |
50-63 | unpadded 64kbps |
64 | exactly 64kbps |
65 | padded 64kbps |
... | ... |
The "exact" bitrates are as follows:
32000, 44100, or 48000kHz: | 32 | 40 | 48 | 56 | 64 | 80 | 96 | 112 | 128 | 160 | 192 | 224 | 256 | 320 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Everything else: | 8 | 16 | 24 | 32 | 40 | 48 | 56 | 64 | 80 | 96 | 112 | 128 | 144 | 160 |
If an exact bitrate is given, the minimum bitrate will switch between unpadded and padded frames as needed in order to achieve exactly that bitrate. For 8, 12, 16, 24, 32, and 48kHz files, this uses all unpadded frames.
After mp3packer has chosen an output bitrate for a given frame, there is generally a range of positions to put the actual data. The data can be packed as much as possible into the previous frame, or it can be set to fill up the current frame as much as possible.
The default is to pack as far behind as possible if the -b
switch is not given, since there is usually no problem filling up the frames. If a minimum bitrate is specified then the frames are pushed as far up as possible without affecting any of the following frames.
The -r
switch will attempt to always push data as far up as possible, even if a minimum bitrate is not specified. Conversely, the -R
switch will push the data into previous frames as possible (note that this was the default behavior before 1.16).
Note that these options do not affect file size or compatibility at all. It will only change the internal layout of the data in the frames.
--copy-time
did not work with Unicode filenames.-z
processing can go 2-3x faster than 2.01 with quad-core processors.-z
processing to be multi-threaded and use SSE if available.-z
to deal with overflows better-z
) errors, and make all errors displays a bit more user-friendly.--nice
option, for changing the program's priority.-z
switch. It now goes ~40% slower, but manages a bit of extra compression. This change is most apparent with low-bitrate encodes.-i
switch. No longer prints a bunch of garbage for every frame, and the number of bits wasted is no longer negative.-r
and -R
options to control bit reservior minimization.-z
now works with MPEG-2 files.-z
outputting larger frames than the input.-z
switch when the errors had no effect on anything.-z
which showed up mainly for high-bitrate iTunes encodes.-z
option for brute-force Huffman table searching.-i
mode, and prints sync/buffer errors if they occur in normal mode.-w
switch to throw out entire frames if only one granule has a buffer error. This mirrors what Foobar does upon encountering a broken frame.-u
switch to update the original file and keep a backup of the old file.