Extensible Binary Meta Language (EBML)
Extensible Binary Meta Language (EBML) is a generalized file format for any kind of data, aiming to be a binary equivalent to XML. It provides a basic framework for storing data in XML-like tags.
It was originally developed for the Matroska audio/video container format.
EBML提供一种基本的框架在XML中存储数据,就像tags一样。
最开始就是为MKV容器进行设计的。
EBML was designed to be a simplified binary extension of XML for the purpose of storing and manipulating data in a hierarchical form with variable field lengths.
EBML可以存储变长数据。
EBML是一种类似于XML格式的可扩展二进制元语言,使用可变长度的整数存储,以节省空间。
EBML基本元素结构:
typedef struct {
vint ID // EBML-ID
vint size // size of element
char[size] data // data
} EBML_ELEMENT;
Element IDs (also called EBML IDs) are outlined as follows, beginning with the ID itself, followed by the Data Size, and then the non-interpreted Binary itself.
Simple Diagram
注: 下文中所用分析工具MKVToolNix
地址: https://www.videohelp.com/software/MKVToolNix
MKV文件由EBML Header和Segment构成。
主结构展开:
Simple Diagram
Header
Meta Seek Information
The Metaseek section contains an index of where all of the other groups are in the file are located, such as the Track information, Chapters, Tags, Cues, Attachments, and so on.
This element isn't technicaly required, but you would have to search the entire file to find all of the other Level 1 elements if you did not have it.
This is because any of the items can occur in any order. For instance you could have the chapters section in the middle of the Clusters. This is part of the flexibility of EBML and Matroska.
该部分包含一个其它group的索引,存储这些group在文件中的位置。
比如Track information, Chapters, Tags, Cues, Attachments等group。
Segment Information
可以看到包括timestamp scale和duration等信息。
Track
The Track section has basic information about each of the tracks.
For instance, is it a video, audio or subtitle track?
What resolution is the video?
What sample rate is the audio?
The Track section also says what codec to use to view the track, and has the codec's private data for the track.
包含每个轨道的基本信息。比如是视频轨道还是音频轨道,比如分辨率是多少,比如音频的采样率是多少等等等。
Chapters
The Chapters section lists all of the Chapters. Chapters are a way to set predefined points to jump to in video or audio.
Clusters
The Clusters section has all of the Clusters. These contain all of the video frames and audio for each track.
最重要的部分。所有的视频帧 音频帧都在这里。
里边可以看到非常重要的时间戳信息。
还可以通过track number判断当前帧属于视频还是音频等。
Cueing Data
The Cueing Data section contains all of the cues.
Cues are the index for each of the tracks.
It is a lot like the MetaSeek, but this is used for seeking to a specific time when playing back the file. Without this it is possible to seek, but it is much more difficult because the player has to 'hunt and peck' through the file looking for the correct timecode.
用于快速seek。
Attachment
The Attachment section is for attaching any type of file you want to a Matroska file.
You could attach anything, pictures, webpages, programs, even the codec needed to play back the file. What you attach is up to you. (Someone might even want to attach an Ogg, or maybe another Matroska file some day?!?) In the future we want to come up with a standard way to label things like an album cover of a CD.
此部分可以放置任意格式的文件。比如图片,网页,程序等。
Tagging
The Tagging section contains all of the Tags that relate to the the file and each of the tracks. These tags are just like the ID3 tags found in MP3's. It has information such as the singer or writer of a song, ctors that were in the video, or who made the video.
References:
https://en.wikipedia.org/wiki/Extensible_Binary_Meta_Language
http://matroska-org.github.io/libebml/
https://blog.csdn.net/lxmnet123/article/details/10741935
https://matroska.org/technical/diagram/index.html
https://matroska.org/technical/specs/index.html
https://www.videohelp.com/software/MKVToolNix
https://blog.csdn.net/qq_32430349/article/details/50363375
网友评论