Unable to find next atom because identifier is invalid ��������

Issue #277 new
Former user created an issue

I get the error in the title when I try to add tags to an m4a created with Android MediaCodec. Any ideas?

Android version 8

jaudiotagger version jaudiotagger-2.2.6-SNAPSHOT

Sample file attached

Code Used

public static void updateTitleAndMeta(File file, IDTagPackage idTagPackage) {
        if (file.exists()) {
            try {
                AudioFile audioFile = AudioFileIO.read(file);
                if (audioFile != null) {
                    TagOptionSingleton.getInstance().setAndroid(true);
                    TagOptionSingleton.getInstance().setId3v2PaddingWillShorten(true);
                    Tag tag = audioFile.getTagOrCreateAndSetDefault();
                    tag.setField(FieldKey.TITLE, idTagPackage.getId3tagTitle());
                    String currentArtist = tag.getValue(FieldKey.ARTIST, 1);
                    if (TextUtils.isEmpty(currentArtist)) {
                        if (tag.getFirstField(FieldKey.ARTIST) == null) {
                            tag.createField(FieldKey.ARTIST, idTagPackage.getId3tagArtist());
                        } else {
                            tag.setField(FieldKey.ARTIST, idTagPackage.getId3tagArtist());
                        }
                    }

                    String currentAlbum = tag.getValue(FieldKey.ALBUM, 1);
                    if (TextUtils.isEmpty(currentAlbum)) {
                        if (tag.getFirstField(FieldKey.ALBUM) == null) {
                            tag.createField(FieldKey.ALBUM, idTagPackage.getId3tagAlbum());
                        } else {
                            tag.setField(FieldKey.ALBUM, idTagPackage.getId3tagAlbum());
                        }
                    }

                    String currentComment = tag.getValue(FieldKey.COMMENT, 1);
                    if (TextUtils.isEmpty(currentComment)) {
                        if (tag.getFirstField(FieldKey.COMMENT) == null) {
                            tag.createField(FieldKey.COMMENT, idTagPackage.getId3tagComment());
                        } else {
                            tag.setField(FieldKey.COMMENT, idTagPackage.getId3tagComment());
                        }
                    }

                    /*
                    Don;t update the year as it might be recorded before
                    tag.setField(FieldKey.YEAR, idTagPackage.getId3tagYear());
                    */

                    AudioFileIO.write(audioFile);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    }

Thank you

Comments (4)

  1. IJabz repo owner

    Tried this, actually the error occurs when you read the file not when you write it. The problem is under the ilst tag there is an invalid atom, it may be better in such a case for us to just ignore the bad metadata under the ilst atom so the file can be read and then subsequently written,

  2. WiZU&Me

    “it may be better in such a case for us to just ignore the bad metadata under the ilst atom”

    My question is: how to ignore the read error to get the audiofile?

    Thank you.

  3. Dan Gravell

    I’ve noticed this quite a bit. @IJabz do you think simply ignoring this is the best way to go?

  4. Dan Gravell

    I was looking at the file supplied - it looks like the problem is that hdlr atom defines a length of 33, suggesting it is a parent of mdta . However mdta doesn’t define a length. It looks like the file is genuinely corrupt to me, not just having an atom we don’t like…

  5. Log in to comment