MediaArea / MediaInfo

Convenient unified display of the most relevant technical and tag data for video and audio files.
https://MediaArea.net/MediaInfo
BSD 2-Clause "Simplified" License
1.38k stars 160 forks source link

Usable Chapter (Menu) JSON/XML output #706

Open gitoss opened 1 year ago

gitoss commented 1 year ago

One big adavantage of MediaInfo over for example ffprobe is the structured XML/JSON output.

Unfortunately, the format sems to be lacking concering chapters. An example of the current output (XML flavor, JSON is about the same):

<track type="Menu">
<StreamOrder>1</StreamOrder>
<ID>2</ID>
<Format>Timed Text</Format>
<CodecID>text</CodecID>
<Duration>12345.000</Duration>
<Language>en</Language>
<extra>
<Encoded_Date>2000-04-01 01:02:03 UTC</Encoded_Date>
<Tagged_Date>2000-04-01 01:02:03 UTC</Tagged_Date>
<Menu_For>1</Menu_For>
<_00_00_00_000>01. The Quest for XML</_00_00_00_000>
<_01_02_03_000>02. The Quest for JSON</_01_02_03_000>
</extra>
</track>

I'm unable to count the chapters, query the time codes and names - because the time codes are the key names, i.e. I have to know them which makes the whole exercise rather useless.

A usable format would be something like the OverDrive MediaMarkers (custom xml tags embedded in mp3 files). This is a structure I can xml query the number of elements inside the , and query each individual and

<Markers>
<Marker>
<Name>01. The Quest for XML</Name>
<Time>0:0:00.000</Time>
</Marker>
<Marker>
<Name>02. The Quest for JSON</Name>
<Time>01:02:03.000</Time>
</Marker>
</Markers>

You could adapt something similar for MediaInfo, maybe with the language added somewhere if there are multi-language chapter names - see https://github.com/MediaArea/MediaInfo/issues/226

gitoss commented 1 year ago

Thanks for helping out with the markdown code, I was just about to rtfm :-)

JeromeMartinez commented 1 year ago

We have now sub element also in the text/tree/etc views, it was not the case when we implemented this version, so should be easier now. But it still makes thing slightly different compared to other parts (1 element = 1 item).

Right now I think more to something like:

<Chapter time="01:02:03.000">02. The Quest for JSON</Chapter>

But does not resolve the issue with multiple languages.

gitoss commented 1 year ago

Right now I think more to something like

This would be fine if you want to stick to the 1 element rule.

For a more regular xml structure with a tag for the chapter name and chapter time code, you can have a look at the help file of the scripting language I use - which happen to have a xml sample that covers multiple languages: https://jpsoft.com/help/f_xmlgetattr.htm

Personally, I don't use multiple languages and haven't encountered multi-language chapter names yet - the simple ogg or cue chapter format is probably popular for a reason. Alas, if you want complicated, have a look at the matroska spec: https://www.matroska.org/technical/chapters.html