Skip to main content

A Python wrapper for mkvmerge. It provides support for muxing, splitting, linking, chapters, tags, and attachments through the use of mkvmerge.

Project description

pymkv2

PyPI Version License codecov versions

pymkv2 is a Python wrapper for mkvmerge and other tools in the MKVToolNix suite. It provides support for muxing, splitting, linking, chapters, tags, and attachments through the use of mkvmerge.

About pymkv2

it's a fork of the pymkv project. pymkv2 is a Python 3 library for manipulating MKV files with mkvmerge. Constructing mkvmerge commands manually can quickly become confusing and complex. To remedy this, I decided to write this library to make mkvmerge more scriptable and easier to use. Please open new issues for any bugs you find, support is greatly appreciated!

Installation

mkvmerge must be installed on your computer, it is needed to process files when creating MKV objects. It is also recommended to add it to your $PATH variable but a different path can be manually specified. mkvmerge can be found and downloaded from here or from most package managers.

To install pymkv from PyPI, use the following command:

$ pip install pymkv2

You can also clone the repo and run the following command in the project root to install the source code as editable:

$ pip install -e .

Language code utilities

pymkv exposes a normalized API for comparing and translating language codes across ISO 639-1, /B, /T, 639-3, BCP 47, and English language names. Use these helpers instead of comparing language strings directly — language_ietf="zh-Hans" and language="chi" should match, and they do via languages_match.

from pymkv import (
    MKVFile,
    get_iso639_2,
    languages_match,
    language_equivalents,
    normalize_language,
)

get_iso639_2("English")        # "eng"
get_iso639_2("fra")            # "fre"  (canonical /B)
normalize_language("zh-Hans")  # "chi"  (BCP 47 subtag stripped)
languages_match("zho", "zh")   # True
language_equivalents("eng")    # frozenset({"eng", "en"})

# MKVTrack setter is now lenient — any recognized form is accepted and
# canonicalized to /B on store.
mkv = MKVFile("path/to/file.mkv")
track = mkv.tracks[1]
track.language = "Chinese"        # stored as "chi"
track.matches_language("zh")       # True (works against language_ietf too)
track.effective_language           # "chi" — normalized /B

Documentation

The documentation for pymkv can be found here or in the project's docstrings.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymkv2-2.3.0.tar.gz (75.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymkv2-2.3.0-py3-none-any.whl (52.0 kB view details)

Uploaded Python 3

File details

Details for the file pymkv2-2.3.0.tar.gz.

File metadata

  • Download URL: pymkv2-2.3.0.tar.gz
  • Upload date:
  • Size: 75.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pymkv2-2.3.0.tar.gz
Algorithm Hash digest
SHA256 8b497b87f694ea645e2a2e08f22b4330853ed3342b4c87c81a04cc52c1e0c9be
MD5 f9e64f5c962a77ac99b7b334aa0c3008
BLAKE2b-256 d01ea6d2f9d1e461ffbb19c9b6f5dbe156f6ce54b98786c29c858062bb79adea

See more details on using hashes here.

File details

Details for the file pymkv2-2.3.0-py3-none-any.whl.

File metadata

  • Download URL: pymkv2-2.3.0-py3-none-any.whl
  • Upload date:
  • Size: 52.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pymkv2-2.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6a0db232a04714a0d2cf3649c94559e5f2cfd715b379183d655e8b84cdd6c957
MD5 2c142f971b49a393497552b64d3a4ff9
BLAKE2b-256 8fc315b15377cc39257d744b876a85aae41231b9f47a964c32471797c41eb5ed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page