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.1.tar.gz (10.9 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.1-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.1-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.1-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.1-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.1-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.1-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.1-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.1-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.1-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.1-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.1-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.1-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.1-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.1-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.1-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.1-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.1.tar.gz.

File metadata

  • Download URL: pyecm_tools-1.0.1.tar.gz
  • Upload date:
  • Size: 10.9 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.1.tar.gz
Algorithm Hash digest
SHA256 e15521c7843929c337679f801a5a38b2cb34e467ff3993e4301ac1131f8ea9dc
MD5 7f025df71b9707328a8dcefaff855a90
BLAKE2b-256 fa6f031c5fad2ea54d8b177ea65800822524d55b204d9452cf91d98d913ff4d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyecm_tools-1.0.1-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2659695729f1a97a28ca0c54eb66d4eb0bce8fc2e7d82798c56f9161ac9f049a
MD5 31944be91521b9f0a782002ded9a3b27
BLAKE2b-256 1c8346d57d631951edc4b8c27d73c055c7d3d458bbd2a4e5918b9a7b0aad9e7d

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.1-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.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4158ab6d196e4027090742375bd2e0b8b69be3a654dc389d0d110e7da84295f8
MD5 6ff9e4a71bf50cc968f58961dd8d6d7b
BLAKE2b-256 b02a82b4d2c0ea602c86bb44132bde38b7d24a08318b519ccc98db87697129d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyecm_tools-1.0.1-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 59776718b552743367a74b38dbd68d068b3ba497b1c6286c2949454c9c8a19ff
MD5 53380ab1c6638da922cbf4b9604b01fa
BLAKE2b-256 5c40ad9d0c727a427e0c9a31e12c013f5ae61e2edbfe332ba54ffede31a77297

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.1-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.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e0ca2830be75ae5758518b7685d7e2b962b619678ea76a96c220451321de2061
MD5 fcb078d13bb85b6fa535961d6a48fd72
BLAKE2b-256 be0fc8c63fe5b7948b1cd8576c36a8ca0cd3f7d678148a41932ffd352f651e19

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyecm_tools-1.0.1-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 545f4a09cdc3a9f026d6ef43350a685950301ce1696ffc3afd6e4fc6831f5f99
MD5 15ef0cbfcd12bc17e7ed853a8f334e96
BLAKE2b-256 62c3c880bbba32114996c4aaca6deb0145d3d81875bb3ea8a0bda39e5363dd32

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.1-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.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c92bcd66d75bf576cc686f85f6f74bdfe9a450c46c83a071535d13413729118a
MD5 1ead044c1d9cb6b27f830ca86b30962a
BLAKE2b-256 15890c31b22a614dcea3f9cdfc29db251c0a040290d2fc803fc27c4260eb131f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyecm_tools-1.0.1-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8ed2b47e28bf7e4fbe141394811e5b0648136d3442d9efc1bca6e9fbe3b4fc98
MD5 4aff0bf471aab0729e808ce9ceb6875a
BLAKE2b-256 c38e2ce67ffa34640c6276880f5ee6cce3b6ed43a30c35544be574234935f7cf

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.1-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.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 70852195adc7df3137d2b3eac30626f9c7175b30be172e08679a6edccb1f7b05
MD5 b477dd0c7ce61f1b0df7729a158d4489
BLAKE2b-256 7beebf9e9d74f6b2a3f8fc4f23466e9cabc36f990c02d0197518d2e256cf6721

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyecm_tools-1.0.1-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 830adbae979a60972056ee3e0b1aeac9e3df06c2b007a09c7ad3f682c361cebd
MD5 76eea48be96ac17037280ac33d7c8f64
BLAKE2b-256 b1dd5ab129e0108c353710aadd0f46a83f77ef5496bb7b1f8230119c1845805f

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.1-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.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f9be5848d74f689049abdd0041ae787917451fda662355f3c8d5b4434aea6e36
MD5 235fbd6e73c0dd5da687a0b34d5744a4
BLAKE2b-256 d482ad09f7d371539951c5bf6de89d8f7d62dbe2f4b321d45a649a63ed71c01a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyecm_tools-1.0.1-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ca0313bdfbc5ec36e3139cbc54db2a122e3bf536cccf816637209e34f0f83f9f
MD5 9ae2bc2f1027cfeb43446f95e6289c26
BLAKE2b-256 67fc62809fb2b5acd17932fcea6d4ef8364a9bc0167eb00d9b66aacc89ddae65

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.1-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.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2a96f2f04c38c1a3c4cb843779417b4f7614da6ce076eb7337669b78b8b17f09
MD5 64c08a47811531fe58cbfa09781d8968
BLAKE2b-256 b4c57ec091fca7af53f74787587d341d97f4935d31236a156b3b423ceb040a34

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyecm_tools-1.0.1-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 bcfc4ce21150e0652b44b124e2f7fc9f16e4114f291113c802176bbc211e96c5
MD5 ffeae05242b25e57c9087b7176697f4c
BLAKE2b-256 185bfa357fff5ca50c9bf2620a745e4b52ca1883ef971359b2318b64b5a8f806

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.1-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.1-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 53757eb41da5151907bf1d3fca4ed563848431db796e6a5b5cfac4e903880dcc
MD5 53b0e565e28b455b84f35d6a28a1e34a
BLAKE2b-256 66b00f91dbec0857afb598d1e9283381ec98574a2a082ed455ea050d9cabb991

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyecm_tools-1.0.1-cp38-cp38-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 eb556d3ce4855610cf51694d8c2407353b0b4cdb9796c110b1b3ec31872fe1e0
MD5 f5e44ff6c2dad8d272d8681163d5805d
BLAKE2b-256 bbdb16a7ed69aa3b34b69c03f935362d9a7daee11cce048f45776baf37f83c27

See more details on using hashes here.

File details

Details for the file pyecm_tools-1.0.1-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.1-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4857b5e056649b3053fb053b999d3e25c16e99dd19b16de3ecb662742bde8880
MD5 7c2db0cba146300bf7e1be0c4d7d80b8
BLAKE2b-256 d5695d20f2ed8a2e958cfbe435f51d476f4af4cd72cbd0081604fa88b560cf29

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