Skip to main content

A Python wrapper for Neill Corlett's ECM tools for encoding and decoding PSX CD images.

Project description

PyECM Tools

PyPI Version License: MIT Python Versions

A high-performance Python wrapper for Neill Corlett's classic ECM (Error Code Modeler) tools, designed for compressing and decompressing PlayStation (PSX) and other CD-based disc images.

What is ECM and Why Use It for PSX Games?

PlayStation disc images (usually in .bin/.cue format) are large. While you can compress them with standard tools like .zip or .7z, the results are often not as good as they could be.

This is because CD-ROM data includes Error Detection Code (EDC) and Error Correction Code (ECC). This data is mathematically generated and behaves much like random noise, which is notoriously difficult to compress.

The ECM tool works by stripping out this redundant ECC/EDC data from the disc image. The resulting .ecm file is much smaller and contains more uniform data, which can then be compressed extremely well by other tools like 7-Zip or RAR.

When you need to use the image again, the unecm process perfectly regenerates the original ECC/EDC data, restoring the file to its original, bit-perfect state.

This package makes that powerful C code available with a simple, Pythonic interface.

Features

  • Faithful Wrapper: Uses the original, battle-tested C source code from Neill Corlett for 100% compatibility.
  • High Performance: All heavy lifting is done in compiled C code, offering native speed for encoding and decoding.
  • Simple Pythonic API: Provides easy-to-use encode() and decode() functions.
  • Progress Reporting: Includes a callback mechanism to easily track the progress of long operations, perfect for GUIs or logging.
  • Cross-Platform: Compiles on Windows, macOS, and Linux.

Installation

You can install the package directly from PyPI using uv or pip:

uv pip install pyecm-tools

Quick Start: Compressing Civilization II

Let's say you have a disc image of Civilization II for the PlayStation and you want to archive it efficiently.

import pyecm
import os

# --- Define our file paths ---
input_file = "Civilization II (USA).bin"
ecm_file = "Civilization II (USA).ecm"
restored_file = "Civilization II (USA).restored.bin"

# --- Create a dummy file for the example if it doesn't exist ---
if not os.path.exists(input_file):
    print(f"Creating a dummy file for '{input_file}'...")
    with open(input_file, "wb") as f:
        # A typical PSX game is ~650MB. We'll make a smaller 50MB file.
        f.write(os.urandom(50 * 1024 * 1024))

# 1. Encode the .bin file to .ecm
print(f"Encoding '{input_file}' to '{ecm_file}'...")
try:
    pyecm.encode(input_file, ecm_file)
    print("Encoding successful!")
except Exception as e:
    print(f"An error occurred: {e}")

# 2. Decode the .ecm file back to a .bin
print(f"\nDecoding '{ecm_file}' to '{restored_file}'...")
try:
    pyecm.decode(ecm_file, restored_file)
    print("Decoding successful!")
except Exception as e:
    print(f"An error occurred: {e}")

# You can now verify that 'input_file' and 'restored_file' are identical.
# For even better compression, you can now compress the .ecm file with 7-Zip.

Advanced Usage: Progress Reporting

For large files, you'll want to see the progress. You can pass any Python function as a callback to the progress argument.

import pyecm

def my_progress_reporter(current_bytes, total_bytes, operation_type):
    """A callback function to display progress."""
    if total_bytes == 0:
        percent = 100
    else:
        percent = (current_bytes * 100) / total_bytes

    # The 'type' argument is 0 for the initial analysis phase and 1 for processing
    stage = "Analyzing" if operation_type == 0 else "Processing"

    print(f"\r{stage}: {percent:.2f}% complete ({current_bytes}/{total_bytes})", end="")
    if current_bytes == total_bytes:
        print() # Newline at the end

# --- Use the callback with encode ---
print("Encoding with progress reporting:")
pyecm.encode(
    "Civilization II (USA).bin",
    "Civilization II (USA).ecm",
    progress=my_progress_reporter
)

