psxavenc is an open-source command-line tool for encoding audio and video data into formats commonly used on the original PlayStation.
Requirements:
- a recent version of FFmpeg libraries (
libavformat
,libavcodec
,libavutil
,libswresample
,libswscale
); - a recent version of Meson.
$ meson setup build
$ cd build
$ ninja install
Run psxavenc
.
Rescale a video file to ≤320x240 pixels (preserving aspect ratio) and encode it into a 15fps .STR file with 37800 Hz 4-bit stereo audio and 2352-byte sectors, meant to be played at 2x CD-ROM speed:
$ psxavenc -t str2cd -f 37800 -b 4 -c 2 -s 320x240 -r 15 -x 2 in.mp4 out.str
Convert a mono audio sample to 22050 Hz raw SPU-ADPCM data:
$ psxavenc -t spu -f 22050 in.ogg out.snd
Convert a stereo audio file to a 44100 Hz interleaved .VAG file with 8192-byte interleave and loop flags set at the end of each interleaved chunk:
$ psxavenc -t vagi -f 44100 -c 2 -L -i 8192 in.wav out.vag
Format | Audio | Channels | Video | Sector size |
---|---|---|---|---|
xa |
XA-ADPCM | 1 or 2 | None | 2336 bytes |
xacd |
XA-ADPCM | 1 or 2 | None | 2352 bytes |
spu |
SPU-ADPCM | 1 | None | |
spui |
SPU-ADPCM | Any | None | Any |
vag |
SPU-ADPCM | 1 | None | |
vagi |
SPU-ADPCM | Any | None | Any |
str2 |
None or XA-ADPCM | 1 or 2 | BS v2 | 2336 bytes |
str2cd |
None or XA-ADPCM | 1 or 2 | BS v2 | 2352 bytes |
sbs2 |
None | BS v2 | Any |
Notes:
vag
andvagi
are similar tospu
andspui
respectively, but add a .VAG header at the beginning of the file. The header is always 48 bytes long forvag
files, while in the case ofvagi
files it is padded to the size specified using the-a
option (2048 bytes by default). Note thatvagi
files with more than 2 channels and/or alignment other than 2048 bytes are not standardized.- The
sbs2
format (used in some System 573 games) is simply a series of concatenated BS v2 frames, each padded to the size specified by the-a
option, with no additional headers besides the BS frame headers.