Monday, September 05, 2005

 

Some notes on AVI Manipulate - 1

1.
About AVI
http://en.wikipedia.org/wiki/AVI

2.
Microsoft's AVI RIFF File Reference
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directshow/htm/avirifffilereference.asp

3.
John P. McGowan's AVI Overview
http://www.jmcgowan.com/avi.html
http://www.jmcgowan.com/avitech.html

4.
From
http://pvdtools.sourceforge.net/aviformat.txt

THIS DOCUMENT IS IN THE PUBLIC DOMAIN, YOU ARE FREE TO COPY AND MODIFY IT AS YOU SEE FIT

BETA DOCUMENTATNION OF RIFF-AVI FILE FORMAT -- DO NOT TRUST FOR ACCURACY -- DOESN'T COVER OPENDML EXTENTIONS
YOU HAVE BEEN WARNED

Tree view of RIFF data chunks(ie. map of subchunks). LIST chunk will be added in next revision(the documentation I based this on didn't cover LIST chunks, oddly enough):

RIFF RIFF HEADER
|-AVI AVI CHUNK
|-hdrl MAIN AVI HEADER
| |-avih AVI HEADER
| |-strl STREAM LIST[One per stream]
| | |-strh STREAM HEADER[Requiered after above]
| | |-strf STREAM FORAMT
| | |-strd OPTIONAL -- STREAM DATA
| | |-strn OPTIONAL -- STREAM NAME
|-movi MOVIE DATA
| |-rec RECORD DATA[SEE BELOW]
| |-[data subchunks] RAW DATA[SEE BELOW]
|-idx1 AVI INDEX
|-[index data] DATA


DATA Map(ie sequential listing of all the data contained in the various chunks):

"RIFF"
dwChunkSize; - Chunk Size in Bytes
"AVI "
dwAVIChunkSize; - AVI chunk size
"LIST"
dwLIST1ChunkSize; - LIST chunk size
"hdrl"
"avih"
dwMicroSecPerFrame; - Specifies the number of microseconds between frames. This value indicates the overall timing for the file.
dwMaxBytesPerSec; - 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 sequence as specified by the other parameters contained in the main header and stream header chunks.
dwReserved1; - set to 0, reserved
dwFlags; - [Bit 4 - Has index(idx1), Bit 5 - Use index to determine how to read the AVI data, rather than the physical order of the chunks with the RIFF file, Bit 8 - AVI file is interleaved, Bit 16 - AVI file is optimized for live video capture, Bit 17 - AVI file contains copyrighted data]
dwTotalFrames; - Total number of frames
dwInitialFrames; - Specifies the initial frame for interleaved files. Noninterleaved files should specify zero. If you are creating interleaved files, specify the number of frames in the file prior to the initial frame of the AVI sequence in this member. For more information about the contents of this member, see "Special Information for Interleaved Files" in the Video for Windows Programmer's Guide.
dwStreams; - Specifies the number of streams in the file. For example, a file with audio and video has two streams.
dwSuggestedBufferSize; - Specifies the suggested buffer size for reading the file. Generally, this size should be large enough to contain the largest chunk in the file. If set to zero, 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 enough to read an entire record, and not just a chunk.
dwWidth; - Specifies the width of the AVI file in pixels.
dwHeight; - Specifies the height of the AVI file in pixels.
dwReserved[4]; - Reserved, set this array to 0
"LIST"
dwLISTChunkSize; - size of second LIST chunk
"strl"
"strh"
dwstrhSize; - size of strh
fccType; - FourCC code for type of data contained in this stream - 'auds' = audio stream, 'mids' = MIDI stream, 'txts' = Text stream, 'vids' = Video sterm
fccHandler; - FourCC of codec to use, for PVDTools this should be "DIB " or "Y8 " or "Y800" or "GREY" and eventually "Y4 "
dwFlags; - Ignore, too little documentation
wPriority; - Ignore
wLanguage; - Ignore
dwInitialFrames; - "How far audio data is skewed ahead of video frames in interleaved file."
dwScale; - "Used with dwRate(see below) to specify the time scale that this stream will use." Divide dwRate by dwScale to get frame rate/sample rate
dwRate; - See dwScale
dwStart; - "Specifies starting time for this stream." Usually 0.
dwLength; - Length of stream in units specified by dwRate and dwScale
dwSuggestedBufferSize; - Ignore
dwQualty; - Ignore
dwSampleSize; - Sample size, zero if varies - same a nBlockAlign in WAVEFORAMTEX
rcFrame; - RECT structure(struct of 4 shorts), ignore
"strf" - same format as BITMAPINFO
[strf stuff]
"LIST
dwLISTSize3; - Size of 3rd List chunk
"strl"
"strh"
size of strh
"auds"
above strh format
[typically a "JUNK" chunk goes here wehn using VirtualDub 1.5.xx or higher]
"LIST"
size of 4th LIST chunk(DWORD)
"01xx" -- ignore the xx, it's useless[the 01 stands for second stream identified in header]
[audio data]
"00xx" -- ignore the xx, it's useless[the 00 stands for first stream identified in header]
[video data]
[rinse, repeat the 01xx and 00xx chunks as needed]
"idx1"
size of idx1 chunk
chunkId
flags
offset of chunk
size of chunk
[rinse, repeat for each chunk of data]
"JUNK"
[blank info]

5.
www.FOURCC.org - Video Codecs and Pixel Formats
http://www.fourcc.org/

6.
The entry-points for avifil32
From http://www.webtropy.com/articles/dll-api.aspx?dll=avifil32

Import Ordinal Hint Function Entry Point
------ ----------- ----------- -------------------------- -----------

Export Ordinal Hint Function Entry Point
------ ----------- ----------- -------------------------- -----------
[C ] 1 (0x0001) 0 (0x0000) AVIBuildFilter 0x00005DC2
[C ] 2 (0x0002) 1 (0x0001) AVIBuildFilterA 0x00005DC2
[C ] 3 (0x0003) 2 (0x0002) AVIBuildFilterW 0x000059F0
[C ] 4 (0x0004) 3 (0x0003) AVIClearClipboard 0x0000390F
[C ] 5 (0x0005) 4 (0x0004) AVIFileAddRef 0x000053C8
[C ] 6 (0x0006) 5 (0x0005) AVIFileCreateStream 0x0000533B
[C ] 7 (0x0007) 6 (0x0006) AVIFileCreateStreamA 0x00005354
[C ] 8 (0x0008) 7 (0x0007) AVIFileCreateStreamW 0x0000533B
[C ] 9 (0x0009) 8 (0x0008) AVIFileEndRecord 0x000053BB
[C ] 10 (0x000A) 9 (0x0009) AVIFileExit 0x00004F7E
[C ] 11 (0x000B) 10 (0x000A) AVIFileGetStream 0x00005322
[C ] 12 (0x000C) 11 (0x000B) AVIFileInfo 0x00005290
[C ] 13 (0x000D) 12 (0x000C) AVIFileInfoA 0x00005290
[C ] 14 (0x000E) 13 (0x000D) AVIFileInfoW 0x00005264
[C ] 15 (0x000F) 14 (0x000E) AVIFileInit 0x00004F65
[C ] 16 (0x0010) 15 (0x000F) AVIFileOpen 0x00005209
[C ] 17 (0x0011) 16 (0x0010) AVIFileOpenA 0x00005209
[C ] 18 (0x0012) 17 (0x0011) AVIFileOpenW 0x00005122
[C ] 19 (0x0013) 18 (0x0012) AVIFileReadData 0x000053A2
[C ] 20 (0x0014) 19 (0x0013) AVIFileRelease 0x000053D5
[C ] 21 (0x0015) 20 (0x0014) AVIFileWriteData 0x000054FC
[C ] 22 (0x0016) 21 (0x0015) AVIGetFromClipboard 0x000037E7
[C ] 23 (0x0017) 22 (0x0016) AVIMakeCompressedStream 0x0000590D
[C ] 24 (0x0018) 23 (0x0017) AVIMakeFileFromStreams 0x0000BA8F
[C ] 25 (0x0019) 24 (0x0018) AVIMakeStreamFromClipboard 0x0000BDC6
[C ] 26 (0x001A) 25 (0x0019) AVIPutFileOnClipboard 0x000037AC
[C ] 27 (0x001B) 26 (0x001A) AVISave 0x000024F6
[C ] 28 (0x001C) 27 (0x001B) AVISaveA 0x000024F6
[C ] 29 (0x001D) 28 (0x001C) AVISaveOptions 0x00002F44
[C ] 30 (0x001E) 29 (0x001D) AVISaveOptionsFree 0x000025D0
[C ] 31 (0x001F) 30 (0x001E) AVISaveV 0x00002498
[C ] 32 (0x0020) 31 (0x001F) AVISaveVA 0x00002498
[C ] 33 (0x0021) 32 (0x0020) AVISaveVW 0x0000197B
[C ] 34 (0x0022) 33 (0x0021) AVISaveW 0x000023BE
[C ] 35 (0x0023) 34 (0x0022) AVIStreamAddRef 0x000053C8
[C ] 36 (0x0024) 35 (0x0023) AVIStreamBeginStreaming 0x00005894
[C ] 37 (0x0025) 36 (0x0024) AVIStreamCreate 0x0000582A
[C ] 38 (0x0026) 37 (0x0025) AVIStreamEndStreaming 0x000058D5
[C ] 39 (0x0027) 38 (0x0026) AVIStreamFindSample 0x000054D6
[C ] 40 (0x0028) 39 (0x0027) AVIStreamGetFrame 0x0000E0C5
[C ] 41 (0x0029) 40 (0x0028) AVIStreamGetFrameClose 0x0000E0B2
[C ] 42 (0x002A) 41 (0x0029) AVIStreamGetFrameOpen 0x0000E161
[C ] 43 (0x002B) 42 (0x002A) AVIStreamInfo 0x0000540E
[C ] 44 (0x002C) 43 (0x002B) AVIStreamInfoA 0x0000540E
[C ] 45 (0x002D) 44 (0x002C) AVIStreamInfoW 0x000053E2
[C ] 46 (0x002E) 45 (0x002D) AVIStreamLength 0x000055B6
[C ] 47 (0x002F) 46 (0x002E) AVIStreamOpenFromFile 0x000057EC
[C ] 48 (0x0030) 47 (0x002F) AVIStreamOpenFromFileA 0x000057EC
[C ] 49 (0x0031) 48 (0x0030) AVIStreamOpenFromFileW 0x000057AE
[C ] 50 (0x0032) 49 (0x0031) AVIStreamRead 0x00005547
[C ] 51 (0x0033) 50 (0x0032) AVIStreamReadData 0x00005515
[C ] 52 (0x0034) 51 (0x0033) AVIStreamReadFormat 0x000054FC
[C ] 53 (0x0035) 52 (0x0034) AVIStreamRelease 0x000053D5
[C ] 54 (0x0036) 53 (0x0035) AVIStreamSampleToTime 0x000056D3
[C ] 55 (0x0037) 54 (0x0036) AVIStreamSetFormat 0x000053A2
[C ] 56 (0x0038) 55 (0x0037) AVIStreamStart 0x0000558E
[C ] 57 (0x0039) 56 (0x0038) AVIStreamTimeToSample 0x000055E7
[C ] 58 (0x003A) 57 (0x0039) AVIStreamWrite 0x00005569
[C ] 59 (0x003B) 58 (0x003A) AVIStreamWriteData 0x0000552E
[C ] 60 (0x003C) 59 (0x003B) CreateEditableStream 0x0000D4DC
[C ] 61 (0x003D) 60 (0x003C) DllCanUnloadNow 0x00006039
[C ] 62 (0x003E) 61 (0x003D) DllGetClassObject 0x00004CA3
[C ] 63 (0x003F) 62 (0x003E) EditStreamClone 0x0000BF5F
[C ] 64 (0x0040) 63 (0x003F) EditStreamCopy 0x0000BEC7
[C ] 65 (0x0041) 64 (0x0040) EditStreamCut 0x0000BE7E
[C ] 66 (0x0042) 65 (0x0041) EditStreamPaste 0x0000BF10
[C ] 67 (0x0043) 66 (0x0042) EditStreamSetInfo 0x0000BFE8
[C ] 68 (0x0044) 67 (0x0043) EditStreamSetInfoA 0x0000BFE8
[C ] 69 (0x0045) 68 (0x0044) EditStreamSetInfoW 0x0000BFA2
[C ] 70 (0x0046) 69 (0x0045) EditStreamSetName 0x0000C119
[C ] 71 (0x0047) 70 (0x0046) EditStreamSetNameA 0x0000C119
[C ] 72 (0x0048) 71 (0x0047) EditStreamSetNameW 0x0000C0A8
[C ] 73 (0x0049) 72 (0x0048) IID_IAVIEditStream 0x000012A8
[C ] 74 (0x004A) 73 (0x0049) IID_IAVIFile 0x000012E8
[C ] 75 (0x004B) 74 (0x004A) IID_IAVIStream 0x000012D8
[C ] 76 (0x004C) 75 (0x004B) IID_IGetFrame 0x000012B8



***************************| Module Dependency Tree |***************************
* *
* Legend: F Forwarded Module ? Missing Module 6 64-bit Module *
* D Delay Load Module ! Invalid Module *
* * Dynamic Module E Import/Export Mismatch or Load Failure *
* ^ Duplicate Module *
* *
* O Ordinal Function E Import/Export Error F Forwarded Function *
* C C Function R Called At Least Once * Dynamic Function *
* + C++ Function *
* *
********************************************************************************

7.
A Simple C# Wrapper for the AviFile Library
By Corinna John
Edit AVI files in .NET
http://www.codeproject.com/cs/media/aviFileWrapper.asp

It is a simple yet interesting try

a longer explanation can be found at
http://www.codeproject.com/csharp/steganodotnet4.asp

8.
C# RIFF Parser
By gtamir
Decode Resource Interchange Files (AVI, WAV, RMID...) using this pure C# parser.
From http://www.codeproject.com/csharp/RiffParser.asp

It is not only for AVI though



<< Home

This page is powered by Blogger. Isn't yours?