Microsoft has specified the format for storage of digital video (DV) data in AVI files. Conforming to this specification will ensure that the AVI files authored in this format will be compatible with future versions of the Microsoft® DirectShow® digital video architecture for the Microsoft® Windows® platform.
This article provides background information to understand the format of Audio-Video Interleaved (AVI) files containing DV audio and video data, or information for programmers who use DV-AVI files on other platforms. Applications that read or write AVI files should use the File Source (Async) filter with the AVI Splitter filter and the AVI MUX filter with the File Writer filter and their associated interfaces provided in the DirectShow architecture, rather than developing the routines to perform these services. These filters simplify the programming requirements for accessing these files.
This article also describes the format of AVI files containing DV data. Specific FOURCCs (four-character codes) for interleaved DV data streams and DV compressor/decompressor stream handlers are defined. The stream format structure for DV data is defined. Specifications for two methods of storing DV data in the AVI file format are specified.
It is assumed that the reader is familiar with the DV data format. (This format is defined in the Specification of Consumer-use Digital VCRs, also called the Blue Book).
This article contains the following sections.
For more information about resource interchange file format (RIFF) files, see the Windows Software Development Kit (SDK) Multimedia Programmer's Guide and Multimedia Programmer's Reference.
For more information about AVI files, see Chapter 6 of the Microsoft Video for Windows Development Kit version 1.1 Programmer's Guide and version 1.02 of the OpenDML AVI File Format Extensions published by the OpenDML AVI M-JPEG File Format Subcommittee, February 28, 1996.
For more information on compressors and decompressors, see the Video Compression and Decompression Drivers section of the Windows DDK Documentation in the MSDN Library.
There are two types of DV AVI files:
Interleaved DV data can be stored in its native format as a single stream within an AVI RIFF file. This has the advantage of using the minimum amount of data storage for DV. The primary disadvantage is that this file format is not backward-compatible with Video for Windows, because it doesn't contain either a video 'vids' or an audio 'auds' stream. Support is provided for the interleaved DV stream through the DV Muxer and DV Splitter filters provided with DirectShow.
DV data can be stored in a single stream within an AVI RIFF file by specifying the 'iavs' (interleaved audio and video stream) FOURCC (four-character code) in the fccType member and either of the 'dvsd', 'dvhd', or 'dvsl' FOURCCs in the fccHandler member of the 'strh' stream header chunk. The frames per second of the video stream must be specified in the dwRate and dwScale members and the total number of video blocks in the 'movi' chunk in the dwLength member.
The 'dvsd' stream handler FOURCC specifies that the DV data is as defined in Part 2 of the Specification of Consumer-use Digital VCRs. Video is in the format of 525 lines at 29.97 Hz (525-60) or 625 lines at 25.00 Hz (625-50).
The 'dvhd' stream handler FOURCC specifies that the DV data is as defined in Part 3 of the Specification of Consumer-use Digital VCRs. Video is in the format of 1125 lines at 30.00 Hz (1125-60) or 1250 lines at 25.00 Hz (1250-50).
The 'dvsl' stream handler FOURCC specifies that the DV data is as defined in Part 6 of Specification of Consumer-use Digital VCRs. Video is in the format of high-compression SD (SDL).
Note The remainder of this article provides definitions for 'dvsd' streams.
The stream header chunk must be followed by DVINFO stream format chunk. The DVINFO stream format has the following data structure defined for it.
typedef struct tag_DVINFO { DWORD dwDVAAuxSrc; DWORD dwDVAAuxCtl; DWORD dwDVAAuxSrc1; DWORD dwDVAAuxCtl1; DWORD dwDVVAuxSrc; DWORD dwDVVAuxCtl; DWORD dwDVReserved[2]; } DVINFO, *PDVINFO;
The actual DV data is stored as '##dc' chunks in the 'movi' chunk (the ## in the format represents the stream identifier). Each chunk contains one frame of data, either 10 or 12 DV DIF sequences for 525-60 or 625-50 systems, respectively. The DV SD ('dvsd') DIF sequence format is defined in Part 2 of the Specification of Consumer-use Digital VCRs.
The following diagram illustrates the playback of an AVI file with one DV data stream using a DirectShow filter graph (the DV Splitter and DV Video Decoder filters are included in DirectShow specifically to deal with DV data). The table that follows the diagram defines the media types.
Media | Major type | Subtype | Format structure |
---|---|---|---|
A | MEDIATYPE_Stream | MEDIASUBTYPE_AVI | none |
B | MEDIATYPE_iavs | MEDIASUBTYPE_dvsd, MEDIASUBTYPE_dvhd, or MEDIASUBTYPE_dvsl | DVINFO |
C | MEDIATYPE_VIDEO | MEDIASUBTYPE_dvsd, MEDIASUBTYPE_dvhd, or MEDIASUBTYPE_dvsl | DVINFO |
D | MEDIATYPE_AUDIO | NULL | WAVEFORMATEX |
E | MEDIATYPE_VIDEO | standard video types | VIDEOINFO |
The following diagram illustrates the creation of an AVI file with one DV data stream by using a DirectShow filter graph (the DV Video Encoder and DV Muxer filters are included in DirectShow specifically to deal with DV data). The preceding table defines the media types. Upstream filters (not shown) can be of any combination to produce the proper media types, D and E.
The following diagram illustrates the creation of an AVI file with one DV data stream using a source filter that communicates through hardware device drivers with a DV device (such as a 1394-based DV camcorder) for DV data input, by using a DirectShow filter graph (the source filter is included in DirectShow specifically to deal with DV data). The preceding table defines the media types.
The following diagram illustrates the output of an AVI file with one DV data stream using a sink filter that communicates through hardware device drivers with a DV device (such as a 1394-based DV camcorder) for DV data output, by using a DirectShow filter graph (the sink filter is included in DirectShow specifically to deal with DV data). The preceding table defines the media types.
The following example shows the AIFF RIFF form for an AVI file with one DV data stream, expanded with completed header chunks.
00000000 RIFF (0FAE35D4) 'AVI ' 0000000C LIST (00000106) 'hdrl' 00000018 avih (00000038) dwMicroSecPerFrame : 33367 dwMaxBytesPerSec : 3728000 dwPaddingGranularity : 0 dwFlags : 0x810 HASINDEX | TRUSTCKTYPE dwTotalFrames : 2192 dwInitialFrames : 0 dwStreams : 1 dwSuggestedBufferSize : 120000 dwWidth : 720 dwHeight : 480 dwReserved : 0x0 00000058 LIST (0000006C) 'strl' 00000064 strh (00000038) fccType : 'iavs' fccHandler : 'dvsd' dwFlags : 0x0 wPriority : 0 wLanguage : 0x0 undefined dwInitialFrames : 0 dwScale : 100 (29.970 Frames/Sec) dwRate : 2997 dwStart : 0 dwLength : 2192 dwSuggestedBufferSize : 120000 dwQuality : 0 dwSampleSize : 0 rcFrame : 0,0,720,480 000000A4 strf (00000020) dwDVAAuxSrc : 0x........ dwDVAAuxCtl : 0x........ dwDVAAuxSrc1 : 0x........ dwDVAAuxCtl1 : 0x........ dwDVVAuxSrc : 0x........ dwDVVAuxCtl : 0x........ dwDVReserved[2] : 0,0 000000CC LIST (0FADAC00) 'movi' 0FADACD4 idx1 (00008900)
Interleaved DV data can be split into a video stream and one to four audio streams within an AVI RIFF file. This has the advantage of being backward-compatible with Video for Windows, because it contains a standard video 'vids' stream and at least one standard audio 'auds' stream The primary disadvantage is that this file format requires the audio data to be redundantly stored as audio streams. The "video" stream is actually the native interleaved DV data stream. However, as a standard 'vids' stream with a handler type of 'dvsd', the DV Video Decoder is used. This format also requires that "captured" files are split by using the DV Splitter filter before they are written as AVI files.
DV data can be stored as a video stream with a separate number of audio streams in an AVI RIFF file. The video stream is specified with a standard video stream header (the fccType member value is 'vids'). The fccHandler member is specified as 'dvsd', 'dvhd', or 'dvsl'. The frames per second of the video stream must be specified in the dwRate and dwScale members and the total number of video blocks in the 'movi' chunk in the dwLength member.
In this AVI file containing DV video as a 'vids' stream and DV audio as 'auds' streams form of DV, the video stream format chunk is a standard BITMAPINFOHEADER structure. The stream format chunk can be optionally extended to include the DVINFO structure, by increasing the stream format chunk size from 40 bytes (size of the BITMAPINFOHEADER structure) to 72 bytes (size of BITMAPINFOHEADER plus DVINFO structures) and immediately following the BITMAPINFOHEADER data structure with a DVINFO data structure.
The audio stream(s) is specified with a standard audio stream header (the fccType member value is 'auds'). The fccHandler member is not used for audio streams.
The DV video data is stored as '##dc' chunks, as defined in the preceding description of an AVI file with one DV data, and the audio data is stored as '##wb' chunks in the 'movi' chunk.
The following diagram illustrates the playback of an AVI file containing DV video as a 'vids' stream and DV audio as 'auds' streams, by using a DirectShow filter graph (the DV Video Decoder filter is included in DirectShow specifically to deal with DV data). The DV media types table defines the media types.
The following diagram illustrates the creation of an AVI file containing DV video as a 'vids' stream and DV audio as 'auds' streams, using a DirectShow filter graph (the DV Video Decoder is included in DirectShow specifically to deal with DV data). The DV media types table defines the media types. Upstream filters (not shown) can be of any combination to produce the proper media types, D and E.
The following diagram illustrates the creation of an AVI file containing DV video as a 'vids' stream and DV audio as 'auds' streams using a source filter that communicates through hardware device drivers with a DV device (such as a 1394-based DV camcorder) for DV data input, by using a DirectShow filter graph (the source and DV Splitter filters are included in DirectShow specifically to deal with DV data). The DV media types table defines the media types.
The following diagram illustrates the output of an AVI file containing DV video as a 'vids' stream and DV audio as 'auds' streams using a sink filter that communicates through hardware device drivers with a DV device (such as a 1394-based DV camcorder) for DV data output, by using a DirectShow filter graph (the DV Muxer and sink filters are included in DirectShow specifically to deal with DV data). The DV media types table defines the media types.
The following example shows the AIFF RIFF form for an AVI file containing DV video as a 'vids' stream and DV audio as 'auds' streams expanded with completed header chunks (including optional DVINFO data following the BITMAPINFO in the 'strf' sub-chunk for the 'vids' stream).
00000000 RIFF (103E2920) 'AVI ' 0000000C LIST (00000146) 'hdrl' 00000018 avih (00000038) dwMicroSecPerFrame : 33367 dwMaxBytesPerSec : 3728000 dwPaddingGranularity : 0 dwFlags : 0x810 HASINDEX | TRUSTCKTYPE dwTotalFrames : 2192 dwInitialFrames : 0 dwStreams : 2 dwSuggestedBufferSize : 120000 dwWidth : 720 dwHeight : 480 dwReserved : 0x0 00000058 LIST (00000094) 'strl' 00000064 strh (00000038) fccType : 'vids' fccHandler : 'dvsd' dwFlags : 0x0 wPriority : 0 wLanguage : 0x0 undefined dwInitialFrames : 0 dwScale : 100 (29.970 Frames/Sec) dwRate : 2997 dwStart : 0 dwLength : 2192 dwSuggestedBufferSize : 120000 dwQuality : 0 dwSampleSize : 0 rcFrame : 0,0,720,480 000000A4 strf (00000048) biSize : 40 biWidth : 720 biHeight : 480 biPlanes : 1 biBitCount : 24 biCompression : 0x64737664 'dvsd' biSizeImage : 120000 biXPelsPerMeter : 0 biYPelsPerMeter : 0 biClrUsed : 0 biClrImportant : 0 dwDVAAuxSrc : 0x........ dwDVAAuxCtl : 0x........ dwDVAAuxSrc1 : 0x........ dwDVAAuxCtl1 : 0x........ dwDVVAuxSrc : 0x........ dwDVVAuxCtl : 0x........ dwDVReserved[2] : 0,0 000000F4 LIST (0000005E) 'strl' 00000100 strh (00000038) fccType : 'auds' fccHandler : ' ' dwFlags : 0x0 wPriority : 0 wLanguage : 0x0 undefined dwInitialFrames : 0 dwScale : 1 (32000.000 Samples/Sec) dwRate : 32000 dwStart : 0 dwLength : 2340474 dwSuggestedBufferSize : 4272 dwQuality : 0 dwSampleSize : 4 rcFrame : 0,0,0,0 00000140 strf (00000012) wFormatTag : 1 PCM nChannels : 2 nSamplesPerSec : 32000 nAvgBytesPerSec : 128000 nBlockAlign : 4 wBitsPerSample : 16 cbSize : 0 00000814 LIST (103D0EF4) 'movi' 103D1710 idx1 (00011210)
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.
Modifications to the original AVI file specification made in the OpenDML AVI File Format Extensions are not discussed in this section. For further information on these extensions, see version 1.02 of the OpenDML AVI File Format Extensions published by the OpenDML AVI M-JPEG File Format Subcommittee, February 28, 1996.
This section contains the following topics.
AVI files use the AVI RIFF form. The AVI RIFF form is identified by the FOURCC (four-character code) 'AVI '. All AVI files include two mandatory LIST chunks. These chunks define the format of the stream 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 components 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 the AVI sequence and is the second required LIST chunk. The 'idx1' chunk is the index 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 example 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>) 'strn'(<Stream name>) ... ) . . . ) LIST ('movi' {SubChunk | LIST ('rec ' SubChunk1 SubChunk2 . . . ) . . . } . . . ) ['idx1'<AVI Index>] )
This and following sections describe the chunks contained in the LIST 'hdrl' and LIST 'movi' chunks. The 'idx1' chunk is not described in this document. For more information on the 'idx1' chunk and indexes in AVI files, see version 1.02 of the OpenDML AVI File Format Extensions published by the OpenDML AVI M-JPEG File Format Subcommittee, February 28, 1996.
The file begins with the main header. In the AVI file, this header is identified by the 'avih' FOURCC (four-character code). The 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 AVI main header structure is defined as follows:
typedef struct { DWORD dwMicroSecPerFrame; DWORD dwMaxBytesPerSec; DWORD dwReserved1; DWORD dwFlags; DWORD dwTotalFrames; DWORD dwInitialFrames; DWORD dwStreams; DWORD dwSuggestedBufferSize; DWORD dwWidth; DWORD dwHeight; DWORD dwReserved[4]; } MainAVIHeader;
AVIF_HASINDEX | Indicates the AVI file has an 'idx1' chunk containing an index at the end of the file. For good performance, all AVI files should contain an index. |
AVIF_MUSTUSEINDEX | Indicates that the index, rather than the physical ordering of the chunks in the file, should be used to determine the order of presentation of the data. For example, you could use this to create a list of frames for editing. |
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. Applications should warn the user before writing over a file with this flag set because the user probably defragmented this file. |
AVIF_COPYRIGHTED | Indicates the AVI file contains copyrighted data and software. When this flag is used, software should not permit the data to be duplicated. |
The main header is followed by one or more 'strl' chunks. (A 'strl' chunk is required for each data stream.) These chunks contain information about the streams in the file. Each 'strl' chunk must contain a stream header and stream format chunk. Stream header chunks are identified by the FOURCC (four-character code) 'strh' and the stream format chunks are identified by the FOURCC 'strf'. In addition to the stream header and stream format chunks, the 'strl' chunk might also contain a stream-header data chunk and a stream name chunk. Stream-header data chunks are identified by the FOURCC 'strd'. Stream name chunks are identified by the FOURCC 'strn'.
The stream header structure contains header information for a single stream of a file.
typedef struct { FOURCC fccType; FOURCC fccHandler; DWORD dwFlags; DWORD dwPriority; DWORD dwInitialFrames; DWORD dwScale; DWORD dwRate; DWORD dwStart; DWORD dwLength; DWORD dwSuggestedBufferSize; DWORD dwQuality; DWORD dwSampleSize; RECT rcFrame; } AVIStreamHeader;
The stream header specifies the type of data the stream contains, such as audio or video, by means of a FOURCC.
'vids' | Indicates the stream contains video data. The stream format chunk contains a BITMAPINFO structure that can include palette information. |
'auds' | Indicates the stream contains audio data. The stream format chunk contains a WAVEFORMATEX or PCMWAVEFORMAT structure. |
'txts' | Indicates the stream contains text data. |
AVISF_DISABLED | Indicates this stream should not be enabled by default. |
AVISF_VIDEO_PALCHANGES | Indicates this video stream contains palette changes. This flag warns the playback software that it will need to animate the palette. |
The last eight members describe the playback characteristics of the stream. These factors include the playback rate (dwScale and dwRate), the starting time of the sequence (dwStart), the length of the sequence (dwLength), the size of the playback buffer (dwSuggestedBuffer), an indicator of the data quality (dwQuality), and the sample size (dwSampleSize).
Some of the members in the stream header structure are also present in the main header structure. The data in the main header applies to the whole file, while the data in the stream header structure applies only to a stream.
A stream format ('strf') chunk must follow a stream header ('strh') chunk. The stream format chunk describes the format of the data in the stream. For video streams, the information in this chunk is a BITMAPINFO structure (including palette information if appropriate). For audio streams, the information in this chunk is a WAVEFORMATEX or PCMWAVEFORMAT structure. (The WAVEFORMATEX structure is an extended version of the WAVEFORMAT structure.) For more information about this structure and other stream types, see the New Multimedia Data Types and Data Techniques Standards Update.
The 'strl' chunk might also contain an additional stream-header data ('strd') chunk. If used, this chunk follows the stream format chunk. The format and content of this chunk is defined by installable compression or decompression drivers. Typically, drivers use this information for configuration. Applications that read and write RIFF files do not need to decode this information. They transfer this data to and from a driver as a memory block.
The optional 'strn' stream name chunk provides a zero-terminated text string describing the stream. (The AVI file functions can use this chunk to let applications identify the streams they want to access by their names.)
An AVI player associates the stream headers in the LIST 'hdrl' chunk with the stream data in the LIST 'movi' chunk by using the order of the 'strl' chunks. The first 'strl' chunk applies to stream 0, the second applies to stream 1, and so forth.
For example, if the first 'strl' chunk describes the wave audio data, the wave audio data is contained in stream 0. Similarly, if the second 'strl' chunk describes video data, then the video data is contained in stream 1.
Following the header information is a LIST 'movi' chunk that contains chunks of the actual data in the streams - that is, the pictures and sounds themselves. The data chunks can reside directly in the LIST 'movi' chunk or they might be grouped into 'rec' chunks. The 'rec' grouping implies that the grouped chunks should be read from disk all at once. This is used only for files specifically interleaved to play from CD-ROM.
Like any RIFF chunk, the data chunks contain a FOURCC (four-character code) to identify the chunk type. A FOURCC is a 32-bit quantity represented as a sequence of one to four ASCII alphanumeric characters, padded on the right with blank characters. The FOURCC that identifies each chunk consists of the stream number and a two-character code that defines the type of information encapsulated in the chunk. For example, a waveform chunk is identified by a two-character code of 'wb'. If a waveform chunk corresponded to the second LIST 'hdrl' stream description, it would have a FOURCC of '01wb'.
Note While two-character codes are a convenient way to describe a stream, do not expect them to be recognized by other applications. Use FOURCCs when creating a stream or transferring the information to other applications.
Because all the format information is in the header, the audio data contained in these data chunks does not contain any information about its format. An audio data chunk has the following format (the ## in the format represents the stream identifier):
WAVE Bytes '##wb' BYTE abBytes[];
Video data can be compressed or uncompressed DIBs. An uncompressed DIB has BI_RGB specified for the biCompression member in its associated BITMAPINFO structure. A compressed DIB has a value other than BI_RGB specified in the biCompression member. For more information about compression formats, see the description of the BITMAPINFOHEADER data structure in the Microsoft Windows Programmer's Reference.
A data chunk for an uncompressed DIB contains RGB video data. These chunks are identified by a two-character code of 'db' (db is an abbreviation for DIB bits). Data chunks for a compressed DIB are identified by a two-character code of 'dc' (dc is an abbreviation for DIB compressed). Neither data chunk will contain any header information about the DIBs. The data chunk for an uncompressed DIB has the following form:
DIB Bits '##db' BYTE abBits[];
The data chunk for a compressed DIB has the following form.
Compressed DIB Bits '##dc' BYTE abBits[];
Video data chunks can also define new palette entries used to update the palette during an AVI sequence. For more information on specifying palette information, see Video for Windows Programmer's Guide.
Text streams can use arbitrary two-character codes.
The BITMAPINFOHEADER structure contains information for the video stream of an AVI RIFF file. This structure has the following members.
typedef struct tagBITMAPINFOHEADER { DWORD biSize; LONG biWidth; LONG biHeight; WORD biPlanes; WORD biBitCount; DWORD biCompression; DWORD biSizeImage; LONG biXPelsPerMeter; LONG biYPelsPerMeter; DWORD biClrUsed; DWORD biClrImportant; } BITMAPINFOHEADER;
When the value in the biBitCount member is set to greater than eight, video drivers can assume bitmaps are true color and they do not use a color table.
When the value in the biBitCount member is set to less than or equal to eight, video drivers can assume the bitmap uses a palette or color table defined in the BITMAPINFO data structure. This data structure has the following members:
typedef struct tagBITMAPINFO { BITMAPINFOHEADER bmiHeader; RGBQUAD bmiColors[1]; } BITMAPINFO;
The BITMAPINFO bmiheader member specifies a BITMAPINFOHEADER structure. The BITMAPINFO bmiColors member specifies an array of RGBQUAD data types that define the colors in the bitmap.
The WAVEFORMATEX structure contains information for the audio stream(s) of an AVI RIFF file. This structure has the following members.
typedef struct waveformat_extended_tag { WORD wFormatTag; WORD nChannels; DWORD nSamplesPerSec; DWORD nAvgBytesPerSec; WORD nBlockAlign; WORD wBitsPerSample; WORD cbSize; } WAVEFORMATEX;
DirectShow currently supports the following AVI 2.0 file format extensions.
See the specification in version 1.02 of the OpenDML AVI File Format Extensions published by the OpenDML AVI M-JPEG File Format Subcommittee, February 28, 1996.
Top of Page
© 2000 Microsoft and/or its suppliers. All rights reserved. Terms of Use.