exiv2 icon indicating copy to clipboard operation
exiv2 copied to clipboard

Extracting metadata from meta box in a mp4/mov file (advice needed)

Open nkming2 opened this issue 1 month ago • 4 comments

exiv2 is not extracting data from the meta box which contain valuable info. Many of these data are often not available in the output of exiv2 right now.

For example in a mov file taken with an iPad, these data are available in the meta box:

  • mdta.com.apple.quicktime.location.accuracy.horizontal: 0.00000
  • mdta.com.apple.quicktime.location.ISO6709: +0.0000+0.0000/
  • mdta.com.apple.quicktime.make: Apple
  • mdta.com.apple.quicktime.model: iPad (99th generation)
  • mdta.com.apple.quicktime.software: 0.0.0
  • mdta.com.apple.quicktime.creationdate: 2020-11-22T11:22:33+0100

(values are modified for privacy reason)

If I run exiv2 (main branch) with this file, GPS data, device model and OS version are missing from the output. Even creationdate could be useful due to the UTC offset info.

I've finished most of the work already, up to the point that I have a std map containing the above key value pairs. But I'm not sure how to move forward.

If I simply insert the key-value pairs to xmpData_, exiv2 will throw kerInvalidKey. I then tried to prefix it with "Xmp.", only to end up with kerNoNamespaceInfoForXmpPrefix. I guess exiv2 is doing some sort of validation on the output? If so, this will make things complicated because the keys used in the meta box are not standardized and every oem can put whatever they like inside. Maintaining a mapping like this would be... unfortunate.

nkming2 avatar Nov 30 '25 08:11 nkming2

If so, this will make things complicated because the keys used in the meta box are not standardized and every oem can put whatever they like inside. Maintaining a mapping like this would be... unfortunate.

It is indeed. Sounds like vendor MakerNotes all over again... 🙄 Maybe you can kindly ask the vendor to stick to standard metadata schemes?

Exiv2 so far supports only true Exif metadata (w/ limited support for vendor MakerNotes), IPTC, and XMP (w/ set/known/fixed schemas indeed): https://exiv2.org/metadata.html

Then there are "comment" (e.g. in JPEGs and PNGs), thumbnails, and ICC profiles, and that's about it.

These are all standard and documented. What you found doesn't sound like it fits into any of these categories/containers. (So far, you might only be able to make a specific conversion for creation date though to a standard Exif or XMP field.) Unless there is a QuickTime schema for XMP to be added and mapped?

kmilos avatar Dec 01 '25 10:12 kmilos

@nkming2 Exiv2 supports the metadata standards EXIF, IPTC, Xmp and ICC in about 20 different image formats (JPEG, PNG, TIFF, BMFF etc). It locates the data "blocks" for each standard and passes what it finds the the parser for that standard. I've documented and described this in my book. Specifically for BMFF formats: https://exiv2.org/book/index.html#BMFF

As you know, BMFF files can store unlimited data in boxes which are not known to code parsing the file.

In the case of XMP, Exiv2 locates the XMP data and passes it directly to the Adobe XMKsdk parser embedded in libexiv2. If your data (for example) quicktime.model is not in the XMP data, it will not be reported. It is similar for EXIF metadata which can encode GPS and other data. If GPS information is stored in other boxes in your file, Exiv2 has no knowledge of these boxes.

clanmills avatar Dec 02 '25 06:12 clanmills

Thanks for the replies!

@kmilos Custom conversion could be done to retrieve Xmp.video.Make, Xmp.video.Model, Xmp.video.Software, Xmp.video.GPSCoordinates from the iPad video example above, but yea they are non-standard AFAIK. BTW, I couldn't find the Xmp.video and Xmp.audio schema in https://exiv2.org/metadata.html, are they defined elsewhere? I'm asking because I want to submit a PR to extract the video track orientation info, but I need to know which "Xmp.video.xyz" I should be using.

@clanmills I actually built exiv2 with EXIV2_ENABLE_EXTERNAL_XMP set to OFF but I get the point.

So after some thoughts based on the inputs from you two, it seems to me that it's not a good idea to put this in upstream. There doesn't seems to be a proper way to support these non standard data and any potential hack would be too immature for upstream. I will have to keep this in my own fork though as I do need these data.

Thanks again! And also thanks for your hard work to maintain exiv2 👍

nkming2 avatar Dec 03 '25 16:12 nkming2

@nkming2 Thanks for your reply. Andreas talked several times replacing the Exif, IPTC, and XMP classes with "Unified Metadata Container". This would make it simpler to add new families of metadata to Exiv2. This would enable you to add a new "Family" of Metadata such a "BMFF". You could parse the image and populate the BMFF family as you see fit.

Andreas made a start on this about 2011. I rescued his branch and did some work on this in 2021. I believe the code compiles and works. I didn't complete the work in 2021 because the priority was to add BMFF support to Exiv2 v0.27.4. After that was released in June 2021, I retired because I was 70!

We're always looking for volunteers to join Team Exiv2. If you'd like to consider working on the "Unified Metadata Container", you'd be very welcome to join the team. Although I have retired, I will support you and help you to get up to speed. My contact information (email, website) is on my contributors page: https://github.com/clanmills.

If you're interested, please contact me by email as I have disabled GitHub notifications.

clanmills avatar Dec 03 '25 18:12 clanmills