FeRD - 2013-06-10

(Ancient issue, but since it's still open here...)

I believe that's proper behavior. It's somewhat unfortunate, but due to the way the MP3 file format is specified that's likely the best way for mp3val to handle the situations you describe.

The key issue is that frames are delimited only by a start header, and not an end marker. So, the way mp3val (or any parser) identifies the end of a given frame is by finding the start of the next frame. If it finds something other than a frame header where it expects to find one, then it has to assume the frame has been corrupted.

So, by adding in garbage characters at a position where there should be a frame header, you're effectively corrupting the last frame. Or, to put it another way, imagine that instead of appending two bytes of garbage, you'd replaced the last 500 bytes of the file with 502 bytes of garbage, so that the last frame really is corrupted. I don't believe there's any easy/reliable way for mp3val to tell the difference, at least in the general case, so in both situations it's forced to assume the worst about that last frame.