Page 1 of 1

Avifil32 Library Import - AVISave() Parameters?

Posted: Sun Mar 27, 2011 8:04 pm
by D Ogre
I'm writing a import wrapper of the AVIFIL32 library for PureBasic 4.51. I'm using Lib2PBImport by t-soft to create a import library framework for the .lib file under the c:\Program Files\PureBasic\PureLibraries\Windows\Libraries. When the import file is generated, the AVISave() (Both ANSI and Unicode) is written out accepting no parameters.

MSDN states that the original function has six parameters:
http://msdn.microsoft.com/en-us/library ... s.85).aspx

Has this function depreciated in the library? Do I have the most recent .lib file? What gives?

Re: Avifil32 Library Import - AVISave() Parameters?

Posted: Mon Apr 04, 2011 12:28 am
by D Ogre
I'm still not sure exactly why the AVISave function in the PureBasic static .lib file contains no parameters. I thought that maybe someone here with more experience with this library would know. However, in my searches for an answer, I did find a little information about this particular function in general...

Based on VB source code by Ray Mercer, this function is compiled using the CDECL calling convention. This would
make it incompatible with the standard PureBasic IMPORT (we would use IMPORTC instead) command, which the rest of the library needs. This still doesn't explain why no parameters when MSDN clearly states the six parameters this function requires.

I've been searching all over the internet for the past few weeks in the hopes of compiling enough useful stuff to build a wrapper in PureBasic for the AVIFIL32 library. This is what I came up with so far:

Code: Select all

; ** AVIFIL32 Library Include File **

;              Author: D Ogre
;    Language Version: PureBasic 4.51
; Static Library Name: avifil32.lib ("Purelibraries\Windows\Libraries\avifil32.lib")
;     Wrapper Version: 1.0
; Original Build Date: 04/03/2011

;              Mod By: NA
;                Date: NA

; Form types, list types, and chunk types                     
#formtypeAVI                 = $20495641 ;Hex(mmioFOURCC("A", "V", "I", " "))
#listtypeAVIHEADER           = $6C726468 ;Hex(mmioFOURCC("h", "d", "r", "l"))
#ckidAVIMAINHDR              = $68697661 ;Hex(mmioFOURCC("a", "v", "i", "h"))
#listtypeSTREAMHEADER        = $6C727473 ;Hex(mmioFOURCC("s", "t", "r", "l"))
#ckidSTREAMHEADER            = $68727473 ;Hex(mmioFOURCC("s", "t", "r", "h"))
#ckidSTREAMFORMAT            = $66727473 ;Hex(mmioFOURCC("s", "t", "r", "f"))
#ckidSTREAMHANDLERDATA       = $64727473 ;Hex(mmioFOURCC("s", "t", "r", "d"))
#ckidSTREAMNAME              = $6E727473 ;Hex(mmioFOURCC("s", "t", "r", "n"))

#listtypeAVIMOVIE            = $69766F6D ;Hex(mmioFOURCC("m", "o", "v", "i"))
#listtypeAVIRECORD           = $20636572 ;Hex(mmioFOURCC("r", "e", "c", " "))

#ckidAVINEWINDEX             = $31786469 ;Hex(mmioFOURCC("i", "d", "x", "1"))

; Stream types for the fccType field.
#streamtypeVIDEO             = $73646976 ;Hex(mmioFOURCC("v", "i", "d", "s"))
#streamtypeAUDIO             = $73647561 ;Hex(mmioFOURCC("a", "u", "d", "s"))
#streamtypeMIDI              = $7364696D ;Hex(mmioFOURCC("m", "i", "d", "s"))
#streamtypeTEXT              = $73747874 ;Hex(mmioFOURCC("t", "x", "t", "s"))

; Basic chunk types
#cktypeDIBbit                = $6264 ;Hex(aviTWOCC("d", "b"))
#cktypeDIBcompressed         = $6364 ;Hex(aviTWOCC("d", "c"))
#cktypePALchange             = $6370 ;Hex(aviTWOCC("p", "c"))
#cktypeWAVEbytes             = $6277 ;Hex(aviTWOCC("w", "b"))

