- Daggerfall VID File Format 5 December 2003 This is the format for the .VID files that come with TES:Daggerfall. They contain short videos used in the game for intros and for the main quest. OVERALL VID FORMAT ======================================= The over file is composed of a main header followed blocks of audio and video data. bytes 1 - 787 : Header bytes 788+ Audio/Video Blocks ... The type of block is identified by the first byte in the block. 0x01 = Video, Compression #1 0x03 = Video, Compression #2 0x04 = Video, Compression #3 0x14 = End Of File 0x7D = Audio 0xA6 = Audio, Start Frame HEADER ======================================= The header is always the first 787 bytes of the VID file. Bytes 1 - 3: ASCII Always "VID" Bytes 4 - 5: INT16 Always 0x00 02 (512) Bytes 6 - 7: INT16 Number of Frames Bytes 8 - 9: INT16 Video Frame Width (256 or 320) Bytes 10 - 11: INT16 Video Frame Height (200) Bytes 12 - 13: INT16 Unknown Bytes 14 - 16: ??? Always 0x0E 00 02 Bytes 17 - 784: RGB 256-color VGA palette. Each palette entry is composed of 3 triplets (R/G/B) ranging in value from 0 to 63. Bytes 785 - 787: ??? Always 0x7C 00 00 (might be a special record?) AUDIO BLOCK - 0xA6 and 0x7D ======================================= The audio blocks hold the audio for each frame. Bytes 1 - 1: CHAR8 Block Type (0xA6 or 0x7D). Both types appear to have the same format. The 0xA6 block is always the first block in the file after the header. Bytes 2 - 3: INT16 Audio block data length Bytes 4 - ?: AUDIO Audio data. 8-bit, 11025 Hz audio VIDEO BLOCK - 0x01, 0x03 and 0x04 ======================================= The basic structure of the video blocks is all the same: Bytes 1 - 1: CHAR8 Block Type (0x01, 0x03 or 0x04). Bytes 2 - 3: INT16 Unknown value Bytes 4 - ?: VIDEO Compressed video data. Each type of video block has a slightly different compression format (see below for details). Unfortunately there is no record size so you must completely parse the video data in order to find the next block. It is important to note exactly how the video frames go together. Only the 0x03 video block actually contains a full frame of data. The 0x01 and 0x04 types only contain the pixels that have changed from the previous frame. Thus, generally in order to render any one frame you must also render all previous frames up to the first 0x03 video block. The transparent pixel for 0x01 and 0x04 frames is the pixel 205 (0xCD). The video frames are played back usually at around 10 frames per second. Use the audio block length to determine the playing time for a frame (some frames, such as the first or last, are longer than others). VIDEO COMPRESSION - 0x01 ======================================= The video data in a form of RLE compression with the following algorithim used for uncompression: InputByte = Read 1 Byte From File if ( InputByte >= 0x80 ) RunLength = InputByte - 0x80 Add RunLength Transparent Pixels to Frame else if ( InputByte == 0 ) End of Video Frame else RunLength = InputByte Read RunLength Bytes From File and Copy to Frame endif VIDEO COMPRESSION - 0x03 ======================================= This is usually the first video block in the file and contains a full frame of video in regular RLE format. The basic uncompressing algorithm is: InputByte = Read 1 Byte From File /* RLE compression */ if (InputByte >= 0x80) NumberofBytes = InputByte - 0x80 InputByte = Read 1 Byte From File Add NumberofBytes of InputByte to Video Frame else if (InputByte == 0) End of Video Frame else NumberofBytes = InputByte Read NumberofBytes from File and Copy to Video Frame endif VIDEO COMPRESSION - 0x04 ======================================= This format has an extra header variable: Bytes 4 - 5: INT16 Y-Offset. The video frame data starts at this line in the frame. What follows is the video frame data in the same format as the 0x01 type. CREDITS ======================================= Andux (andux@bigfoot.com) http://meepo.dnsalias.org/ (slow, frequently offline site) http://scrawnykid.virtualave.net/ (fast, slightly broken site) ICQ: 24517071 Dave Humphrey (dave@uesp.net) http://www.uesp.net/ Gavid Clayton (interkarma@yahoo.com.au)