Zeugma440 / atldotnet

Fully managed, portable and easy-to-use C# library to read and edit audio data and metadata (tags) from various audio formats, playlists and CUE sheets
MIT License
442 stars 60 forks source link

MP4/M4A : Support for writing certain chapters without images #163

Closed Zeugma440 closed 10 months ago

Zeugma440 commented 1 year ago

The problem

Given a unit test that saves :

To store that inside an ID3v2 structure, we'd describe two chapters, respectively starting at 0:01 and 0:10, one without picture and the other with a picture, and that would fit without issues.

This is very different with an MP4 structure, as :

As a consequence, a timespan when there's no displayed picture cannot be described in an MP4 structure. Reading the file generated in the unit test results in finding the wood picture associated with the first chapter (as both appear at index 0 and are assumed starting at 0:00), and no picture associated with the second chapter.

Potential solution

Auto-generate a blank picture and insert it on chapters with no declared picture to maintain titles and pictures ordered the very same way... but creating media out of thin air sounds real messy. I'd rather stick to creating warnings in the log imho.

Follow-up from @CooPzZ _I'm thinking in editing this actually makes sense to do now - it should be minimal bytes for a blank image, but the added images are where you put them. But, only do this if there is min 1 image added to a chapter somewhere. You could still show it as a null image when viewed in ATL if your blank image is used. This is better for making sense while editing and outputs as expected. If not the Warning needs to describe what happened.

Otherwise I think, instead of the warning, an Error needs to occur to prevent adding without images on some chapters as the format doesn't support it and they won't go to the expected chapter, if not done in a row from chapter 1. I'd call that fair in that you are all in or not because of the format._

Zeugma440 commented 10 months ago

Solved that issue by inserting a 1x1 black image on any chapter without picture if at least one chapter has a user-defined picture.

The picture is a 734-bytes-long JPG created in the library's resources. BMP and PNG would be smaller in size but don't work when viewing chapters in VLC.

Zeugma440 commented 10 months ago

Available on today's v5.06