; Chunk id to use for extra chunks for padding.
#ckidAVIPADDING              = $4B4E554A ;Hex(mmioFOURCC("J", "U", "N", "K"))

; AVI file/stream errors
#AVIERR_OK                   = $00000000
#AVIERR_UNSUPPORTED          = $80044065
#AVIERR_BADFORMAT            = $80044066
#AVIERR_MEMORY               = $80044067
#AVIERR_INTERNAL             = $80044068
#AVIERR_BADFLAGS             = $80044069
#AVIERR_BADPARAM             = $8004406A
#AVIERR_BADSIZE              = $8004406B
#AVIERR_BADHANDLE            = $8004406C
#AVIERR_FILEREAD             = $8004406D
#AVIERR_FILEWRITE            = $8004406E
#AVIERR_FILEOPEN             = $8004406F
#AVIERR_COMPRESSOR           = $80044070
#AVIERR_NOCOMPRESSOR         = $80044071   
#AVIERR_READONLY             = $80044072
#AVIERR_NODATA               = $80044073
#AVIERR_BUFFERTOOSMALL       = $80044074
#AVIERR_CANTCOMPRESS         = $80044075
#AVIERR_USERABORT            = $800440C6
#AVIERR_ERROR                = $800440C7
#REGDB_E_CLASSNOTREG         = $80040154 

; Added for some stream functions
#AVIERR_UNSUCCESSSFUL        = -1

; uiFlags for AVISaveOptions
#ICMF_CHOOSE_KEYFRAME        = $1 
#ICMF_CHOOSE_DATARATE        = $2
#ICMF_CHOOSE_PREVIEW         = $4
#ICMF_CHOOSE_ALLCOMPRESSORS  = $8

; lFlags for AVIStreamFindSample
#FIND_NEXT                   = $1
#FIND_PREV                   = $4
#FIND_FROM_START             = $8
#FIND_KEY                    = $10
#FIND_ANY                    = $20
#FIND_FORMAT                 = $40

; lpbiWanted for AVIStreamGetFrameOpen 
; (Use the best format for the display.)
#AVIGETFRAMEF_BESTDISPLAYFMT = 1

; dwFlags for AVIStreamWrite
#AVIIF_LIST                  = $1
#AVIIF_KEYFRAME              = $10
#AVIIF_NOTIME                = $100
#AVIIF_COMPUSE               = $0FFF0000

#FOURCC_RIFF                 = $46464952 ;Hex(mmioFOURCC("R", "I", "F", "F"))
#FOURCC_LIST                 = $5453494C ;Hex(mmioFOURCC("L", "I", "S", "T"))

; dwFlags in the AVIFILEINFO Struct
#AVIFILEINFO_HASINDEX        = $10
#AVIFILEINFO_MUSTUSEINDEX    = $20
#AVIFILEINFO_ISINTERLEAVED   = $100
#AVIFILEINFO_TRUSTCKTYPE     = $800
#AVIFILEINFO_WASCAPTUREFILE  = $10000
#AVIFILEINFO_COPYRIGHTED     = $20000

; dwCaps in the AVIFILEINFO Struct
#AVIFILECAPS_CANREAD         = $1
#AVIFILECAPS_CANWRITE        = $2
#AVIFILECAPS_ALLKEYFRAMES    = $10
#AVIFILECAPS_NOCOMPRESSION   = $20

; dwFlags in the AVISTREAMINFO Struct
#AVISTREAMINFO_DISABLED      = $1
#AVISTREAMINFO_FORMATCHANGES = $10000

; dwFlags in the AVICOMPRESSOPTIONS Struct
; Each of these flags determines if the appropriate field in the structure 
; (dwInterleaveEvery, dwBytesPerSecond, and dwKeyFrameEvery) is payed attention to. 
#AVICOMPRESSF_INTERLEAVE     = $1
#AVICOMPRESSF_DATARATE       = $2
#AVICOMPRESSF_KEYFRAMES      = $4
#AVICOMPRESSF_VALID          = $8

