QUOTE(RogerG @ Mar 9 2007, 19:17)

sometimes out is larger than in. Could you make an option to not overwrite in if out is larger?
The only time the output is larger than the input should be when the only thing that's added is the LAME header. In this case the file is only ~500 bytes larger. I suppose that any increase is bad, but I figured that 500 bytes is not enough to worry about. I can look into not using the output file if it's larger, but if it's hard I don't think I'll bother.
Have you seen any files that get larger than about 500 bytes? If so, then that's probably a bug.
QUOTE
What do you think about an option to remove space padding from id3v2 tags? This would decrease file size even more.
I try to avoid id3 tags altogether, especially id3v2. It's quite a nasty tagging spec, and judging by the files that I get, it tends to get broken quite a bit. (And I'd have to implement yet another CRC generator... not fun)
QUOTE
What will happen to my file if there are buffer errors?
That depends on what options you have set. By default both the output and input files will be kept, and a warning will be displayed. If you change the
--keep-bad option, various things happen:
--keep-bad in: Keeps only the input file. Good for only repacking the files without errors
--keep-bad out: Keeps only the output file. Good if you want to repack all the files no matter what
--keep-bad both: Default. Won't delete either file.
Similarly, the
--keep-ok switch determines which files to keep when no errors occur.
Note also that if you use the
-u switch, the
output file will be the same name as the original input, whereas the
input file will be renamed something else.
QUOTE
Why does it corrupt my files ("buffer underflow; frame 0 will be truncated", "WARNING: buffer underflow; frame 0 will be entirely replaced with silence") ? Not sure if it does but the warnung messages don't sound well. How can your program be lossless if it inserts silence into my files?
That warning, when you see it only on the first few frames, generally means that the file was split improperly. The data for that frame doesn't exist in the file, so the only thing that can be done to make it normal again is replace it with a frame which is silent.
The warning message is telling you that the input file is bad, not that the processing did something horrible to the file.
When a bitstream error occurs, you are right that mp3packer is no longer lossless on that frame, but only because the data is already lost and mp3packer has to "recreate" it.
For example, if half of a frame is cut off, you can do a few things:
- Pad the frame with zeros and decode like normal (tends to be completely wrong)
- Start decoding from the beginning of the valid data (also generally completely wrong, as there is no way to tell how far into the frame the valid data starts)
- Only keep the parts of the frame which have no missing data, and set the rest of the frame to silence (what mp3packer does by default; usually the best-sounding option)
- Replace the whole frame with silence (what mp3packer does if the -w option set; saves a bit more space sometimes)
There is basically no "lossless" way to even read the mp3 data, as some of it is already lost!
However, all frames which do not produce a warning message should be lossless. If not, there's something wrong.