This page is based on the document 'Description of the 4X Movie (4xm) File Format' by Mike Melanson found at http://multimedia.cx/4xm-format.txt.
- Company: 4X Technologies
- Website: Defunct, but key files are mirrored at http://samples.mplayerhq.hu/game-formats/4xm/
- Samples: http://samples.mplayerhq.hu/game-formats/4xm/
The 4xm file format transports video data compressed with 4X Technologies' proprietary 4xm Video codec. It also transports audio data interleaved with the coded video chunks. The format supports multiple audio language tracks, as well. The audio can be either uncompressed PCM or a custom packing for IMA ADPCM: 4X IMA ADPCM.
The technology is intended for use in computer and console games.
All multi-byte numbers are little endian.
The 4xm file format is quite reminiscent of the Microsoft Audio/Video Interleaved (AVI) file format. A 4xm file is comprised of a series of chunks that are identified by human-readable four-character codes (fourccs). There are two types of chunks. The first type is a LIST chunk which encapsulates other chunks. A LIST chunk begins with a 12-byte preamble which is laid out as follows:
bytes 0-3 fourcc: 'LIST' bytes 4-7 length of LIST chunk, not including LIST fourcc or length fields, but including the chunk type bytes 8-11 chunk type, e.g.: 'HEAD'
A list chunk contains any number of the second type of chunk, which is laid out as follows:
bytes 0-3 chunk type fourcc bytes 4-7 length of chunk, not including the chunk type or length bytes 8.. chunk data
Additionally, a 4xm file begins with the following RIFF header:
bytes 0-3 fourcc: 'RIFF' bytes 4-7 file size, not including RIFF fourcc or file size fields bytes 8-11 RIFF sub-type fourcc: '4XMV'
4xm files have the following general structure:
RIFF header LIST-HEAD chunk LIST-HNFO chunk LIST-TRK_ chunk LIST-VTRK chunk LIST-STRK chunk [..more tracks..] LIST-MOVI chunk LIST-FRAM chunk LIST-FRAM chunk LIST-FRAM chunk [..more frame tracks..]
A LIST-HNFO chunk is known to contain name, info, and std_ chunks. A name chunk has the following structure:
bytes 0-3 fourcc: 'name' bytes 4-7 length of name data bytes 8.. variable-length DOS/Windows path and filename of 4xm file
An info chunk has the following structure:
bytes 0-3 fourcc: 'info' bytes 4-7 length of info data bytes 8.. variable-length info field, apparently the name and version of the software used to create the 4xm file; example: "Packed with 4xmovie v.188.8.131.521"
A std_ chunk has the following structure:
bytes 0-3 fourcc: 'std_' bytes 4-7 length of std_ data (always appears to be 8) bytes 8-11 data rate bytes 12-15 framerate
The framerate is represented as a 32-bit, single precision IEEE floating point number (a float type in C). Common framerates include:
on-disk (hex) byteswapped hex framerate 00 00 70 41 41700000 15 fps 00 00 F0 41 41F00000 30 fps
A LIST-TRK_ chunk contains any number of LIST_?TRK chunks (where ? = 'V' for a video track and 'S' for a sound track) which define the format of various audio/video tracks within the file. A 4xm file may contain multiple audio tracks and possibly multiple video tracks.
A LIST_?TRK has typically contains a name chunk and a ?trk format chunk, where ? = 'v' for a video format chunk and 's' for a sound format chunk. A name chunk has the following structure:
bytes 0-3 fourcc: 'name' bytes 4-7 length of name data bytes 8.. variable-length DOS/Windows path and filename of file that was used as the data for this track
A vtrk chunk has the following structure:
bytes 0-3 fourcc: 'vtrk' bytes 4-7 length of vtrk structure (68 or 0x44 bytes) bytes 8-35 unknown bytes 36-39 video width bytes 40-43 video height bytes 44-47 video width (again?) bytes 48-51 video height (again?) bytes 52-75 unknown
A strk chunk has the following structure:
bytes 0-3 fourcc: 'strk' bytes 4-7 length of strk structure (40 or 0x28 bytes) bytes 8-11 track number bytes 12-15 audio type: 0 = PCM, 1 = 4X IMA ADPCM bytes 16-35 unknown bytes 36-39 number of audio channels bytes 40-43 audio sample rate bytes 44-47 audio sample resolution (8 or 16 bits)
A LIST-MOVI chunk contains any number of LIST-FRAM chunks. A LIST-FRAM chunk contains any number of ?frm chunks (where ? = 'i', 'p', or 'c') and snd_ chunks. The ifrm, pfrm, and cfrm identifiers refer to the 3 frame types (I, P, and C) in the 4xm Video coding scheme.