没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
AVI Files
The Microsoft Audio/Video Interleaved (AVI) file format is a RIFF file specification used wit
h applications that capture, edit, and playback audio/video sequences. In general, AVI files co
ntain multiple streams of different types of data. Most AVI sequences will use both audio an
d video streams. A simple variation for an AVI sequence uses video data and does not requir
e an audio stream. Specialized AVI sequences might include a control track or MIDI track as
an additional data stream. The control track could control external devices such as an MCI
videodisc player. The MIDI track could play background music for the sequence. While a spe
cialized sequence requires a specialized control program to take advantage of all its capabilitie
s, applications that can read and play AVI sequences can still read and play an AVI sequenc
e in a specialized file. (These applications ignore the non-AVI data in the specialized file.) T
his chapter primarily describes AVI files containing only audio and video data.
This chapter covers the following topics:
• The required chunks of an AVI file
• The optional chunks of an AVI file
• Developing routines to write AVI files
For additional information about RIFF files, see the Microsoft Windows Multimedia Programm
er's Guide and Microsoft Windows Multimedia Programmer's Reference.
For additional information about installable compressors and decompressors, see chapter 10, "
Video Compression and Decompression Drivers."
AVI RIFF Form
AVI files use the AVI RIFF form. The AVI RIFF form is identified by the four-character co
de "AVI ". All AVI files include two mandatory LIST chunks. These chunks define the form
at of the streams and stream data. AVI files might also include an index chunk. This
optional chunk specifies the location of data chunks within the file. An AVI file with these c
omponents has the following form:
RIFF ('AVI '
LIST ('hdrl'
.
.
.
)
LIST ('movi'
.
.
.
)
['idx1'<AVI Index>]
)
The LIST chunks and the index chunk are subchunks of the RIFF "AVI " chunk. The "AVI
" chunk identifies the file as an AVI RIFF file. The LIST "hdrl" chunk defines the format of
the data and is the first required list chunk. The LIST "movi" chunk contains the data for t
he AVI sequence and is the second required list chunk. The "idx1" chunk is the optional ind
ex chunk. AVI files must keep these three components in the proper sequence.
The LIST "hdrl" and LIST "movi" chunks use subchunks for their data. The following examp
le shows the AVI RIFF form expanded with the chunks needed to complete the LIST "hdrl"
and LIST "movi" chunks:
RIFF ('AVI '
LIST ('hdrl'
'avih'(<Main AVI Header>)
LIST ('strl'
'strh'(<Stream header>)
'strf'(<Stream format>)
'strd'(additional header data)
.
.
.
)
.
.
.
)
LIST ('movi'
{SubChunk | LIST('rec '
SubChunk1
SubChunk2
.
.
.
)
.
.
.
}
.
.
.
)
['idx1'<AVIIndex>]
)
The following sections describe the chunks contained in the LIST "hdrl" and LIST "movi" ch
unks as well as the "idx1" chunk.
Data Structures for AVI Files
Data structures used in the RIFF chunks are defined in the AVIFMT.H header file. The refer
ence section at the end of this chapter describes the data structures that can be used for the
main AVI header, stream header, AVIIndex, and palette change chunks.
The Main AVI Header LIST
The file begins with the main header. In the AVI file, this header is identified with "avih" fo
ur-character code. The header contains general information about the file, such as the number
of streams within the file and the width and height of the AVI sequence. The main header
has the following data structure defined for it:
typedef struct {
DWORD dwMicroSecPerFrame;
DWORD dwMaxBytesPerSec;
DWORD dwReserved1;
DWORD dwFlags;
DWORD dwTotalFrames;
DWORD dwInitialFrames;
DWORD dwStreams;
DWORD dwSuggestedBufferSize;
DWORD dwWidth;
DWORD dwHeight;
DWORD dwScale;
DWORD dwRate;
DWORD dwStart;
DWORD dwLength;
} MainAVIHeader;
The dwMicroSecPerFrame field specifies the period between video frames. This value indicat
es the overall timing for the file.
The dwMaxBytesPerSec field specifies the approximate maximum data rate of the file. This
value indicates the number of bytes per second the system must handle to present an AVI se
quence as specified by the other parameters contained in the main header and stream header
chunks.
The dwFlags field contains any flags for the file. The following flags are defined:
AVIF_HASINDEX
Indicates the AVI file has an "idx1" chunk.
AVIF_MUSTUSEINDEX
Indicates the index should be used to determine the order of presentation of the data.
AVIF_ISINTERLEAVED
Indicates the AVI file is interleaved.
AVIF_WASCAPTUREFILE
Indicates the AVI file is a specially allocated file used for capturing real-time video.
AVIF_COPYRIGHTED
Indicates the AVI file contains copyrighted data.
The AVIF_HASINDEX and AVIF_MUSTUSEINDEX flags applies to files with an index chu
nk. The AVI_HASINDEX flag indicates an index is present. The AVIF_MUSTUSEINDEX fla
g indicates the index should be used to determine the order of the presentation of the data.
When this flag is set, it implies the physical ordering of the chunks in the file does not corr
espond to the presentation order.
The AVIF_ISINTERLEAVED flag indicates the AVI file has been interleaved. The system ca
n stream interleaved data from a CD-ROM more efficiently than non-interleaved data. For mo
re information on interleaved files, see "Special Information for Interleaved Files."
The AVIF_WASCAPTUREFILE flag indicates the AVI file is a specially allocated file used f
or capturing real-time video. Typically, capture files have been defragmented by user so video
capture data can be efficiently streamed into the file. If this flag is set, an application shoul
d warn the user before writing over the file with this flag.
The AVIF_COPYRIGHTED flag indicates the AVI file contains copyrighted data. When this f
lag is set, applications should not let users duplicate the file or the data in the file.
The dwTotalFrames field of the main header specifies the total number of frames of data in
file.
The dwInitialFrames is used for interleaved files. If you are creating interleaved files, specif
y the number of frames in the file prior to the initial frame of the AVI sequence in this fiel
d.
The dwStreams field specifies the number of streams in the file. For example, a file with au
dio and video has 2 streams.
The dwSuggestedBufferSize field specifies the suggested buffer size for reading the file. Gen
erally, this size should be large enough to contain the largest chunk in the file. If set to zer
o, or if it is too small, the playback software will have to reallocate memory during playback
which will reduce performance. For an interleaved file, the buffer size should be large enoug
h to read an entire record and not just a chunk.
The dwWidth and dwHeight fields specify the width and height of the AVI file in pixels.
The dwScale and dwRate fields are used to specify the general time scale that the file will
use. In addition to this time scale, each stream can have its own time scale. The time scale i
n samples per second is determined by dividing dwRate by dwScale.
The dwStart and dwLength fields specify the starting time of the AVI file and the length of
the file. The units are defined by dwRate and dwScale. The dwStart field is usually set to
zero.
The Stream Header ("strl") Chunks
剩余12页未读,继续阅读
cornbrother
- 粉丝: 1
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页