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.
in.mp3 according to
options and saves the output to
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).
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
options, if specified, may be any of the following:
-b 129will result in the smallest allowed frame size being a padded 128kbps frame.
-b 117will result in the smallest allowed frame size being an unpadded 128kbps frame. If
-b 128is 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.
-tto remove all tags.
-zswitch 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
-zswitch 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.
-zprocessing. 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.
mp3packer -a "-food" in.mp3is given, the output will be named
"-vbr"is the default.
-astring 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.
mp3packer -u process.mp3 backup.mp3, the file
process.mp3will contain the packed mp3, and
backup.mp3will be the same as the original
process.mp3. Note that if you don't specify an output file or change the
-aoption, the original will have
"-vbr"appended to it, which may lead to confusion.
-bswitch is used. The
-rswitch will force minimization all the time, and the
-Rswitch 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.
outwill only keep the output file and will delete the input file, whereas
bothwill keep both files (the default)
inwill only leave the input file and will discard the repacked file.
outdoes just the opposite.
bothkeeps both files (default). Note that buffer under/overflows and sync errors are counted as errors, whereas recompression errors (if using the
-zswitch) are not.
-uoption, it will force overwriting the backup file.
-zswitch. 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, but print only the minimum CBR bitrate.
|Name||High||Above normal||Normal||Below Normal||Idle|
--nicewith 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 inwill report frame statistics about the input file.
--debug outwill report on how the file was processed and written.
--debug huffwill print debug information about the recompression of frames if the
-zoption is given.
--debug alldoes 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.
MPEG1 layer 3
38.281250 frames per second
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
Largest frame uses 8478 bits = 1060 bytes = 324.548437 kbps
Smallest bitrate for CBR is 256
-zswitch 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.
-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:|
The "exact" bitrates are as follows:
|32000, 44100, or 48000kHz:||32||40||48||56||64||80||96||112||128||160||192||224||256||320|
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.
-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-timedid not work with Unicode filenames.
-zprocessing can go 2-3x faster than 2.01 with quad-core processors.
-zprocessing to be multi-threaded and use SSE if available.
-zto deal with overflows better
-z) errors, and make all errors displays a bit more user-friendly.
--niceoption, for changing the program's priority.
-zswitch. It now goes ~40% slower, but manages a bit of extra compression. This change is most apparent with low-bitrate encodes.
-iswitch. No longer prints a bunch of garbage for every frame, and the number of bits wasted is no longer negative.
-Roptions to control bit reservior minimization.
-znow works with MPEG-2 files.
-zoutputting larger frames than the input.
-zswitch when the errors had no effect on anything.
-zwhich showed up mainly for high-bitrate iTunes encodes.
-zoption for brute-force Huffman table searching.
-imode, and prints sync/buffer errors if they occur in normal mode.
-wswitch to throw out entire frames if only one granule has a buffer error. This mirrors what Foobar does upon encountering a broken frame.
-uswitch to update the original file and keep a backup of the old file.