decryptune
Fast, native M4A (fMP4/CENC) decryptor + MP4 sanitizer + iTunes tagger in one lightweight, self-contained call — a Rust core with a sync/async Python API that replaces the usual chain of external tools (no subprocesses, no ffmpeg, no dependencies) and runs fully GIL-free, so async callers can fan out without blocking the event loop.
Install
Wheel (recommended) — the native module ships inside the package, fixed at install time:
pip install decryptune-1.0.0-cp312-abi3-manylinux_2_34_x86_64.whl
Standalone (no install) — keep decryptune.py next to the extension binary:
from decryptune import DecrypTune
sp = DecrypTune("./libdecryptune.so")
From source (needs Rust 1.85+ and Python 3.12+): pip install maturin && maturin build --release
Usage
from decryptune import DecrypTune, TuneMeta
# bundled native module (wheel) — or DecrypTune("./libdecryptune.so")
sp = DecrypTune()
sp.proc(
input="track.m4a", # bytes / bytearray / memoryview / path
out="out.m4a", # destination path; None → the processed bytes are returned
key="<32 hex>", # None → fix-only pass (headers sanitized, payload untouched)
kid="<32 hex>", # verified against the file's tenc; ignored without key
meta=TuneMeta(
title="Song",
artists=["A"],
isrc="...",
cover="cover.jpg", # bytes or path — JPEG/PNG; oversized JPEGs shrink to ≤1000px
# date=..., album=..., genre=..., lyrics=..., composer=...,
# track=..., track_total=..., disc=..., disc_total=...
),
strict=True, # raise (code 8, per-fragment chi² evidence) when a fragment
) # decrypts to statistical noise — a wrong/fake key
# async twin — same options, same result:
out_bytes = await sp.aproc(...)
Rules that hold for both proc and aproc:
- Every parameter is keyword-only.
outis a path → the file is written atomically (tmp + rename) andNoneis returned;outisNone→ the processedbytesare returned.key=None→ fix-only pass: headers sanitized, audio payload untouched.- A
metawipes the existing tag block and rebuilds it solely from the given fields —None/0/ empty values are skipped; withoutmetathe original metadata passes through untouched. - Any problem raises
DecrypTuneErrorwith a stable numeric code (1–12) and a message authored in the native core:1invalid key ·2invalid kid ·3input not found ·4not an MP4 ·6write failed ·7KID mismatch ·8corrupt audio detected ·9bad input type ·10bad out type ·11tags need a fragmented file ·12bad cover.
Build
cargo build --release && cp target/release/libdecryptune.so .
maturin build --release # → target/wheels/*.whl
Tests
python3 -m pytest tests/
DECRYPTUNE_WHEEL=1 python3 -m pytest tests/ # against the installed wheel
End-to-end suite: synthetic CENC files, real AES-CTR vectors, 300-mutation fuzz, async parity, error codes.
License
MIT — see LICENSE.
Release files for decryptune 1.0.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 | |
|---|---|---|---|
| decryptune-1.0.0.tar.gz | 360.8 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| decryptune-1.0.0-cp312-abi3-win_arm64.whl | CPython 3.12 | abi3 | Windows ARM64 | Details |
| decryptune-1.0.0-cp312-abi3-win_amd64.whl | CPython 3.12 | abi3 | Windows x86-64 | Details |
| decryptune-1.0.0-cp312-abi3-manylinux_2_28_x86_64.whl | CPython 3.12 | abi3 | Linux glibc 2.28+ x86-64 | Details |
| decryptune-1.0.0-cp312-abi3-manylinux_2_28_aarch64.whl | CPython 3.12 | abi3 | Linux glibc 2.28+ ARM64 | Details |
Total release size: 2.2 MB
Release files / decryptune-1.0.0.tar.gz
| Download URL | decryptune-1.0.0.tar.gz |
|---|---|
| Size | 360.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04f4f3d6b432ae642fa9fd191e4bee93b076ba9bec7464635a59ed27ca0ea01e
|
|
BLAKE2b-256 checksum How to use checksums |
f377cff0d590d67707c5c8624c1fb1dcdb4b7415ebd3f78a39146b5d76121b6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.
Transparency logRelease files / decryptune-1.0.0-cp312-abi3-win_arm64.whl
| Download URL | decryptune-1.0.0-cp312-abi3-win_arm64.whl |
|---|---|
| Size | 406.8 kB |
| Tags | CPython 3.12 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
deb2668027e2d87af7e8b3ef8cca74a88e2f2aed717240618dca759d8175b834
|
|
BLAKE2b-256 checksum How to use checksums |
8c5fd0817f2404c123e9deb96054967b7078b5b2803310bfbc1b28010f030549
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.
Transparency logRelease files / decryptune-1.0.0-cp312-abi3-win_amd64.whl
| Download URL | decryptune-1.0.0-cp312-abi3-win_amd64.whl |
|---|---|
| Size | 434.0 kB |
| Tags | CPython 3.12 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
8022a15b927b7b52e2ec9003433f52819a8952016c7e9ace18e058f8af7fb648
|
|
BLAKE2b-256 checksum How to use checksums |
28704d727729b82aa60c498380d5dc4fb72819c6d94a669b22527b8b0161fdc1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.
Transparency logRelease files / decryptune-1.0.0-cp312-abi3-manylinux_2_28_x86_64.whl
| Download URL | decryptune-1.0.0-cp312-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 500.3 kB |
| Tags | CPython 3.12 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
53e45e06ceec923a335fda3891ba5e5918f8bcab343e3a9de43d3568d979700a
|
|
BLAKE2b-256 checksum How to use checksums |
45810dcd434262259e81bc6c036ff8446d4e6a050cf65adaa8dc5e3752ce9f55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.
Transparency logRelease files / decryptune-1.0.0-cp312-abi3-manylinux_2_28_aarch64.whl
| Download URL | decryptune-1.0.0-cp312-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 473.7 kB |
| Tags | CPython 3.12 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
43cf046d52f99249b7c22931ce28f9ec9dd0184f4ec78d5b7acf6c95c905fd82
|
|
BLAKE2b-256 checksum How to use checksums |
e6a31a3de592e4934d45dfa2f469f42789f9d3414f4f395d8cfef6985b77b059
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.
Transparency log