Reputation: 66995
How to read the metadata of a MKV movie files in C# (or C or C++ or AS3)?
for example such
creator
metadatacreator
hasKeyframes
hasVideo
hasAudio
hasMetaData
canSeekToEnd
duration
datasize
videosize
videocodecid
audiosize
audiocodecid
audiosamplerate
audiosamplesize
stereo
filesize
lasttimestamp
lastkeyframetimestamp
lastkeyframelocation
keyframes (filepositions, times)
width
height
framerate
videodatarate
audiodatarate
Upvotes: 7
Views: 13887
Reputation: 1620
In 2024, I have a similar question. I wanted to extract arbitrary tracks from an mkv file based on mkvinfo
's output data (EBML?). Was about to write a kludgy parser to get what I needed from that output, when I discovered mkvmerge
outputs the same info as json
.
mkvmerge --redirect-output "myMkv-info.json" --identification-format "json" --identify myMkv.mkv
Almost every programming language can parse json to hashmap/dictionary/object. Or use the jq
utility to extract only the data you need.
More details: mkvmerge --identify
Upvotes: 1
Reputation: 1222
I recently posted C# version to https://github.com/OlegZee/nebml. It contains Title editor sample which demostrate inline editing of certain properties.
Upvotes: 3
Reputation: 1243
The simplest way to get a lot of this is to spawn an instance of mkvinfo
and parse its output. One problem with what you are asking is that a Matroska file can have an unlimited number of video and audio streams. So you would have to enumerate the streams in the file prior to getting these properties.
Upvotes: 0
Reputation: 11
You might try asking this over at doom9 forums in their development section. Also mediainfo.dll might also work for you.
Upvotes: 1
Reputation: 14234
There is always attempting to parse the header yourself.
Also I've seen references to the EBML library being used to decode MKV files. Good luck!
Upvotes: 5