; Modes for AVIFileOpen and AVIStreamOpenFromFile
#OF_READ                     = $0
#OF_WRITE                    = $1
#OF_READWRITE                = $2
#OF_SHARE_EXCLUSIVE          = $10
#OF_SHARE_DENY_WRITE         = $20
#OF_SHARE_DENY_READ          = $30
#OF_PARSE                    = $100
#OF_CREATE                   = $1000
#OF_PROMPT                   = $2000
#OF_EXIST                    = $4000
#OF_REOPEN                   = $8000

; ** These structures are provided for reference purposes only. They can be used
;    to send and recieve data to and from an AVI stream. There is no need to define
;    them because they already exist in PureBasic.

;typedef struct tagRECT { 
;  LONG left;
;  LONG top;
;  LONG right;
;  LONG bottom;
;} RECT;

;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, *PBITMAPINFOHEADER;

;typedef struct tagBITMAPINFO { 
;  BITMAPINFOHEADER bmiHeader; 
;  RGBQUAD bmiColors[1]; 
;} BITMAPINFO; 

;typedef struct tagBITMAP {
;  LONG   bmType;
;  LONG   bmWidth;
;  LONG   bmHeight;
;  LONG   bmWidthBytes;
;  WORD   bmPlanes;
;  WORD   bmBitsPixel;
;  LPVOID bmBits;
;} BITMAP, *PBITMAP;

;typedef struct { 
;    WORD  wFormatTag; 
;    WORD  nChannels; 
;    DWORD nSamplesPerSec; 
;    DWORD nAvgBytesPerSec; 
;    WORD  nBlockAlign; 
;    WORD  wBitsPerSample; 
;    WORD  cbSize; 
;} WAVEFORMATEX;

; Added for audio beyond 2 channels
Structure WAVEFORMATEXTENSIBLE
  Format.WAVEFORMATEX ; Built-in PureBasic WAVEFORMATEX struct 
  StructureUnion
    wValidBitsPerSample.w
       wSamplesPerBlock.w
              wReserved.w
  EndStructureUnion
  dwChannelMask.l
      SubFormat.GUID
EndStructure

; ** Define AVIFIL32 PureBasic Structures

; Struct for AVIFileInfo and EditStreamSetInfo
Structure AVIFILEINFO 
       dwMaxBytesPerSec.l 
                dwFlags.l 
                 dwCaps.l 
              dwStreams.l 
  dwSuggestedBufferSize.l 
                dwWidth.l 
               dwHeight.l 
                dwScale.l 
                 dwRate.l 
               dwLength.l 
            dwEditCount.l 
             szFileType.s[64] 
EndStructure 

; Struct for AVIFileCreateStream and AVIStreamInfo
Structure AVISTREAMINFO 
                fccType.l 
             fccHandler.l 
                dwFlags.l 
                 dwCaps.l 
              wPriority.w 
              wLanguage.w 
                dwScale.l 
                 dwRate.l 
                dwStart.l 
               dwLength.l 
        dwInitialFrames.l 
  dwSuggestedBufferSize.l 
              dwQuality.l 
           dwSampleSize.l 
                rcFrame.RECT ; Built-in PureBasic RECT struct
            dwEditCount.l 
    dwFormatChangeCount.l 
                 szName.s[64] 
EndStructure 

; Struct for AVIMakeCompressedStream, AVISave, 
; AVISaveOptions, AVISaveOptionsFree, and AVISaveV
Structure AVICOMPRESSOPTIONS 
            fccType.l 
         fccHandler.l
    dwKeyFrameEvery.l 
          dwQuality.l 
   dwBytesPerSecond.l 
            dwFlags.l 
          *lpFormat 
           cbFormat.l 
           *lpParms 
            cbParms.l 
  dwInterleaveEvery.l 
EndStructure 

; Global pointers for AVI file and stream info, and file compression options.
;      (Can be defined locally instead before usage in YOUR code.)
Global *psi.AVISTREAMINFO                         
Global *pfi.AVIFILEINFO               
Global *plpOptions.AVICOMPRESSOPTIONS 
Global *lpInfo.AVISTREAMINFO

; ** Useful Procedures for getting and making AVI codes
;       (Could also be defined as MACROs instead.)

; Get the LOWORD out of a DWORD
Procedure.w LOWORD(DWORD.l)
  ProcedureReturn (DWORD & $FFFF)
