Urs Fleisch - 2018-12-01

Thanks for the suggestion. I also think that support for MKV in Kid3 would be useful. I even started implementing it later this year. I saw that there is MKV-Support in the taglib2 branch of TagLib, so I integrated this implementation to work with TagLib 1.x. Then I added the necessary code in Kid3.

Unfortunately, the MKV support in TagLib turned out to be unusable. One part of the problem is the implementation which seems to be unfinished and incomplete. It is not easy to integrate because Matroska-Tags are a bit different. They use different target types - to use the same element at different levels (e.g. track, album), and nested tags - to use elements in a different context (e.g. original, sort). Then there can be multiple such element trees.

All this would have to be mapped correctly into the model used by TagLib, but it supports just a few elements correctly and hides all the rest. It also seems to generate duplicate information and is not able to delete elements - they are just set to a void type. I would at least require that a file can be reverted to its original state when tags are added and later removed, just as a simple test, that nothing is corrupted. But this is not possible and it also seems to corrupt MKV files: After editing them with TagLib, they are reported to be corrupt when opened with MKVToolNix.

So after all this was unfortunately just a waste of time. I nevertheless have committed the changes into a separate branch with the following comment:

Add support for Matroska, not usable.

There are many problems with the current Matroska implementation in
TagLib 2:


- Not all tags are accessible, only the "best" are taken, so existing
  tags are no longer shown after new tags are set.
- It is not possible to set the TargetType of tags, which makes it
  impossible to implement certain frame types.
- It is not possible to use nested tags, which makes it
  impossible to implement certain frame types.
- Deleted frames are not deleted, just replace by a Void tag, they are
  still shown in mediainfo.
- After saving tags, the file is reported to be corrupt when opened with
  the header editor of MKVToolNix.

I do not expect that the situation in TagLib will change soon, comments about the MKV support by the original TagLib developer like "TagLib is for audio files only" are not the kind of message to motivate the author of the MKV code to improve the code. And there is not much activity in the development of TagLib since its last release, which was in October 2016.

I probably will retry implementing support for MKV, but this time using libebml. This will be a bit more effort than with TagLib because it will require the creation of a new metadata plugin and using a new library.