Documentation  by JohnK Appendix A: QVIDEO

QAVI Component

This is a custom component that lets you read and create AVI movie files. AVI stands for audio-video interlace format. You can read 24, 8, or 4-bit color AVI files. However you can only create 24 bit graphics in uncompressed avi format (RLE is ok). Not all AVI files share the same compression, so make sure it is in an uncompressed format. ImageJ is great tool for converting AVI files into uncompressed format.. There is no support for audio yet. Also see video capture by vfw (video for widows)..  See limitations.
QAVI Properties
Field Type R/W Default




bpp
LONG R/W 24

Color depth in Bits per Pixel, only 24-bit color is supported for creating AVI files
BytesWritten LONG R

amount of memory written in each frame (equals bitmap size if completed)

Error STRING R

If an error occurs, this will provide a user friendly message.. 
FileType STRING R

string showing AVI file type header
FirstFrame LONG R/W 0

Frame number of  first video frame, usually is 0

FPS LONG R/W

Frames per second. This is the play-back speed. For MPEG conversion, FPS must be either 10, 12,  15, 24, 25,  or 30
FramesWritten   LONG R

when creating an AVI file this keeps track of total output in bytes

Left LONG RW 0
Top LONG RW 0
Right LONG RW
Bottom LONG       'sets the location of the video in the parent frame. It defaults to QBITMAP for writing. RW
Height LONG R

Image height of video images, all images should be the same size.

NumFrames  LONG R/W

Number of video frames
PaletteRGBQuad
Binary STRING holding the color table (Palette) for 8 and 4 bit video
R


'get the palette from an AVI
PaletteB(255)   AS BYTE
PaletteG(255)   AS BYTE
PaletteR(255)   AS BYTE

DEFINT i, j = 0
FOR i = 0 to 255
    PaletteB(i) = ASC(QAVI.PaletteRGBQuad[j])
    PaletteG(i) = ASC(QAVI.PaletteRGBQuad[j+1])
    PaletteR(i) = ASC(QAVI.PaletteRGBQuad[j+2])
    INC(j,4)
NEXT i


Quality LONG R/W 10000

image compression quality  from 0 (lowest) to 10000 (highest), only 10000 is currently supported for
creating AVI files.


SampleSize LONG R

Frame size in bytes

ShowDialog  INTEGER R/W

show windows compression, options dialog box    

ShowError INTEGER      RW false

 If True error messages will appear with a dialog box automatically

FileType      
AS STRING           'string showing AVI file type header R

CompressionType  AS STRING R/W

bitPlanes
bitmap bitplanes










QAVI Methods
Method Type Description Params




AVItoBMP FUNCTION  (AVIFile$, TheBMP AS QBITMAP, FrameNumber%) Write AVI frame to QBitmap. Pixel Format is set. Returns TRUE on success1

Bitmaps will be reformated for width and height. Returns TRUE on success
BMPtoAVIFile FUNCTION (TheBMP AS QBITMAP) Write bitmap to file, 24 bit only

 Serially stores the bitmap in the AVI file. All bitmaps must be the same size. Returns TRUE on success
CreateAVIFile FUNCTION (FileName$, Width%, Height%, FramesPerSecond%) Create an AVI  file to write

Example:
DIM Vid AS QAVI
Vid.CreateAVIFile("Custom.AVI",myBMP.Width,myBMP.Height, 15)
If sucessful, then the function returns TRUE,
and QAVI properties .Width, .Height, .FPS will be reset by the passed parameters
GetAVIFileInfo SUB (FileName$) Close AVI file after writing 0

 Read the AVI file and set Properties.  Returns TRUE on success
CloseAVIFile FUNCTION Close AVI file after writing 0

Closes all AVI handles and releases the AVI library memory.  Returns TRUE on success

QAVI Events
Event Type Occurs when... Params




none


QAVI  Examples

'************************************************************************** 
' Example 1 Read the format of an AVI file '************************************************************************** 
$INCLUDE <rapidq.inc>
$INCLUDE <QAVI.inc>

DIM myAVI AS QAVI
myAVI.ShowError = True
myAVI.GetAVIFileInfo("Test.avi")
myAVI.CloseAVIFile 'be sure to do this when done

Showmessage "the file is " + _
str$(MyAVI.Height) + _
" x " + str$(MyAVI.Width) + _
" , fps = " + str$(MyAVI.fps) + _
" , File type of: " + myAVI.FileType
Application.Terminate

 

'************************************************************************** 
' Example 2 Draw your own AVI file
'************************************************************************** 
$INCLUDE <rapidq.inc>
$INCLUDE <QAVI.inc>

DECLARE SUB PaintForm
DIM i as integer

CREATE TheBMP AS QBITMAP
Width = 160 'must be on a DWORD (32 bit) boundary
Height =120
PixelFormat = pf24bit
END CREATE

CREATE Form AS QFORM
ClientWidth = TheBMP.Width
ClientHeight = TheBMP.Height
OnPaint=PaintForm
END CREATE

CREATE myAVI AS QAVI
ShowError = True
NumFrames = 10
END CREATE

' create a new one at 10 frames per second
'properties .Width, .height, .fps will be reset after this function
myAVI.CreateAVIFile("Test.avi", TheBMP.Width, TheBMP.Height, 24, 10)
Form.Show

for i=1 to myAVI.NumFrames
WITH TheBMP
.FillRect(0,0, .width, .height, 0)
.Line(0,0, .width*Rnd, .height*Rnd, &Hff00)
END WITH
myAVI.BMPtoAVIFile(TheBMP)
Form.Repaint
next i
myAVI.CloseAVIFile
Application.Terminate


SUB PaintForm
Form.Draw(0,0, TheBMP.BMP)
END SUB

'************************************************************************** 
' Example 3 Get a single frame from an AVI file
'**************************************************************************
$INCLUDE <Rapidq2.inc>
$INCLUDE <QAVI.inc>

DIM MyAVI AS QAVI
DIM TheBMP AS QBitmapEX

'get the first frame
IF MyAVI.AVItoBMP ("test2.avi", TheBMP, 1) = 0 THEN
Showmessage MyAVI.Error
ELSE
'store it in the system clipboard
TheBMP.CopyToclipboard
END IF
MyAVI.CloseAVIFile 'be sure to close the object