AVI文件格式-文件总格式

 这一系列的文章都是从MSDN上拷贝出来的,先记到这里,后面会一步步把它翻译出来的。

由于本人英语水平有限,翻译的可能不完全正确,请各位注意。

 

AVI RIFF 文件参考

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. )

微软的AVI文件格式是一种RIFF文件,它可以被其它程序控制、编辑和播放的音视频序列。一般情况下,AVI文件包含了多个不同类型的数据流。大多数AVI的这些序列都包含了音频和视频两种数据流。稍微变异了的AVI这种序列只使用视频流而不需要音频流。

 

(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. )

本文不介绍扩展的OpenDML AVI文件格式。更多的这些扩展信息,请参考《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. )

一个FOURCC(四字符码)是一个32位的无符号整数,它由4个ASCII字符连接而成。例如,'abcd'用低位在前的系统来表示就是0x64636261。FOURCCs可以包含空格,所以' abc'就是一个有效的FOURCC。AVI文件格式就是用FOURCC码来标识数据流类型、数据块、索引入口和其它的信息。

 

RIFF文件格式(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 morelists andchunks. )

AVI文件格式基于RIFF(资源交换文件格式)文件格式。一个RIFF文件由一个RIFF头或者和跟在其后面的数个列表和数据块共同组成。

  • RIFF头具有如下的格式(The RIFF header has the following form):

    'RIFF' fileSize fileType (data)

    where 'RIFF' is the literal FOURCC code 'RIFF', fileSize is a 4-byte value giving the size of the data in the file, andfileType is a FOURCC that identifies the specific file type. The value offileSize includes the size of the fileType FOURCC plus the size of the data that follows, but does not include the size of the 'RIFF' FOURCC or the size offileSize. The file data consists of chunks and lists, in any order.

          'RIFF'  [文件大小] [文件类型] (数据)

          'RIFF'就是FOURCC码'RIFF'[文件大小]是一个4字节的数值,用来描述文件中数据的大小[文件类型]也是一个FOURCC,用来标识文件的类型。[文件大小]包含[文件类型]和其后的数据,但是不包含'RIFF'[文件大小]共8个字节。数据由数据块和列表组成,它们可以任意顺序排列

  • 一个数据块具有如下的格式(A chunk has the following form):

    [ckID] [ckSize] [ckData]

    where ckID is a FOURCC that identifies the data contained in the chunk,ckSize is a 4-byte value giving the size of the data inckData, andckData is zero or more bytes of data. The data is always padded to nearestWORD boundary.ckSize gives the size of the valid data in the chunk; it does not include the padding, the size ofckID, or the size ofckSize.

          [ckID]是一个四字符码,它标示本数据块,[ckSize]占用4个字节,表明[ckData]的大小,[ckData]的内容可以没有。数据总是以2字节对齐,而[ckSize]只指定有效数据的大小,不包括[ckID][ckSize]占用的大小和为字节对齐而添加的额外无效数据。

  • 一个列表具有如下格式(A list has the following form):

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

    where 'LIST' is the literal FOURCC code 'LIST', listSize is a 4-byte value giving the size of the list,listType is a FOURCC code, andlistData consists of chunks or lists, in any order. The value oflistSize includes the size oflistType plus the size oflistData; it does not include the 'LIST' FOURCC or the size oflistSize.

          'LIST'就是四字符码'LIST',[listSize]是4个字节指定的列表大小,[listType]是一个四字符码,[listData]由任意顺序的数据块和列表组成。[listSize]指定的长度包括[listType][listData]合起来的大小,而不包括'LIST'四字符码和[listSize]占用的空间。

 

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

本节剩下的部分使用下面的形式来描述RIFF数据块:

ckID ( ckData )

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

数据块大小被隐藏掉了,使用这种形式,一个列表可以被看做是:

'LIST' ( listType ( listData ) )

可选择的元素被放到了括弧中(Optional elements are placed in brackets):[ optional element ]

AVI RIFF格式(AVI RIFF Form)

AVI files are identified by the FOURCC 'AVI ' 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"标示了AVI这种文件格式。所有的AVI文件都至少包含了两个基本的LIST列表,一个是用于描述数据流的格式,一个是数据流本身。AVI文件可能还会包含一个索引数据块,它用来描述数据块在文件中的位置。这些信息的结构如下:


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.

'hdrl'这个列表定义了数据格式,它是要求的第一个列表,必需存在。'movi'列表包含了数据流,这个列表也必需存在。'idx1'列表包含了索引信息。AVI文件要求这三个列表的顺序必需如上述这样排列。

  • Note   The OpenDML extensions define another type of index, identified by the FOURCC 'indx'.
  • 注意 OpenDML中的索引定义使用了四字符码‘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:

'hdrl'和'movi'两个列表采用了嵌套子数据块的方法来保存它的数据。下面列出了把这两个列表展开时所需要的子块的情形:

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 AVI主信息头

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 of an AVIMAINHEADER structure.

'hdrl'列表以AVI主信息头结构开始,它被’avih'数据块所包含。AVI主信息头结构包含了整个AVI文件的总体信息,比如数据流个数、图像的宽和高。本信息的结构定义是AVIMAINHEADER

AVI Stream Headers  AVI数据流信息头

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 of an AVISTREAMHEADER structure.

在主信息头的后面,跟随一个或者多个'strl'列表,每个数据流都必需有一个'strl'列表。每个'strl'都包含了文件中一个数据流的基本信息,它至少需要包含一个数据流头块'strh'和数据流格式块'strf'。有时候可能会有附加信息存在,此时一个'strl'列表会包含一个数据流头结构的数据块'strd'和一个数据流名称的数据块'strn'。

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 is aBITMAPINFO structure, including palette information if appropriate. For audio streams, the information is aWAVEFORMATEX structure.

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 should 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 codeDescription
dbUncompressed video frame
dcCompressed video frame
pcPalette change
wbAudio data

For example, if stream 0 contains audio, the data chunks for that stream would have the FOURCC '00wb'. If stream 1 contains video, the data chunks for that stream would 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') contains anAVIPALCHANGE structure. If a stream contains palette changes, set the AVISF_VIDEO_PALCHANGES flag in thedwFlags member of theAVISTREAMHEADER structure 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 of anAVIOLDINDEX structure with entries for each data chunk, including 'rec ' chunks. If the file contains an index, set the AVIF_HASINDEX flag in thedwFlags member of theAVIMAINHEADER structure.

Other Data Chunks

Data can be aligned in an AVI file by inserting 'JUNK' chunks as needed. Applications should ignore the contents of a 'JUNK' chunk.

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值