Reading and writing metadata

This is a noob question, but I am trying to extract the tags and headers from a large number of videos, edit them and then rewrite them into the file.

I’ve tried using mkvinfo for this, but the output format is quite different to the xml, and also contains things that have seemingly been added for human readability that might not be wanted for writing (e.g. default duration containing an fps conversion). Preferably, I would like to have the output of the metadata in the same format that it will be written in by mkvpropedit to remove the risk of unintented changed being introduced by parsing. mkvextract does have a way to output tags as an xml file, but does not seem to do this for the headers of individual tracks.

How would I go about doing this?

Welcome!

mkvextract & mkvpropedit together can be used for chapters & tags, you’re on the right track there. However, mkvextract cannot extract the segment information nor the track headers as files, and likely never will. On top of that mkvpropedit cannot use files for track header level information; you’ll have to use individual options for that.

If you want machine-parseable information for track headers, use mkvmerge in its JSON identification mode, mkvmerge --identification-mode json --identify yourfile.mkv or its shortcut mkvmerge -J yourfile.mkv

Thanks. So I’d have to iterate over the headers and set each one with an individual call to mkvpropedit?

No, you can update multiple items within the same call. The documentation contains several examples that operate on multiple properties. You can even combine all operations in a single call, including editing properties of various tracks, replacing chapters & tags.

There just isn’t a file format for track headers similar to how there are file formats for chapters & tags.

Thanks. I’ll give that a go then.