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.2.tar.gz (10.8 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.2-cp314-cp314t-musllinux_1_2_x86_64.whl (231.9 kB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

pyecm_tools-1.0.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (237.3 kB view details)

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

pyecm_tools-1.0.2-cp314-cp314-musllinux_1_2_x86_64.whl (194.2 kB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

pyecm_tools-1.0.2-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.2-cp313-cp313-musllinux_1_2_x86_64.whl (196.1 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

pyecm_tools-1.0.2-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.2-cp312-cp312-musllinux_1_2_x86_64.whl (201.9 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

pyecm_tools-1.0.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (206.5 kB view details)

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

pyecm_tools-1.0.2-cp311-cp311-musllinux_1_2_x86_64.whl (180.5 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

pyecm_tools-1.0.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (191.2 kB view details)

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

pyecm_tools-1.0.2-cp310-cp310-musllinux_1_2_x86_64.whl (176.4 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

pyecm_tools-1.0.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (180.6 kB view details)

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

pyecm_tools-1.0.2-cp39-cp39-musllinux_1_2_x86_64.whl (175.7 kB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ x86-64

pyecm_tools-1.0.2-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (179.9 kB view details)

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

pyecm_tools-1.0.2-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.2-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (163.3 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.2.tar.gz.

File metadata

  • Download URL: pyecm_tools-1.0.2.tar.gz
  • Upload date:
  • Size: 10.8 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.2.tar.gz
Algorithm Hash digest
SHA256 c7df3c816a710c52a7101a9bdaf60bb6579de7058d703bbcb81b27af7a10e3e7
MD5 c40976067168f9c3aa8ee36578d4e04f
BLAKE2b-256 9ee34ad10012bb4e79792cea069deddd454709e63b7bf3f2ecd1d677cdb345e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyecm_tools-1.0.2-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 992d2279844f1b6c21b662d7cc04f4b15c2f7d59295b2dd2b5a12ad5c4beab70
MD5 86b27b7ded2c3a67c425205ba8646062
BLAKE2b-256 ce3094baa6c3394a9a6e1a0d3c39f7f2735df5a5ed1dde346c246488299b4fe0

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.2-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.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a6b3d29030eb05d99f5d117ea2cad60cd206a261e865ee743429cf24e0a8a49a
MD5 9f4c350848e15224f6234846225c04f4
BLAKE2b-256 6877cebec2a7c016c567588b38e5a622654bab2fe85738b29bb013e77f96179c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyecm_tools-1.0.2-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d465f60f201dd3ad37c8a652a350509ead58aee889b269f4fb532c179f144130
MD5 84654fca9f8a63c1f68c60c089ed6cdf
BLAKE2b-256 a18af18418180e23121846a279a08082967ff38c2aac4e768a388566fc60a626

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.2-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.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e905e5715699a22d30f6bcca864207779cca8a8dfda545cc71829610cd463a0d
MD5 1199b1f1c8b05c88ec3a16b37c9ca8b2
BLAKE2b-256 9125b5b9344465910471c09083e111abfd745b513b0919ea36453428b5bfb85c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyecm_tools-1.0.2-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 17fcbc63eb554f33b12e6b684464af8f5278635956fa647094871d7f8ef051d3
MD5 c015f2c6104639a0cd7eb347fc1589b4
BLAKE2b-256 4938bcccdf0edf99d96f3ba1a42e12e244f46f76ba7221e220988b1eed5e8e01

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.2-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.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8d470672d3c5aa978ec0ee3a1d150ee125db7f6cd2c621bcfc7a744ef5920d2b
MD5 3fad5d963b9401a98954f45c4e402263
BLAKE2b-256 21f31e25a0f42c5622f7bf39c17d7fa16e7194f4de0b61a2a698ca3fdae1c26b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyecm_tools-1.0.2-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 dca03c1c8e82c0a7feb858496d4c17e3172b290358f00ba4682da90eb745a32c
MD5 efdbdc2b9abf0ecca2379698dc2c8354
BLAKE2b-256 5387817f89a3d5abd2558a1c3d065cc7667d5c5f65e4894d3d1f5c5165681453

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.2-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.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 56bb436368a0460fb39c5fa86e822f492312bee8fdb5cfab1b699957198cde74
MD5 2ac167e1392c94eb9dd1c8ef4291bd0d
BLAKE2b-256 95a4b88dbd810f1946215bafe41e415fd797728396791b2b65d6241da7e9f503

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyecm_tools-1.0.2-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 97b3d248b3bfe8d0bf450acfbcdc4f333d4a26cf164c5286cec5c7cf75d631a8
MD5 b607049e92092fd5e0a772f9d8ba6ebe
BLAKE2b-256 ff3a42565815b743250c7c481da190942f797f8bc5a915273d5fb0ac69536f2a

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.2-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.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2fe15a43767f49e0d5d03185531487309fcc93d8151d5929e3b3bcfc680625d6
MD5 279e226aba91ec6cbc98eb3c206e3b5e
BLAKE2b-256 ce53676c72fe59a78acec0f30237d279a8592bb940e74d3a22b328e43e5f0847

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyecm_tools-1.0.2-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 289d0ef2aeee59f869de7a0ecda59f7c18014a2d23e085dd211a3ca93476fa55
MD5 f415450e3b1def9056611a4c3ec5202b
BLAKE2b-256 6d9346d68afd0da4231123c70598b621ce96a2c11f8b2d898a0c753e287f8c3d

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.2-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.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ac646c64f90cdec7e3843ec634c58815ac369ab2f3ed5c133151c705b2db993e
MD5 3d6b4a6e068f66cd61a01c08e793bf7d
BLAKE2b-256 eb4c9a58bb536e2284b52ea08fdb2ee9ebb17bfd32b0e9dcd6b544aa2c710138

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyecm_tools-1.0.2-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c9fcfee57526497dc72179376630c052e72eb6e0573ea3019981c51ba24fd526
MD5 ae9e5b4d83c6952fe36066c919c544b4
BLAKE2b-256 ab3625727bec8137aca109b9c222fb631f5bc3fe5eeea26c13535452f44e09b3

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.2-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.2-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 101c205d3bcf4b6c84b228109f73b4e1881defe2b390aeb1061550fd3fe616e7
MD5 8a15825459182f9804eb924f6f9535bf
BLAKE2b-256 ab2b98dd8f36f30d555f454d5aa2b566a58fedb2efaffd3443253a8556ea0553

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyecm_tools-1.0.2-cp38-cp38-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5eaaa7b1a7eeed68a237294274e2830f60ece374d9d88f59826f75f56e870770
MD5 2f875a333b1eb084518619137af738d0
BLAKE2b-256 2c34fd6605a5a67cc2283cf4fe021bc7656d7346aa640cc792497af33d0b1f66

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.2-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.2-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 44053867d2b97017e36802e28d513e97a2a705231aac54bfd95253a2097cdc01
MD5 6d569a4d51cd81c82af540a942e3da70
BLAKE2b-256 71b053de4cb0cacc7d0325d76ed3b91a02c65a3a4c19f7c9e1e278c5d4fda016

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