Skip to main content

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

pip install decryptune

From source (needs Rust 1.85+ and Python 3.12+): pip install maturin && maturin build --release — this is also the macOS path (it builds and runs the same; prebuilt wheels ship for Linux and Windows).

Usage

from decryptune import DecrypTune, TuneMeta

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
    classic=True                 # rewrite a fragmented (fMP4) result as a regular MP4 —
)                                # real tables, one mdat; audio copied, never re-encoded;
                                 # the DASH header (ftyp brands, ID32, over-long elst) is
                                 # cleaned up too. A non-fragmented file still gets its header polished.

# async twin — same options, same result:
out_bytes = await sp.aproc(...)

Rules that hold for both proc and aproc:

  • Every parameter is keyword-only.
  • out is a path → the file is written atomically (tmp + rename) and None is returned; out is None → the processed bytes are returned.
  • key=None → fix-only pass: headers sanitized, audio payload untouched.
  • A meta wipes the existing tag block and rebuilds it solely from the given fields — None / 0 / empty values are skipped; without meta the original metadata passes through untouched.
  • Any problem raises DecrypTuneError with a stable numeric code (1–16) and a message authored in the native core: 1 invalid key · 2 invalid kid · 3 input not found · 4 not an MP4 · 6 write failed · 7 KID mismatch · 8 corrupt audio detected · 9 bad input type · 10 bad out type · 11 tags need a fragmented file · 12 bad cover · 13 cover file not found · 14 cover too large (max 32 MB) · 15 classic rewrite unsupported · 16 tag too large (max 32 MB).

Benchmark

Native Windows 11 (windows-x86_64 wheel), Intel i7-11800H (8C/16T), Python 3.13, real 3.0MB fragmented track:

scenario result
decrypt + fix, strict (bytes in/out) 3.0 ms median — ~1.0 GB/s
fix-only pass (no key) 1.0 ms
full tags + cover resize (877KB JPEG) 219 ms
32 calls: sequential → asyncio.gather (bytes) 97 ms → 30 ms (×3.3)
32 calls with path out (real writes) 46 ms (×2.1)
event-loop max lag under 8 concurrent heavy calls < 15 ms (Windows timer granularity)

Fragment work (decrypt + strict evidence check) spreads across cores on large files: a 128MB fragmented file runs decrypt+strict in ~0.1s.

License

MIT — see LICENSE.

Metadata

Release files for decryptune 1.1.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for decryptune 1.1.10
File Size Uploaded Provenance Actions
decryptune-1.1.10.tar.gz 510.8 kB With provenance Details for decryptune-1.1.10.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for decryptune 1.1.10
File Actions
decryptune-1.1.10-cp312-abi3-win_arm64.whl CPython 3.12 abi3 Windows ARM64 Details for decryptune-1.1.10-cp312-abi3-win_arm64.whl
decryptune-1.1.10-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details for decryptune-1.1.10-cp312-abi3-win_amd64.whl
decryptune-1.1.10-cp312-abi3-manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.28+ x86-64 Details for decryptune-1.1.10-cp312-abi3-manylinux_2_28_x86_64.whl
decryptune-1.1.10-cp312-abi3-manylinux_2_28_aarch64.whl CPython 3.12 abi3 Linux glibc 2.28+ ARM64 Details for decryptune-1.1.10-cp312-abi3-manylinux_2_28_aarch64.whl

Total release size: 2.2 MB

Release files / decryptune-1.1.10.tar.gz

Download URL decryptune-1.1.10.tar.gz
Size 510.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c56c55ae1d5f2374250ee82d6f399983559278951287fe269a48dbce4d0f3b19
BLAKE2b-256 checksum
How to use checksums
ff8ad105a01cb32a0b8c4ab96887070d1b8e533b1b03867bf3654d800923b10e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 3, 2026.

Transparency log

Release files / decryptune-1.1.10-cp312-abi3-win_arm64.whl

Download URL decryptune-1.1.10-cp312-abi3-win_arm64.whl
Size 377.7 kB
Tags CPython 3.12 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
59eb16f3c367ceec5e639aad2ed93ee4bec1efb461fda74df766e297c44207fc
BLAKE2b-256 checksum
How to use checksums
e11db70d7ce3a466baacf5e55488423e7ef0919e65a4e28216c1257390ff551f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 3, 2026.

Transparency log

Release files / decryptune-1.1.10-cp312-abi3-win_amd64.whl

Download URL decryptune-1.1.10-cp312-abi3-win_amd64.whl
Size 400.5 kB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
c60dca846799f59262c9b0b3b09b4b139a5e05aa0ef9f81e3630dce8adf47cf8
BLAKE2b-256 checksum
How to use checksums
815ddf23f332c94f457b5462835bf22ff81a9cdfb115c4e0fbb0db02c96b3cdf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 3, 2026.

Transparency log

Release files / decryptune-1.1.10-cp312-abi3-manylinux_2_28_x86_64.whl

Download URL decryptune-1.1.10-cp312-abi3-manylinux_2_28_x86_64.whl
Size 460.3 kB
Tags CPython 3.12 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
69548f7482c4de8f9b4ca7d06c59ebb50e77d22042569dbb2394966a31ce4de1
BLAKE2b-256 checksum
How to use checksums
2e8af0276b62112e6a9f59fac3109fd55d355155a043ffda0a4fe47bd1189ec6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 3, 2026.

Transparency log

Release files / decryptune-1.1.10-cp312-abi3-manylinux_2_28_aarch64.whl

Download URL decryptune-1.1.10-cp312-abi3-manylinux_2_28_aarch64.whl
Size 441.7 kB
Tags CPython 3.12 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
d2e4a68aa064f703ad587e87cd1c190a4eeebee0b11d0bb6ecd9788c98846179
BLAKE2b-256 checksum
How to use checksums
30ddbef5b9ebf40111e0d3af3cb077f34ff9ccd02fe7e3fdff7d024f79dc73d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 3, 2026.

Transparency log

Security for decryptune 1.1.10

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.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for decryptune-1.1.10.tar.gz

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 Dec 3, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page