Cannot add tag to mp4 file using Fragmented FIle Format

Issue #249 new
Andreas Kromke created an issue

I have a problem with a file downloaded from Youtube. It does not have any mp4 tags, and jaudiotagger (master branch, not a release version) fails to create them using getTagOrCreateAndSetDefault(). To be more precise: commit() fails with the mentioned error messages.

When I add a tag for "title" using kid3, jaudiotagger is able to add additional tags.

I currently have not the time to deeply look into the sources, unfortunately, and I do not have any knowledge about mp4 tags, otherwise I would have tried to find the root problem. Sorry.

Error messages:

02-23 16:28:29.790 28972 28972 E mp4     : Writing:Option 5.1;No udta atom
02-23 16:28:31.555 28972 28972 E generic : Cannot make changes to file /storage/emulated/0/Music/NewPipe/Soundtrack.m4a because Unable to make changes to Mp4 file, incorrect offsets written difference was -97
02-23 16:28:31.555 28972 28972 E generic : org.jaudiotagger.audio.exceptions.CannotWriteException: Unable to make changes to Mp4 file, incorrect offsets written difference was -97
02-23 16:28:31.555 28972 28972 E generic :     at org.jaudiotagger.audio.mp4.Mp4TagWriter.checkFileWrittenCorrectly(Mp4TagWriter.java:827)
02-23 16:28:31.555 28972 28972 E generic :     at org.jaudiotagger.audio.mp4.Mp4TagWriter.write(Mp4TagWriter.java:609)
02-23 16:28:31.555 28972 28972 E generic :     at org.jaudiotagger.audio.mp4.Mp4FileWriter.writeTag(Mp4FileWriter.java:42)
02-23 16:28:31.555 28972 28972 E generic :     at org.jaudiotagger.audio.generic.AudioFileWriter.write(AudioFileWriter.java:400)
02-23 16:28:31.555 28972 28972 E generic :     at org.jaudiotagger.audio.AudioFileIO.writeFile(AudioFileIO.java:489)
02-23 16:28:31.555 28972 28972 E generic :     at org.jaudiotagger.audio.AudioFileIO.write(AudioFileIO.java:212)
02-23 16:28:31.555 28972 28972 E generic :     at org.jaudiotagger.audio.AudioFile.commit(AudioFile.java:115)

Comments (3)

  1. IJabz repo owner

    If its YouTube probably contains a video tag and jaudiotagger only designed for audio tags, so I expect the bug (and it is a bug) is related to that.

  2. Andreas Kromke reporter

    Yes, you might be right.

    I recently found out that this issue occurs with any m4a file downloaded with NewPipe. NewPipe is an Android program available in F-Droid and kind of alternative to the official YouTube application. Unfortunately NewPipe did not offer the mp3 format as alternative, so there is no way avoiding m4a here.

    Update:

    By tedious studies of mp4 format descriptions and examination of the failing files I found out that NewPipe stores fragmented mp4 files. For more information see here. It seems that Mp4TagWriter.java has not been designed to handle these files, as 'mdat' is always referred to as a single one, not an array. Further, I could not find any 'sidx' atom handling, except its definition in Mp4AtomIdentifier.java.

    Specification can be found here: ISO

    There is also already an issue (still open) in NewPipe explicitly describing the phenomenon: Issue 469

    By the way: File starts with "ftyp dash".

  3. Log in to comment