AVI file format-total file format

Source: Internet
Author: User

This series of articles are all copied from msdn. Remember them first, and they will be translated step by step later.

Due to my limited level of English, the translation may not be completely correct. Please note that.

 

Avi riff file reference

This is preliminary documentation and subject to change.

 

(The Microsoft AVI file format is a riff File Specification used with applications that capture, edit, and play back audio-video sequences. in general, AVI files contain multiple streams of different types of data. most Avi sequences use both audio and video streams. A simple variation for an AVI sequence uses video data and does not require an audio stream .)

Microsoft's AVI file format is a riff file that can be controlled, edited, and played by other programs. Generally, an AVI file contains multiple data streams of different types. Most Avi sequences contain audio and video data streams. The slightly mutating Avi sequence only uses video streams instead of audio streams.

 

(This section does not describe the opendml AVI file format extensions. For further information on these extensions, seeOpendml AVI file format extensions, Published by The opendml Avi M-JPEG file format Subcommittee .)

This document does not describe the extended opendml AVI file format. For more information about these extensions, see 《Opendml AVI file format extensions.

 

Fourccs)

(A fourcc (four-character code) is a 32-bit unsigned integer created by concatenating four ASCII characters. for example, the fourcc 'abcd' is represented on a little-Endian system as 0x64636261. fourccs can contain space characters, so 'abc' is a valid fourcc. the AVI file format uses fourcc codes to identify stream types, data chunks, index entries, and other information .)

A fourcc (four character code) is a 32-bit unsigned integer, which is composed of four ASCII characters. For example, 'abcd' is expressed as 0x64636261 in the system with a low position. Fourccs can contain spaces, so 'abc' is a valid fourcc. The AVI file format uses the fourcc code to identify the data stream type, data block, index entry, and other information.

 

Riff File Format)

(The AVI file format is based on the riff (resource Interchange File Format) document format. A riff file consists of a riff header followed by zero or moreListsAndChunks.)

The AVI file format is based on the riff (Resource Exchange File Format) file format. A riff file consists of a riff header or several lists and data blocks following it.

  • The riff header has the following format (the riff header has the following form ):

    'RIFF' fileSize fileType (data)

    Where 'riff' is the literal fourcc code 'riff ',fileSizeIs a 4-byte value giving the size of the data in the file, andfileTypeIs a fourcc that identifies the specific file type. The valuefileSizeParameter des the size offileTypeFourcc plus the size of the data that follows, but does not include the size of the 'riff' fourcc or the sizefileSize. The file data consists of chunks and lists, in any order.

'Riff' [file size] [file type] (data)

'Riff'Is the fourcc code 'riff',[File size]It is a 4-byte value used to describe the data size in the file.,[File type]It is also a fourcc used to identify the file type.[File size]Include[File type]And the subsequent data, but does not contain'Riff'And[File size]8 bytes in total.DataComposed of data blocks and lists, which can be arranged in any order

  • A data block has the following format (a chunk has the following form ):

    [ckID] [ckSize] [ckData]

    WhereckIDIs a fourcc that identifies the data contained in the chunk,ckSizeIs a 4-byte value giving the size of the data inckData, AndckDataIs zero or more bytes of data. The data is always padded to nearestWordBoundary.ckSizeGives the size of the valid data in the chunk; it does not include the padding, the sizeckID, Or the sizeckSize.

[Ckid]It is a four-digit code, which indicates the data block,[Cksize]Occupies 4 bytes, indicating[Ckdata],[Ckdata]. Data is always aligned in 2 bytes, while[Cksize]Only specify the size of valid data, not including[Ckid],[Cksize]The occupied size and extra invalid data added for byte alignment.

  • A list has the following format (A list has the following form ):

    'LIST' [listSize] [listType] [listData]

    Where 'LIST' is the literal fourcc code 'LIST ',listSizeIs a 4-byte value giving the size of the list,listTypeIs a fourcc code, andlistDataConsists of chunks or lists, in any order. The valuelistSizeParameter des the sizelistType Plus the sizelistData; It does not include the 'LIST' fourcc or the sizelistSize.

'LIST'Is the four-character code 'LIST ',[Listsize]Is the list size specified by four bytes,[Listtype]Is a four-digit code,[Listdata]It consists of data blocks and lists in any order.[Listsize]The specified length includes[Listtype]And[Listdata]The combined size, excluding the 'LIST' four-character code and[Listsize]The occupied space.

 

The remainder of this section uses the following notation to describe riff chunks:

The rest of this section uses the following format to describe riff data blocks:

ckID ( ckData )

Where the chunk size is implicit. Using this notation, a list can be represented:

