mkvunlink
Merge linked MKV segments into standalone files.
Matroska can store content once and have several files reference it, through two linking mechanisms:
- Ordered chapters with segment linking: the chapter list is a playlist whose entries can point into other files by segment UID.
- Hard linking: the segment header names a previous and/or next segment, chaining whole files together.
Players that implement linking (mpv, MPC-HC) stitch the pieces together at playback. Everything else plays the file alone, with the linked content missing. mkvunlink resolves the linked timeline the way mpv does and writes it as a single self-contained file that plays anywhere.
Requirements
MKVToolNix v52 or later and FFmpeg on PATH:
| Windows | winget install MKVToolNix.MKVToolNix Gyan.FFmpeg |
| macOS | brew install mkvtoolnix ffmpeg |
| Debian/Ubuntu | apt install mkvtoolnix ffmpeg |
| Arch | pacman -S mkvtoolnix-cli ffmpeg |
The MKVToolNix installer on Windows may not add itself to PATH; add
its folder (C:\Program Files\MKVToolNix) manually.
Installation
uv tool install mkvunlink
or using pip
pip install mkvunlink
Usage
mkvunlink 'Episode 01.mkv'
mkvunlink --outdir flattened /path/to/series
mkvunlink --edition 2 'Movie.mkv'
The linked segment files must be in the same directory as the files
that reference them. Output goes to ./unlinked unless --outdir is
given.
| Option | |
|---|---|
--outdir DIR |
output directory, created if missing |
--edition N |
1-based edition to flatten when the file has several |
--no-verify |
skip the decoded-checksum check of re-encoded audio |
--keep-temp |
keep the working directory for inspection |
Behavior
- Video and bitmap subtitles (PGS/VobSub) are stream copied.
- Audio is stream copied. Codecs mkvmerge cannot split or append (FLAC) are rebuilt with ffmpeg instead: lossless codecs are cut sample-accurately and re-encoded to the same codec, then checked against the sources by decoded checksum; lossy codecs are copied per span without re-encoding.
- Text subtitles (ASS/SRT) are merged onto the joined timeline. Styles keep their names; a style is aliased only when two sources define the same name differently. Segments typeset at a different PlayRes have their styles resampled.
- Chapters are regenerated at the joined positions with their display names in every language. Title, global tags, attachments and track metadata carry over from the main file.
- Multiple editions produce a warning;
--editionselects one.
Limitations
- Segments whose video encoding parameters differ cannot be appended by mkvmerge; mkvunlink reports the error rather than transcoding video.
- WebVTT subtitles are downgraded to SRT, losing cue positioning and styling.
- A flattened file embodies one edition; run once per edition for multi-edition files.
Troubleshooting
An audio track whose header reports no sampling frequency fails the run, and PCM with a missing bit depth is stream copied per span instead of rebuilt sample-accurately. Both header fields can be repaired in place with mkvpropedit, which ships with MKVToolNix.
For example, a 48 kHz 24-bit PCM track is fixed with:
mkvpropedit broken.mkv --edit track:a1 --set sampling-frequency=48000
mkvpropedit broken.mkv --edit track:a1 --set bit-depth=24
License
MIT
Metadata
Release files for mkvunlink 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mkvunlink-0.1.0.tar.gz | 15.4 kB | Without provenance | Details for mkvunlink-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mkvunlink-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for mkvunlink-0.1.0-py3-none-any.whl |
Total release size: 30.2 kB
Release files / mkvunlink-0.1.0.tar.gz
| Download URL | mkvunlink-0.1.0.tar.gz |
|---|---|
| Size | 15.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f4a0f85d6c7b0e9d3515527f6bb3b5f2156d1661dfd0aeb25ae2e218d1f3c90a
|
|
BLAKE2b-256 checksum How to use checksums |
3b101e856d30bba4cdd50e9e0d81ef9f9c0e36760b7af5e15f320295a8e07a85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Release files / mkvunlink-0.1.0-py3-none-any.whl
| Download URL | mkvunlink-0.1.0-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
af66e2b7645aa3c970a3dc404f53d3ed303a936800e3d775e465ed3b134b87b1
|
|
BLAKE2b-256 checksum How to use checksums |
51c0fca68face6574c595b102a5bc82ff444806df5d5e7878a56286a0cee21ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Security for mkvunlink 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.