# Matroska

**Matroska**是一种开放的多媒体容器格式，可将视频、音频、字幕、章节、附件和元数据打包进单个文件，最常见的形态是扩展名为 `.mkv`（视频）、`.mka`（音频）和 `.mks`（字幕）的文件。它构建在 EBML（可扩展二进制元语言，XML 的一种二进制衍生语言）之上，并由 IETF 于 2024 年 10 月发布为 RFC 9559 标准。<sup>[1](https://www.rfc-editor.org/rfc/rfc9559.html)</sup><sup> • </sup><sup>[2](https://datatracker.ietf.org/doc/html/rfc9559)</sup>

| 关键事实 | 详情 |
|---|---|
| 是什么 | 一种基于 EBML（XML 的二进制衍生语言）的多媒体容器格式<sup>[1](https://www.rfc-editor.org/rfc/rfc9559.html)</sup> |
| 标准化 | RFC 9559，IETF 标准轨道，2024 年 10 月；作者为 S. Lhomme、M. Bunkus 和 D. Rice；更新了 RFC 8794（EBML）<sup>[2](https://datatracker.ietf.org/doc/html/rfc9559)</sup> |
| 版本 | 规范涵盖第 1 至第 4 版；第 4 版为当前版本，第 1 至第 3 版已不再维护<sup>[1](https://www.rfc-editor.org/rfc/rfc9559.html)</sup> |
| 起源 | 2002 年 12 月 6 日公布，是多媒体容器格式（MCF）的一个分支，起因是关于采用 EBML 而非二进制格式的争议<sup>[3](https://loc.gov/preservation/digital/formats/fdd/fdd000342.shtml)</sup> |
| 文件结构 | 至少包含一个 EBML 文档，其 `EBML Header` 之后是 `Segment` 根元素，其中包含八个顶层元素<sup>[1](https://www.rfc-editor.org/rfc/rfc9559.html)</sup> |
| 编解码器处理 | 每条轨道都引用 Matroska 编解码器 ID 注册表中登记的 `CodecID`，因此所有实现都以相同方式识别编码<sup>[4](https://www.matroska.org/technical/codec_specs.html)</sup> |
| 保存用途 | 印第安纳大学、伊利诺伊大学、纽约公共图书馆和得克萨斯大学正在使用或计划使用 Matroska 封装 FFV1 无损视频<sup>[5](https://www.iasa-web.org/sites/default/files/publications/IASA-TC_06-B-app_v2019.pdf)</sup> |

## 历史

Matroska 的创始人 史蒂夫·洛姆（Steve Lhomme）在 2001 年录制法国总统选举周期的政治辩论时，开始寻找一种开放而灵活的容器，并发现当时占主导地位的 AVI 格式过于受限。<sup>[3](https://loc.gov/preservation/digital/formats/fdd/fdd000342.shtml)</sup> 美国国会图书馆的格式描述指出，Matroska 于 2002 年 12 月 6 日公开发布，最初是从多媒体容器格式（MCF）中分裂出来的，起因是 MCF 的主要开发者 拉斯·凯尔凯宁（Lasse Kärkkäinen）与洛姆之间关于采用 EBML 而非二进制格式的争议。<sup>[3](https://loc.gov/preservation/digital/formats/fdd/fdd000342.shtml)</sup> 该项目自己的常见问题解答指出，将现有的 AVI、MP4 或 TS 文件重封装为 Matroska 是一个无损过程：音频和视频数据被读取并原样打包进 Matroska 文件。<sup>[6](https://www.matroska.org/faq.html)</sup>

后来的两个里程碑塑造了该格式的发展轨迹：2010 年 [WebM](https://www.edgepedia.org/zh/webm) 开发的启动，以及 2016 年 IETF 标准化进程的启动。<sup>[3](https://loc.gov/preservation/digital/formats/fdd/fdd000342.shtml)</sup> 标准化工作由 IETF CELLAR 工作组承担，其第一项成果是在 Matroska 规范本身之前，先为底层技术 EBML 制定了一份 RFC。<sup>[7](https://www.matroska.org/technical/rfcs.html)</sup> RFC 9559 于 2024 年 10 月达到“建议标准”状态。<sup>[2](https://datatracker.ietf.org/doc/html/rfc9559)</sup>

## 技术结构

一个 Matroska 文件由至少一个使用 Matroska 文档类型的 EBML 文档组成。每个文档以 `EBML Header` 开头，其后是 EBML 根元素，在 Matroska 中定义为 `Segment`。<sup>[1](https://www.rfc-editor.org/rfc/rfc9559.html)</sup> Matroska EBML 模式定义了八个可出现在 Segment 内的顶层元素：`SeekHead`、`Info`、`Tracks`、`Chapters`、`Cluster`、`Cues`、`Attachments` 和 `Tags`。<sup>[1](https://www.rfc-editor.org/rfc/rfc9559.html)</sup> 一个文件也可以包含多个 EBML 文档，每个文档都有自己的头和 Segment。<sup>[1](https://www.rfc-editor.org/rfc/rfc9559.html)</sup>

作为 EBML 文档类型，Matroska 对 EBML 规范增加了约束：EBML 头的 `docType` 必须为“matroska”，`EBMLMaxIDLength` 必须为 4，`EBMLMaxSizeLength` 必须在 1 到 8 之间（含端点）。<sup>[8](https://www.rfc-editor.org/rfc/rfc9559.html?format=pdf)</sup> RFC 9559 还更新了 RFC 8794，允许使用一个此前保留的 EBML 元素 ID。<sup>[2](https://datatracker.ietf.org/doc/html/rfc9559)</sup>

**编解码器识别。** Matroska 文件中的每条轨道都必须通过 `CodecID` 引用一个已定义的编解码器映射；`CodecID` 是来自 Matroska 编解码器 ID 注册表的标识符，代表存储在该轨道 Cluster 中的编码。编解码器 ID 以表示轨道类型的大写字母加下划线为前缀；例如，分配给 FLAC 音频轨道的编解码器 ID 是 `A_FLAC`。<sup>[4](https://www.matroska.org/technical/codec_specs.html)</sup><sup> • </sup><sup>[9](https://www.rfc-editor.org/info/rfc9639/)</sup> 该注册表的目的不是列出所有现存编解码器，而是确保所有支持 Matroska 的开发者对其所支持的编解码器使用相同的标识符。<sup>[4](https://www.matroska.org/technical/codec_specs.html)</sup>

**已登记的选项。** 由 RFC 9559 建立的 IANA 注册表涵盖该格式的可选处理特性。已登记的压缩算法有 zlib、bzlib、lzo1x 和 Header Stripping；已登记的加密算法包括 DES、3DES、Twofish 和 Blowfish，AES 密码模式有 AES-CTR 和 AES-CBC。<sup>[10](https://www.iana.org/assignments/matroska)</sup> 这些注册表还列举了 3D 视频的立体模式（单目、并排、上下、行交错与列交错、红蓝立体等）、矩形、等距柱状、立方体贴图和网格视频的投影类型，以及视频、音频、复合和徽标等轨道类型。<sup>[10](https://www.iana.org/assignments/matroska)</sup>

## 流式传输

Matroska 支持两种流式传输：文件访问和直播流。直播 Matroska 流与文件的区别在于，它通常没有已知的结尾，因此 `Segment` 元素大小部分的所有位都被置位，以表示未知大小；另一种做法是将已知大小的 Segment 拼接起来，这样可以在各 Segment 之间更换编解码器或分辨率，例如在电视节目中从 4:3 切换到 16:9。<sup>[11](https://www.matroska.org/technical/streaming.html)</sup> 该项目的指导方针指出，Matroska 不打算用于 RTP 之上，因为 RTP 已经提供了定时和通道机制，再叠加会造成重复并可能导致不一致。<sup>[11](https://www.matroska.org/technical/streaming.html)</sup> 诸如把定位数据放在前面以减少读取操作之类的[实现](https://www.edgepedia.org/zh/implementation)建议，有助于在不先读取 `Cues`、`Attachments` 或 `SeekHead` 等元素的情况下快速开始播放。<sup>[11](https://www.matroska.org/technical/streaming.html)</sup>

## 在档案与保存中的应用

Matroska 已成为视频保存领域的一种实用容器。IASA-TC 06 指南的对照表将 Matroska 中的 FFV1 在“公开性”上评为“良好”，在“采用度”上评为“成长中”，并记录[印第安纳大学](https://www.edgepedia.org/zh/indiana-university)、伊利诺伊大学、[纽约公共图书馆](https://www.edgepedia.org/zh/new-york-public-library)和得克萨斯大学以及其他档案馆正在使用或计划使用 Matroska 封装 FFV1。<sup>[5](https://www.iasa-web.org/sites/default/files/publications/IASA-TC_06-B-app_v2019.pdf)</sup> MIPoPS 保存手册同样将包含 FFV1 编码视频的 Matroska 文件描述为从事视频数字化的机构首选的保存格式。<sup>[12](https://www.mipops.org/wp-content/uploads/2019/03/Manual_FileFormats.pdf)</sup>

美国国会图书馆在其“数字格式可持续性”资源中维护着 Matroska 多媒体容器的格式描述，该资源从公开性、采用度、透明性、自描述性、外部依赖、专利影响和技术保护机制等方面评估格式。<sup>[3](https://loc.gov/preservation/digital/formats/fdd/fdd000342.shtml)</sup><sup> • </sup><sup>[13](https://loc.gov/preservation/digital/formats/index.shtml)</sup>

## 治理与生态

项目背后的组织 Matroska 协会目前由 史蒂夫·洛姆（Steve Lhomme，主席兼项目创始人）、吕多维克·维亚勒（Ludovic Vialle，财务主管）和莫里茨·邦库斯（Moritz Bunkus，秘书，MKVToolNix 工具的作者）组成。<sup>[14](https://www.matroska.org/legal.html)</sup> 规范源代码在 IETF CELLAR 工作组的仓库中公开维护。<sup>[15](https://github.com/ietf-wg-cellar/matroska-specification)</sup>

与 MP4 相比，Matroska 通常被定位为更灵活的容器：容器比较文献中的评论将 MKV 描述为当一个文件必须承载所有轨道、字幕和特性时的首选格式，而 MP4 在设备兼容性和网络分发方面占主导地位，WebM 则是谷歌围绕免版税编解码器构建的 Matroska 网络优先配置。<sup>[16](https://www.forasoft.com/learn/video-encoding/articles/containers-mp4-mkv-webm-fmp4)</sup> Matroska 的常见问题解答直接回应了向前兼容性：用当前工具创建的文件符合规范，并且该格式的 EBML 基础允许读取器在其父元素的尺寸约束内跳过无法识别的元素。<sup>[6](https://www.matroska.org/faq.html)</sup><sup> • </sup><sup>[8](https://www.rfc-editor.org/rfc/rfc9559.html?format=pdf)</sup>

## References

1. [RFC 9559: Matroska Media Container Format Specification, RFC Editor](https://www.rfc-editor.org/rfc/rfc9559.html)
2. [RFC 9559, IETF Datatracker](https://datatracker.ietf.org/doc/html/rfc9559)
3. [Matroska Multimedia Container, Sustainability of Digital Formats, Library of Congress](https://loc.gov/preservation/digital/formats/fdd/fdd000342.shtml)
4. [Codec Mappings, Matroska technical documentation](https://www.matroska.org/technical/codec_specs.html)
5. [IASA-TC 06 Appendix, part B: Guidelines for the Preservation of Video Recordings, International Association of Sound and Audiovisual Archives (2019)](https://www.iasa-web.org/sites/default/files/publications/IASA-TC_06-B-app_v2019.pdf)
6. [Frequently asked & answered questions, Matroska](https://www.matroska.org/faq.html)
7. [IETF RFCs, Matroska technical documentation](https://www.matroska.org/technical/rfcs.html)
8. [RFC 9559 (PDF rendering), RFC Editor](https://www.rfc-editor.org/rfc/rfc9559.html?format=pdf)
9. [RFC 9639: Free Lossless Audio Codec (FLAC), RFC Editor](https://www.rfc-editor.org/info/rfc9639/)
10. [Matroska, IANA registry](https://www.iana.org/assignments/matroska)
11. [Streaming, Matroska technical documentation](https://www.matroska.org/technical/streaming.html)
12. [MIPoPS Deliverables: File Formats, Moving Image Preservation of Seattle](https://www.mipops.org/wp-content/uploads/2019/03/Manual_FileFormats.pdf)
13. [Sustainability of Digital Formats: Planning for Library of Congress Collections](https://loc.gov/preservation/digital/formats/index.shtml)
14. [Legal aspects, Matroska](https://www.matroska.org/legal.html)
15. [ietf-wg-cellar/matroska-specification, GitHub](https://github.com/ietf-wg-cellar/matroska-specification)
16. [Containers: MP4, fMP4, MKV, WebM, MOV, MPEG-TS, Fora Soft](https://www.forasoft.com/learn/video-encoding/articles/containers-mp4-mkv-webm-fmp4)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 17, 2026; Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Data formats and serialization › Image and video formats

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/matroska

English original: https://www.edgepedia.org/matroska
