Multiple mkv attachments problem

Started by Mammut, August 08, 2022, 01:20:02 AM

Previous topic - Next topic

Mammut

Hi,

when I have multiple attachments in a Matroska .mkv file (separate big and small covers for portrait and for landscape, etc.), the info is completely missing from the Json.

If I have only one attachment, like only one cover, there are keys:

    "AttachedFileName": {
      "id": 1646,
      "table": "Matroska::Main",
      "val": "cover.png"
    },
    "AttachedFileMIMEType": {
      "id": 1632,
      "table": "Matroska::Main",
      "val": "image/png"
    },
    "AttachedFileUID": {
      "id": 1710,
      "table": "Matroska::Main",
      "val": "9372697806095038983"
    }

When there are multiple attachments, these keys are completely missing.

My command line:
exiftool.exe -j -g1 -struct -t -a a.mkv

Maybe there is an option for this?

Thank you!

Phil Harvey

#1
I'm guessing this is the reason (from the -j option documentation):

            The -a option is implied when -json is used,
            but entries with identical JSON names are suppressed in the
            output.  (-G4 may be used to ensure that all tags have unique JSON
            names.)


- Phil

Edit:  Since you are already using -g1, you could try something like -g1:4
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Mammut

Thanks, Phil, I tried it, but unfortunately those keys are missing regardless of the -g1:4 option.

By the way, I just noticed that the "AttachedFileData" key is always missing, even if there is only one attachment: if it's a png file and not a jpg attachment.
I tried the "-api requestall=3" option, but it doesn't help this time.

I would upload these files, but they are bigger then 10 gb. :(

Phil Harvey

If you could generate a smaller sample I could take a look.

Otherwise, seeing the output of the -v3 option may help.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Mammut

Well, this is more stranger. :)

I managed to cut the mkv with the splitting option of mkvtoonix and I found the "culprit".

I added attachments with the Header Editor in mkvtoolnix earlier because it's faster for testing.

But I completely remuxed the video for the cutting now and exiftool gives all the keys now for multiple attachments. So it's working without a problem with fully remuxed videos.
(I tried complete remuxing with only one png, too, and exiftool gives the "AttachedFileData" key, as it should.)

So something is wrong with the Header Editor part of mkvtoolnix, or at least it creates a different .mkv file. It saves the data, but it will be wrong in exiftool.

The strange thing is that I can add one jpg file in Header Editor and it works fine in exiftool, too, it lists all the attachment keys.

But when I add one png file (or more files) in Header Editor, all keys are missing.

I attached such an .mkv file to my post. It was saved in mkvtoolnix's Header Editor.

If you open it in mpc, you can see and export the cover.png, and mkvtoolnix can see it, too. So it's there somewhere but exiftool can't see it, or at least it doesn't list it in the Json output.

Phil Harvey

Got it.  The tags aren't extracted because they are stored after the first Cluster in the attached file.  You need to add the -U (capital "U") option to extract these.  I must have had a good reason to do it this way, but I don't recall exactly why (probably because all of the important metadata came before the first Cluster in my sample files).

I'll look into changing this so the -ee option also extracts this information.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Mammut

Thanks, Phil, the -U is working.

Although it works for a long time if it's a bigger mkv file (it was about half a minute on my machine with a 2-3 gb mkv and I started a 30 gb one about three minutes ago and it still didn't finish).

I guess that mkvtoolnix's Header editor simply adds the info at the end, so maybe there could be an option to look before the first cluster and after the last one? I think maybe it could be faster.

Phil Harvey

Yes, the aim was to avoid long delays like this.  Could you attach the -v3 output for one of your large files?  This would be useful.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Mammut

Yes, I made a change in Header editor on a 2gb mkv to add a png cover and ran exiftool on that.
But the -v3 output is 95 mb, so I link it.

v3 output


Phil Harvey

This helps, thanks.

Wow. I don't think I've ever seen a -v3 output this large.

I'll update ExifTool 12.45 so the -ee option skips over the Cluster information, which should speed things up quite a bit compared to the -U behaviour which reads into the Cluster.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Mammut


Phil Harvey

Just a heads up:  With ExifTool 12.52 I plan to give meaningful names to the MKV tags, so instead of looking like this:

    "TagName": {
      "id": 1443,
      "table": "Matroska::Main",
      "val": "_STATISTICS_TAGS"
    },
    "TagString": {
      "id": 1159,
      "table": "Matroska::Main",
      "val": "BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES"
    },

the output will look like this:

    "StatisticsTags": {
      "id": "_STATISTICS_TAGS",
      "table": "Matroska::Tags",
      "val": "BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES"
    },

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).