Skip to main content

CRI SofDec MPEG Program Stream multiplexer for PS2 cutscenes (.sfd)

Project description

SFD Muxer

Multiplexer/demultiplexer for the CRI SofDec PS2 cutscene container (.sfd).

If this helped you, consider buying me a coffee

CRI SofDec is the streaming format used for video cutscenes in many PS2 / Dreamcast / GameCube games. It interleaves MPEG-1 video with CRI ADX audio in 0x800-byte sectors. Examples of games shipping .sfd cutscenes:

  • Magna Carta: Tears of Blood
  • Burnout, Burnout 2/3
  • Various Sega and CRI-licensed PS2/Dreamcast titles

Python port of nebulas-star/SFD_Muxer (C, 2021), restricted to the case of exactly 1 MPEG-1 video stream + 1 stereo CRI ADX audio (SofDec v1). Validated byte-equivalent to the reference C build for the cutscenes used in the Magna Carta undub.

Install

pip install sfd-muxer

Usage

Command Line

# Extract video and audio from a SFD file
sfd-muxer demux cutscene.sfd --video out.m1v --audio out.sfa

# Create a new SFD from video + audio
sfd-muxer mux --video subtitled.m1v --audio kr_audio.sfa -o cutscene.sfd

# Show SFD file info
sfd-muxer info cutscene.sfd

Python API

from sfd_muxer import SFD

# Demux
sfd = SFD.from_file("cutscene.sfd")
video = sfd.extract_video()   # MPEG-1 elementary stream
audio = sfd.extract_audio()   # CRI ADX (.sfa)

# Mux
sfd = SFD.mux(video, audio)
sfd.to_file("out.sfd")

# Or in-memory:
data = sfd.to_bytes()

Stream formats

  • video — raw MPEG-1 elementary stream starting with 00 00 01 B3 (sequence header). The frame_rate_code (byte 7's low nibble) drives DTS scheduling during muxing.
  • audio — CRI ADX (.sfa) with magic 80 00, (c)CRI watermark at offset 0x11A, and a header that includes block_size at +0x06, channel_count at +0x07, and big-endian u32 sample_rate at +0x08.

SFD layout

sector 0 (0x800 B):  pack_head + audio system_header + 0xBE padding
sector 1 (0x800 B):  pack_head + video system_header + 0xBE padding
sector 2 (0x800 B):  pack_head + Sofdec stream-message PES (0xBF) + zeros
sectors 3..N-1:      interleaved video (0xE0) / audio (0xC0) PES + 0xBE padding
                     (smallest pending DTS first)
final sector:        program_end (0x000001B9) + 0x7FC bytes of 0xFF

Credit

C reference implementation: nebulas-star/SFD_Muxer.

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

sfd_muxer-0.1.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

sfd_muxer-0.1.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file sfd_muxer-0.1.0.tar.gz.

File metadata

  • Download URL: sfd_muxer-0.1.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for sfd_muxer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b5406d805c1fe54de13a206e30f887ad2b75ca788e7c1f545754fa0d49a5c6b9
MD5 9e8d124f133532b05556a1763f0f9b36
BLAKE2b-256 18ad30110bce91cdf72b34865fb31e7b36372f4ea926dce4f45bc09283b5125a

See more details on using hashes here.

File details

Details for the file sfd_muxer-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sfd_muxer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for sfd_muxer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23e168ae2e7fc7d2c756ff0756aa801623d1a05980b703a0b3f6a271d2679c1f
MD5 8a46f78b6bb49c65ba9a9aca5f7f35a0
BLAKE2b-256 bcbb5dcc12f9a1ebea7831b925a000c7d512abbacea5a566c5c38f63ba091b39

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