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). Theframe_rate_code(byte 7's low nibble) drives DTS scheduling during muxing. - audio — CRI ADX (
.sfa) with magic80 00,(c)CRIwatermark at offset0x11A, 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sfd_muxer-0.1.1.tar.gz.
File metadata
- Download URL: sfd_muxer-0.1.1.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20db6284fd492756644fe56c957f1bc21e5bcc0b8ea9353c9f8e2d2615af0d17
|
|
| MD5 |
c1ede6c2d6673956dff7a93bd03eeffe
|
|
| BLAKE2b-256 |
ec44d496f49d3cb57999dfb67d12b786bbb669487a7e502b61893fa1daa65bb1
|
File details
Details for the file sfd_muxer-0.1.1-py3-none-any.whl.
File metadata
- Download URL: sfd_muxer-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00f1565ac8a8e74ac71177cdeba616b7f6e6a4cb272fc2c1a47892c9e3529097
|
|
| MD5 |
50bbff1472658de3a20e71dd422971a6
|
|
| BLAKE2b-256 |
e929f364ce53b381b7f432a7ae95a1db2c3b4a0ae7e2dfb4129bb9aab7b1b190
|