In Mp3 when metadata becomes shorter we dont reclaim the space instead just left as padding

Issue #301 closed
Former user created an issue

Hi IJabz,

is there any solution for the problem described here: https://stackoverflow.com/questions/12841454/java-jaudiotagger-mp3-wrong-id3-tag-size

Deletion of artwork or setting a new smaller artwork does not reduce the file size. Is it a bug?

Here a code sample of mine:

            MP3File audioMP3 = (MP3File)AudioFileIO.read(isource);
            Tag tagMP3 = audioMP3.getTag(); 

            ID3v24Tag v2Tag = audioMP3.getID3v2TagAsv24();
            if(v2Tag==null){
                v2Tag = new ID3v24Tag();
            }
            if(tagMP3.getFirstArtwork() != null){
                Artwork artNew = resizeAlbumArtwork(tagMP3.getFirstArtwork(), iwidth, iheight);
                try{
                    v2Tag.deleteArtworkField();
                    v2Tag.setField(artNew);
                }catch(Exception e){ }
                audioMP3.setID3v2Tag(v2Tag);                
                audioMP3.commit();
            }

Thank you for your help!

Michael

Comments (4)

  1. IJabz repo owner

    Its useful to have padding because when user adds data next time they can then write the metadata wihtout having to shift (and hence rewrite) all the audio data.

    But we should reclaim the space on write if TagOptionSingleton.getInstance().isId3v2PaddingWillShorten() is set to true

  2. Log in to comment