# --- Use the callback with decode ---
print("\nDecoding with progress reporting:")
pyecm.decode(
    "Civilization II (USA).ecm",
    "Civilization II (USA).restored.bin",
    progress=my_progress_reporter
)

License

This Python wrapper (pyecm-tools) is distributed under the MIT License.

The original C code for ECM and UNECM is copyrighted by Neill Corlett and is distributed under the GNU General Public License v2 (GPLv2). The source code is included in this package.

Acknowledgements

  • All credit for the brilliant ECM algorithm and its implementation goes to Neill Corlett.

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

pyecm_tools-1.0.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distributions

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

pyecm_tools-1.0.0-cp314-cp314t-musllinux_1_2_x86_64.whl (232.0 kB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

pyecm_tools-1.0.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (237.1 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pyecm_tools-1.0.0-cp314-cp314-musllinux_1_2_x86_64.whl (194.5 kB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

pyecm_tools-1.0.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (201.1 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pyecm_tools-1.0.0-cp313-cp313-musllinux_1_2_x86_64.whl (196.2 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

pyecm_tools-1.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (202.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pyecm_tools-1.0.0-cp312-cp312-musllinux_1_2_x86_64.whl (202.0 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

pyecm_tools-1.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (206.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pyecm_tools-1.0.0-cp311-cp311-musllinux_1_2_x86_64.whl (180.6 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

pyecm_tools-1.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (191.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pyecm_tools-1.0.0-cp310-cp310-musllinux_1_2_x86_64.whl (176.7 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

pyecm_tools-1.0.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (180.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pyecm_tools-1.0.0-cp39-cp39-musllinux_1_2_x86_64.whl (175.9 kB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ x86-64

pyecm_tools-1.0.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (180.0 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pyecm_tools-1.0.0-cp38-cp38-musllinux_1_2_x86_64.whl (158.0 kB view details)

Uploaded CPython 3.8musllinux: musl 1.2+ x86-64

pyecm_tools-1.0.0-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (163.4 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file pyecm_tools-1.0.0.tar.gz.

File metadata

  • Download URL: pyecm_tools-1.0.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for pyecm_tools-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b411e6b719932ac463753c124860e8796d60f2af2e8378bdf36102f2d2765841
MD5 ac11d56ef78afb45849b25f9702cc3e3
BLAKE2b-256 a48f19abacceedc8e8ac237df2de6b7c2fa3f92a7cc755048d9dfd22dcecef81

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.0-cp314-cp314t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyecm_tools-1.0.0-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4e6e254c09cb38f6c858cdc341cf7cefa722114eada4b24bf32559f9ba17319e
MD5 e56d1c0af27351d9c4b26b3303465fbd
BLAKE2b-256 4ddc663a89560aa1b663f5eca0e6f13c5510fc2e7123c8408dddbcd7623d222d

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyecm_tools-1.0.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 66ebefed088715b4412b937201ee1c7a6da5ceaedaf6938e4ee7d08e1318ebc6
MD5 7c1eefedcab890aeebde557684e24138
BLAKE2b-256 94c5e1bc1d65c50edfe254466e0bbc90eff9dc6577d2024485e60b01fe6cce2d

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.0-cp314-cp314-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyecm_tools-1.0.0-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5088827f896ff30a4cc4b6c05b52137b774c27413282e9c11f05aaea259e065f
MD5 67407188d7169aebec5c346d8af2db5d
BLAKE2b-256 a73467333bec9867d730b0a1c23eb0c4b3c8e592538ef6a2b3693c3d693f80f8

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyecm_tools-1.0.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7181c9f2de3994b8a9e87efd8cd2e5ff0d67f5494b351e86e9e0aa55a41cad62
MD5 5a5212ef717f560704475f110df79861
BLAKE2b-256 17aca0fd8d9b5b1dbe653ed8a7738df4731f3e8e491051a20bda16deeccb4b95

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.0-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyecm_tools-1.0.0-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 075bf6a977b768b58db7a32da65e19772ffff95a565cf961096101dca5349d19
MD5 fd48ef58165ace2dee7b789b4a65a290
BLAKE2b-256 f594f03fac2e8d40ff42bb62dbd3206eba6a002e5cb5fa949a1137a6089f10e1

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyecm_tools-1.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 09f3d1eeab56ceca98ae75bbf8a0c3bb7eb8cf1182af8fe6b9f3c69e87dea5ac
MD5 3ee08815f1b76fc65e37ddf79093fd73
BLAKE2b-256 f553ab407a95397f7e027ea9c381cb3378a8acecad07e11195c3a4cefcfd70ac

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.0-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyecm_tools-1.0.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 40d7a21d432e1049207a6b8475206d5ca7fff114a24a55de88aedb3e57cd6112
MD5 ca8275f7be7082b2d429134e9a8d3787
BLAKE2b-256 48809eca7fc50309f3e577baea2537619d1aad962b22a2bc8b875d69570f7330

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyecm_tools-1.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 336bd91633ab58535f034c91f2bdaaf98a6a6b2eeb16639a5b0422c632aae360
MD5 b0da50c5a46b4feff4806679d7d2d239
BLAKE2b-256 c39464c6de8e39ba3c3ecbde81d021a47ddb67c47e27249c4d2e3f4fb1caeb27

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.0-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyecm_tools-1.0.0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 fd204477b0c5b06e1432df5b6eba4538eca870f00eb89b583a08b54ded987614
MD5 7a054a62ee33290cec9092fa58e04465
BLAKE2b-256 46e71ff90d6466347c410f891fd40723dd5269a79aa6c44c6593a0b26fe5e319

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyecm_tools-1.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 598b8f9b0bff00471af4b6b05031de594a284b483bf98a0cdf995684f8ff7f7d
MD5 c65ac4b5b239fec6611db873ac843e3f
BLAKE2b-256 ac637f664a30ffba4b19bcf7c67777b48c22af3b80d4f972d504ce5e61f97ff8

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.0-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyecm_tools-1.0.0-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c672c9d3aa34939a7b53b471ce2ef95d22616226267b194cef5be97282aa8c87
MD5 c378accab55eac2e39be5c06274458aa
BLAKE2b-256 e5486e9af0b35c7ca243758ecb10ba675a44f42c397adba9578b98d1f56adeff

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyecm_tools-1.0.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8181b6b47998e2448bb6569b644d30c8a395d19cd3145f2a88a62455f77ccf76
MD5 2602fac309d2378efbbfbc652ba3fb6c
BLAKE2b-256 f6fd921ac087c0f83ae1faf740f676f088dd6c639e64d163420aa46f0bc93440

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.0-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyecm_tools-1.0.0-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 76a56d8a99cdfcd52eecd38bccc47b91951187e851854852cc696b83871cc482
MD5 3bdbcc15d1ad97d0e1b5c5169ddffcbc
BLAKE2b-256 c6c257cdb9556dbb8d2a7d656b1f7610eb2551d44f0868af8f0c83b27780f8c6

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyecm_tools-1.0.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fa82041b314378cfec1bd407b24ed6be1fa8e28b320c32e9a3d752ebbd9a51cb
MD5 a36d730d82dfde3062b771b12d38ba87
BLAKE2b-256 1e742b05853d202a0a6d8497ed3c7d3198a75ff836904cb9d945d29b5398b935

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.0-cp38-cp38-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyecm_tools-1.0.0-cp38-cp38-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 7839cb4d6b61fec8cf536abea963010f225ba286fef6a5b716e9ddc25da9692a
MD5 ebdc92e84e569faae3be55c7f31d6319
BLAKE2b-256 43f07fbd0cb6d858f08a57e22ff4d2221d84679b8d07a153ce9ac2fcf875f405

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.0-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyecm_tools-1.0.0-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9c5e54c7c3164fd0754c6ce1ef231f2855c6e5d59df1cddc2be194cc0f3bd169
MD5 c4f53c0bdf684e2a7d424db9b3cc72d3
BLAKE2b-256 fe6a73eae156746a7bd9f77f9612064f0c7a28d894b041a54fffc8f2c3c4e17e

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