MKV tags with target type value 50

Tags for mkv files added via mkvpropedit don’t get set up with specific target detail if input tag has a target type value of 50.

If you use mkvextract on a file that’s been tagged using mkvpropedit this way, then the extracted output xml file will show <Targets /> rather than 50, even though the target type value 50 was explicit in mkvpropedit input tag xml file.

Steps to reproduce.

Take a copy of a Matroska video file, name it Test.mkv

Remove all its tags: mkvpropedit Test.mkv --tags all:

Create an input tag xml file as follows:

<Tags>
  <Tag>
    <Targets>
      <TargetTypeValue>50</TargetTypeValue>
    </Targets>
    <Simple>
      <Name>PART_NUMBER</Name>
      <String>01</String>
    </Simple>
  </Tag>
</Tags>

Name it TestTagsIn.xml

Add tags into Test.mkv using mkvpropedit: mkvpropedit Test.mkv --tags global:TestTagsIn.xml

Extract tag information from Test.mkv using mkvextract: mkvextract Test.mkv tags TestTagsOut.xml

The output xml looks like this:

<?xml version="1.0"?>
<!-- <!DOCTYPE Tags SYSTEM "matroskatags.dtd"> -->
<Tags>
  <Tag>
    <Targets />
    <Simple>
      <Name>PART_NUMBER</Name>
      <String>01</String>
      <TagLanguageIETF>und</TagLanguageIETF>
    </Simple>
  </Tag>
</Tags>

In other words, the input target type value of 50 has gone, along with xml file’s surrounding (opening and /closing) <Targets> and <TargetTypeValue> tags.
All being replaced with <Targets />

The same thing happens when using mkvmerge.

Is this deliberate?

With level 50 being the most common tag grouping level (ie. movie /episode level) for Matroska video, is <Targets /> intended to represent the idea of an unspecified target type value level being taken somehow as the ‘default’ level?

If so, this notion of a default target type level being assumed rather than being explicitly set doesn’t seem to be in the Matroska specification.

Welcome!

The value 50 is the default value for the element TargetTypeValue. What this means is that it may be left out when writing if the parent element (Targets) is written. Or to put it differently, when a reader reads its parent element Targets but no TargetTypeValue element beneath it, it MUST act as if it were present & set to its default value, effectively using its default value 50.

Semantically, the following two are identically:

<Targets>
  <TargetTypeValue>50</TargetTypeValue>
</Targets>
<Targets></Targets>
<Targets/>

The third variant is just an XML idiosyncrasy; it’s just a shorthand for the second variant & has nothing to do with Matroska.

You can find all elements and their default values in the Matroska elements spec. The column labeled “Default” is the one with the default value. The legend at the top contains a concise description of what “Default” means, basically what I wrote above, just very short.

I thought it might be something like that.
I’d read through the Tagging section of the spec.
But hadn’t gone through the Element specification table.
Thanks for the pointer.

Windows (Windows 10 at least) maps PART_NUMBER TargetTypeValue=50 tag to System.Media.EpisodeNumber so it displays in Windows File Explorer as Episode number.
Windows seems to recognise the absence of TargetTypeValue, interpreting it as the default value nicely too.

However, I’m currently also using Icaros, as this handles some additional properties such as Year, Contributing artists, and Rating, as well as the display of Frame width and Frame height, which are not natively handled (or not handled well) in Windows.

With Icaros properties activated Episode number disappears if the PART_NUMBER tag doesn’t have TargetTypeValue explicitly set to 50.

I’ll get in touch with its developer and see if Icaros functionality can be changed to properly recognise and take account of the default level.

Yeah, that sounds like a bug in Icaros. Filing a report with them is absolutely the right thing to do.