EndProcedure

; Get the HIWORD out of a DWORD
Procedure.w HIWORD(DWORD.l)
  ProcedureReturn ((DWORD >> 16) & $FFFF)
EndProcedure

; Returns the two-character code created from the given characters.
Procedure.w aviTWOCC(ch0.s, ch1.s)
  ProcedureReturn (Asc(ch0) | (Asc(ch1) << 8))
EndProcedure

; Returns the four-character code created from the given characters.
Procedure.l mmioFOURCC(ch0.s, ch1.s, ch2.s, ch3.s)
  ProcedureReturn (Asc(ch0) | (Asc(ch1) << 8)) | ((Asc(ch2) << 16) | (Asc(ch3) << 24))
EndProcedure 

; Get a two-chracter code from a four-character code (fcctype made with mmioFOURCC)
Procedure.w TWOCCFromFOURCC(fcctype.l)
  ProcedureReturn HIWORD(fcctype)
EndProcedure

; Get stream from four-character code (fcctype made with mmioFOURCC)
Procedure.w StreamFromFOURCC(fcctype.l)
  ProcedureReturn ((LOWORD(fcctype) << 4) + (LOWORD(fcctype)))
EndProcedure

; Statically link AVIFIL32 library
Import #PB_Compiler_Home + "Purelibraries\Windows\Libraries\avifil32.lib"
  
  ; Returns #AVIERR_OK if successful or an error otherwise. 
  ; Possible error values include the following:
  ; #AVIERR_BUFFERTOOSMALL, or #AVIERR_MEMORY
  CompilerIf #PB_Compiler_Unicode = #False
    AVIBuildFilter.l(lpszfilter.p-ascii  , cbfilter.l, fsaving.l) As "_AVIBuildFilterA@12"
  CompilerElse
    AVIBuildFilter.l(lpszfilter.p-unicode, cbfilter.l, fsaving.l) As "_AVIBuildFilterW@12"
  CompilerEndIf
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  AVIClearClipboard.l() As "_AVIClearClipboard@0"
  
  ; Returns the updated reference count for the file interface.
  AVIFileAddRef.l(*pfile) As "_AVIFileAddRef@4"
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  ; Unless the file has been opened with write permission, this function
  ; returns #AVIERR_READONLY.
  CompilerIf #PB_Compiler_Unicode = #False
    AVIFileCreateStream.l(*pfile, *pavi, *psi) As "_AVIFileCreateStreamA@12"
  CompilerElse
    AVIFileCreateStream.l(*pfile, *pavi, *psi) As "_AVIFileCreateStreamW@12"
  CompilerEndIf  
  
  ; Returns #AVIERR_OK if successful or an error otherwise. 
  AVIFileEndRecord.l(*pfile) As "_AVIFileEndRecord@4"
  
  ; This function does not return a value.
  AVIFileExit() As "_AVIFileExit@0"
  
  ; Returns #AVIERR_OK if successful or an error otherwise. 
  ; Possible error values include the following:
  ; #AVIERR_NODATA, or #AVIERR_MEMORY
  AVIFileGetStream.l(*pfile, *pavi, fccType.l, lParam.l) As "_AVIFileGetStream@16"
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  CompilerIf #PB_Compiler_Unicode = #False
    AVIFileInfo.l(*pfile, *pfi, lSize.l) As "_AVIFileInfoA@12"
  CompilerElse  
    AVIFileInfo.l(*pfile, *pfi, lSize.l) As "_AVIFileInfoW@12"
  CompilerEndIf
  
  ; This function does not return a value.
  AVIFileInit() As "_AVIFileInit@0"
  
  ; Returns #AVIERR_OK if successful or an error otherwise. 
  ; Possible error values include the following: 
  ; #AVIERR_BADFORMAT, #AVIERR_MEMORY, #AVIERR_FILEREAD, #AVIERR_FILEOPEN, 
  ; or #REGDB_E_CLASSNOTREG
  CompilerIf #PB_Compiler_Unicode = #False
    AVIFileOpen.l(*pfile, lpszfile.p-ascii  , mode.l, *pclsidHandler) As "_AVIFileOpenA@16"
  CompilerElse  
    AVIFileOpen.l(*pfile, lpszfile.p-unicode, mode.l, *pclsidHandler) As "_AVIFileOpenW@16"
  CompilerEndIf
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  ; The Return value AVIERR_NODATA indicates that data With the requested chunk
  ; identifier does Not exist.
  AVIFileReadData.l(*pfile, ckid.l, *lpData, *lpcbData) As "_AVIFileReadData@16"
  
  ; Returns the reference count of the file. This return value should be used only 
  ; for debugging purposes.
  AVIFileRelease.l(*pfile) As "_AVIFileRelease@4"
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  ; If an application has Read-Only access to the file, the error code 
  ; #AVIERR_READONLY is returned.
  AVIFileWriteData.l(*pfile, ckid.l, *lpData, cbData.l) As "_AVIFileWriteData@16"
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  AVIGetFromClipboard.l(*lppf) As "_AVIGetFromClipboard@4"
  
  ; Returns #AVIERR_OK if successful or an error otherwise. 
  ; Possible error values include the following: 
  ; #AVIERR_NOCOMPRESSOR, #AVIERR_MEMORY, or #AVIERR_UNSUPPORTED  
  AVIMakeCompressedStream.l(*ppsCompressed, *psSource, *plpOptions, *pclsidHandler) As "_AVIMakeCompressedStream@16"
  
  ; Returns #AVIERR_OK if successful or an error otherwise. 
  AVIMakeFileFromStreams.l(*pfile, nStreams.l, *papStreams) As "_AVIMakeFileFromStreams@12"
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  AVIMakeStreamFromClipboard.l(cfFormat.l, *hGobal, *ppstream) As "_AVIMakeStreamFromClipboard@12"
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  AVIPutFileOnClipboard.l(*pfile) As "_AVIPutFileOnClipboard@4"
  
  ; Based on VB source code by By Ray Mercer, AVISave seems to be compiled using 
  ; CDECL calling convention. This is incompatible with the standard IMPORT/ENDIMPORT.
  ; Apparently, you can substitute this function with AVISaveV.  
  ; Still not sure why the PureBasic .lib file has no parameters for this function.
  ; ------------------------------------------------------------------------------------------------------------
  ; Returns #AVIERR_OK if successful or an error otherwise.
  ;CompilerIf #PB_Compiler_Unicode = #False
  ;  AVISave.l(lpszfile.p-ascii  , *pclsidHandler, *lpfnCallback, nStreams.l, *pavi, *plpOptions) As "_AVISaveA"
  ;CompilerElse
  ;  AVISave.l(lpszfile.p-unicode, *pclsidHandler, *lpfnCallback, nStreams.l, *pavi, *plpOptions) As "_AVISaveW"
  ;CompilerEndIf
  ; ------------------------------------------------------------------------------------------------------------
  
  ; Returns TRUE if the user pressed OK, FALSE for CANCEL, or an error otherwise.
  AVISaveOptions.l(hwnd.l, uiFlags.l, nStreams.l, *pavi, *plpOptions) As "_AVISaveOptions@20"
  
  ; Returns #AVIERR_OK.
  AVISaveOptionsFree.l(nStreams.l, *plpOptions) As "_AVISaveOptionsFree@8"
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  CompilerIf #PB_Compiler_Unicode = #False
    AVISaveV.l(lpszfile.p-ascii  , *pclsidHandler, *lpfnCallback, nStreams.l, *pavi, *plpOptions) As "_AVISaveVA@24"
  CompilerElse  
    AVISaveV.l(lpszfile.p-unicode, *pclsidHandler, *lpfnCallback, nStreams.l, *pavi, *plpOptions) As "_AVISaveVW@24"
  CompilerEndIf  
  
  ; Returns the current reference count of the stream.
  ; This value should be used only for debugging purposes
  AVIStreamAddRef.l(*pavi) As "_AVIStreamAddRef@4"
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  AVIStreamBeginStreaming.l(*pavi, lStart.l, lEnd.l, Rate.l) As "_AVIStreamBeginStreaming@16"
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  AVIStreamCreate.l(*pavi, lParam1.l, lParam2.l, *pclsidHandler) As "_AVIStreamCreate@16"
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  AVIStreamEndStreaming.l(*pavi) As "_AVIStreamEndStreaming@4"
  
  ; Returns the position of the frame found or -1 if the search is unsuccessful.
  AVIStreamFindSample.l(*pavi, lPos.l, lFlags.l) As "_AVIStreamFindSample@12"
  
  ; Returns a pointer to the frame data if successful or NULL otherwise. 
  ; The frame data is returned as a packed DIB.
  AVIStreamGetFrame.l(*pgf, lPos.l) As "_AVIStreamGetFrame@8"
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  AVIStreamGetFrameClose.l(*pget) As "_AVIStreamGetFrameClose@4"
  
  ; Returns a GetFrame object that can be used with the AVIStreamGetFrame function.
  ; If the system cannot find a decompressor that can decompress the stream to the 
  ; given format, or to any RGB format, the function returns NULL.
  AVIStreamGetFrameOpen.l(*pavi, *lpiWanted) As "_AVIStreamGetFrameOpen@8"
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  CompilerIf #PB_Compiler_Unicode = #False
    AVIStreamInfo.l(*pavi, *psi, lSize.l) As "_AVIStreamInfoA@12"
  CompilerElse  
    AVIStreamInfo.l(*pavi, *psi, lSize.l) As "_AVIStreamInfoW@12"
  CompilerEndIf  
  
  ; Returns the stream's length, in samples, if successful or -1 otherwise.
  AVIStreamLength.l(*pavi) As "_AVIStreamLength@4"
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  CompilerIf #PB_Compiler_Unicode = #False
    AVIStreamOpenFromFile.l(*pavi, lpszFile.p-ascii  , fccType.l, lParam.l, mode.l, *pclsidHandler) As "_AVIStreamOpenFromFileA@24"
  CompilerElse  
    AVIStreamOpenFromFile.l(*pavi, lpszFile.p-unicode, fccType.l, lParam.l, mode.l, *pclsidHandler) As "_AVIStreamOpenFromFileW@24"    
  CompilerEndIf

  ; Returns #AVIERR_OK if successful or an error otherwise. 
  ; Possible error values include the following:
  ; #AVIERR_BUFFERTOOSMALL, #AVIERR_MEMORY, or #AVIERR_FILEREAD
  AVIStreamRead.l(*pavi, lStart.l, lSamples.l, *lpBuffer, cbBuffer.l, *plBytes, *plSamples) As "_AVIStreamRead@28"
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  ; The return value #AVIERR_NODATA indicates the system could not find any data 
  ; with the specified chunk identifier.
  AVIStreamReadData.l(*pavi, ckid.l, *lpData, *lpcbData) As "_AVIStreamReadData@16"
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  AVIStreamReadFormat.l(*pavi, lPos.l, *lpFormat, *lpcbFormat) As "_AVIStreamReadFormat@16"
  
  ; Returns the current reference count of the stream.
  ; This value should be used only for debugging purposes.
  AVIStreamRelease.l(*pavi) As "_AVIStreamRelease@4"
  
  ; Returns the converted time if successful or -1 otherwise.
  AVIStreamSampleToTime.l(*pavi, lSample.l) As "_AVIStreamSampleToTime@8"
  
  ; Returns #AVIERR_OK if successful or an error otherwise. 
  AVIStreamSetFormat.l(*pavi, lPos.l, *lpFormat, cbFormat.l) As "_AVIStreamSetFormat@16"
  
  ; Returns the number if successful or -1 otherwise.
  AVIStreamStart.l(*pavi) As "_AVIStreamStart@4"
  
  ; Returns the converted time if successful or -1 otherwise.
  AVIStreamTimeToSample.l(*pavi, lTime.l) As "_AVIStreamTimeToSample@8"
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  AVIStreamWrite.l(*pavi, lStart.l, LSample.l, *lpBuffer, cbBuffer.l, dwFlags.l, *plSampWritten, *plBytesWritten) As "_AVIStreamWrite@32" 
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  ; The Return value AVIERR_READONLY indicates the file was opened without write access.
  AVIStreamWriteData.l(*pavi, ckid.l, *lpData, cbData.l) As "_AVIStreamWriteData@16"
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  CreateEditableStream.l(*ppEditable, *psSource) As "_CreateEditableStream@8"
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  EditStreamClone.l(*pavi, *ppResult) As "_EditStreamClone@8"
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  EditStreamCopy.l(*pavi, plStart.l, plLength.l, *ppResult) As "_EditStreamCopy@16"
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  EditStreamCut.l(*pavi, plStart.l, plLength.l, *ppResult) As "_EditStreamCut@16"
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  EditStreamPaste.l(*pavi, plPos.l, plLength.l, *pStream, lStart.l, lLength.l) As "_EditStreamPaste@24"
  
  ; Returns #AVIERR_OK if successful or an error otherwise. 
  ; Note: For using this function with the AVISTREAMINFO Structure
  ; This function does not change the following members:
  ; dwCaps
  ; dwEditCount
  ; dwFlags
  ; dwInitialFrames
  ; dwLength
  ; dwSampleSize
  ; dwSuggestedBufferSize
  ; fccHandler
  ; fccType
  
  ; The function changes the following members:
  ; dwRate
  ; dwQuality
  ; dwScale
  ; dwStart
  ; rcFrame
  ; szName
  ; wLanguage
  ; wPriority
  CompilerIf #PB_Compiler_Unicode = #False
    EditStreamSetInfo.l(*pavi, *lpInfo, cbInfo.l) As "_EditStreamSetInfoA@12"
  CompilerElse  
    EditStreamSetInfo.l(*pavi, *lpInfo, cbInfo.l) As "_EditStreamSetInfoW@12"
  CompilerEndIf  
  
  ; Returns #AVIERR_OK if successful or an error otherwise.
  CompilerIf #PB_Compiler_Unicode = #False
    EditStreamSetName.l(*pavi, lpszName.p-ascii  ) As "_EditStreamSetNameA@8"
  CompilerElse  
    EditStreamSetName.l(*pavi, lpszName.p-unicode) As "_EditStreamSetNameW@8"
  CompilerEndIf  
  