The data block size is hidden. In this form, a list can be viewed:

'LIST' ( listType ( listData ) )

The selectable elements are placed in the ARC (optional elements are placed in brackets ):[ optional element ]

Avi riff form)

AVI files are identified by the fourcc 'av' In the riff header. all AVI files include two mandatory list chunks, which define the format of the streams and the stream data, respectively. an AVI file might also include an index chunk, which gives the location of the data chunks within the file. an AVI file with these components has the following form:

RIFF ('AVI '      LIST ('hdrl' ... )      LIST ('movi' ... )      ['idx1' (<AVI Index>) ]     )

The 'hdrl' List defines the format of the data and is the first required list chunk. the 'movi' list contains the data for the AVI sequence and is the second required list chunk. the 'idx1' list contains the index. AVI Files must keep these three components in the proper sequence.

  • NoteThe opendml extensions define another type of index, identified by the fourcc 'indx '.

The 'hdrl' and 'movi' lists use subchunks for their data. The following example shows the AVI riff form expanded with the chunks needed to complete these lists:

RIFF ('AVI '      LIST ('hdrl'            'avih'(<Main AVI Header>)            LIST ('strl'                  'strh'(<Stream header>)                  'strf'(<Stream format>)                  [ 'strd'(<Additional header data>) ]                  [ 'strn'(<Stream name>) ]                  ...                 )             ...           )      LIST ('movi'            {SubChunk | LIST ('rec '                              SubChunk1                              SubChunk2                              ...                             )               ...            }            ...           )      ['idx1' (<AVI Index>) ]     )

Avi main Header

The 'hdrl' list begins with the main AVI Header, which is contained in an 'avih 'chunk. the main header contains global information for the entire AVI file, such as the number of streams within the file and the width and height of the AVI sequence. the main header chunk consists ofAvimainheaderStructure.

AVI stream Headers

One or more 'strl' lists follow the main header. A 'strl' list is required for each data stream. each 'strl' list contains information about one stream in the file, and must contain a stream header chunk ('strh') and a stream format chunk ('strf '). in addition, a 'strl' list might contain a stream-header data chunk ('strd') and a stream name chunk ('strn ').

The stream header chunk ('strh') consists ofAvistreamheaderStructure.

A stream format chunk ('strf') must follow the stream header chunk. the stream format chunk describes the format of the data in the stream. the data contained in this chunk depends on the stream type. for video streams, the information isBitmapinfoStructure, including palette information if appropriate. For audio streams, the information isWaveformatexStructure.

If the stream-header data ('strd') Chunk is present, it follows the stream format chunk. the format and content of this chunk are defined by the codec driver. typically, drivers use this information for configuration. applications that read and write AVI files do not need to interpret this information; they simple transfer it to and from the driver as a memory block.

The optional 'strn' chunk contains a null-terminated text string describing the stream.

The stream headers in the 'hdrl' list are associated with the stream data in the 'movi' list according to the order of the 'strl' chunks. the first 'strl' chunk applies to stream 0, the second applies to stream 1, and so forth.

Stream Data ('movi' List)

Following the header information is a 'movi' list that contains the actual data in the streams-that is, the video frames and audio samples. the data chunks can reside directly in the 'movi' list, or they might be grouped within 'rec 'lists. the 'rec 'grouping implies that the grouped chunks shoshould be read from disk all at once, and is intended for files that are interleaved to play from CD-ROM.

The fourcc that identifies each data chunk consists of a two-digit stream number followed by a two-character code that defines the type of information in the chunk.

Two-character code Description
DB Uncompressed video frame
DC Compressed Video Frame
PC Palette change
WB Audio Data

For example, if stream 0 contains audio, the data chunks for that stream wocould have the fourcc '00wb '. if stream 1 contains video, the data chunks for that stream wocould have the fourcc '01db' or '01dc '. video data chunks can also define new palette entries to update the palette during an AVI sequence. each palette-change chunk ('xxpc') containsAvipalchangeStructure. If a stream contains palette changes, set the avisf_video_palchanges flag inDwflagsMember ofAvistreamheaderStructure for that stream.

Text streams can use arbitrary two-character codes.

Avi index entries

An optional index ('idx1 ') chunk can follow the 'movi' list. The index contains a list of the data chunks and their location in the file. It consists ofAvioldindexStructure with entries for each data chunk, including 'rec 'chunks. If the file contains an index, set the avif_hasindex flag inDwflagsMember ofAvimainheaderStructure.

Other data chunks

Data can be aligned in an AVI file by inserting 'junk' Chunks as needed. Applications shoshould ignore the contents of a 'junk' chunk.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.