EndImport
If anyone has any additions, corrections, usage examples, or information they wish to share about this library, please do so. Meanwhile, I'll continue my efforts.

Re: Avifil32 Library Import - AVISave() Parameters?

Posted: Mon Apr 04, 2011 1:15 am
by IdeasVacuum
There are a lot of posts on this forum about AVI but I have never been able to get any of the code samples to work :(

dige might know something about the AVISave issue:

http://www.purebasic.fr/english/viewtop ... 34&start=0

Re: Avifil32 Library Import - AVISave() Parameters?

Posted: Mon Apr 04, 2011 2:20 pm
by D Ogre
Yeah, I've seen a lot of code examples around here. I think the main reason why it's hard to apply good working code is sparse MSDN documentation and lack of well documented C/C++ source code to go by. I started looking at some of the PB code here when I started this project, and found that some people must have interpreted the MSDN docs wrong. I've seen one example here that tried to pass the actual FOURCC characters to the fccHandler. That is actually incorrect. You pass the code created from the 4 charaters by the mmioFOURCC function (or at least a constant that represents a valid code) to the fccType, and the fccHandler. I believe It's also the same for the ckunk ids, but you use the aviTWOCC function to get the codes.

Well. hopefully dige or even Inc has some good information for here. :P

I found some useful information myself from the following sources:

Visual Basic AVIFile Tutorials by Ray Mercer:
http://www.shrinkwrapvb.com/avihelp/avihelp.htm

Documentation on the avifmt.h File Reference (List of critical AVIFile helper functions and constants)
http://www.motama.com/doxygen-nmm-1.0.0 ... mt_8h.html

I have a few more, but I haven't thoroughly reviewed them yet to post.

Re: Avifil32 Library Import - AVISave() Parameters?

Posted: Mon Apr 04, 2011 4:38 pm
by Zach
I've been through the shrinkwrapvb.com tutorials every which way, and for the most part they are very helpful.
So they are a good place to start..

Otherise, I might suggest trying to get in touch with Inc. about this specific issue. He has experience with this kind of stuff. He also wrote an AVIFIL library for an older version of PB.