Home > Software engineering >  I this code AVIFileCreateStream parameters where is wrong? (online, etc.)
I this code AVIFileCreateStream parameters where is wrong? (online, etc.)

Time:11-12

 Private Type AVI_COMPRESS_OPTIONS 
FccType As Long
FccHandler As Long
DwKeyFrameEvery As Long
DwQuality As Long
DwBytesPerSecond As Long
DwFlags As Long
LpFormat As Long
CbFormat As Long
LpParms As Long
CbParms As Long
DwInterleaveEvery As Long
End Type
Private Type WAVEHDR
LpData As Long
DwBufferLen As Long
DwBytesRec As Long
DwUser As Long
DwFlags As Long
DwLoops As Long
LpNext As Long
Reserved As Long
End Type

Private Type WAVEFORMATEX
WFormatTag As Integer 'waveform sound format, I am here is set to WAVE_FORMAT_PCM
NChannels As Integer 'channel number, mono is 1, stereo for 2
NSamplesPerSec As Long 'sample, sampling rate, for WAVE_FORMAT_PCM usually is 8.0 kHz, 11.025 kHz, 22.05 kHz and 44.1 kHz
NAvgBytesPerSec As Long 'for buffer estimation */
NBlockAlign As Integer 'block size of data
WBitsPerSample As Integer '//BIT number of each sample, usually for 16
BiSize As Integer '//additional information of size, in bytes, add in
End Type

Const WAVE_FORMAT_PCM=1 'this a Const were written I
Const WHDR_BEGINLOOP=4
Const WHDR_DONE=1
Const WHDR_ENDLOOP=8
Const WHDR_INQUEUE=& amp; H10
Const WHDR_PREPARED=2

Global Const AVIERR_OK As Long=0 & amp;
Global Const OF_WRITE As Long=& amp; H1
Global Const OF_CREATE As Long=& amp; H1000
Global Const AVIIF_KEYFRAME As Long=& amp; H10
Global Const DATARATE As Long=& amp; H280
Global Const ICMF_CHOOSE_KEYFRAME As Long=& amp; H1
Global Const ICMF_CHOOSE_DATARATE As Long=& amp; The H2
Dim res As Long, pfile As Long, ps As Long, pOpts psCompressed As Long, As Long
Dim the ps2 As Long, psCompressed2 As Long, pOpts2 As Long 'this line is to write their own
Dim BMP As cDIB, STRHDR As AVI_STREAM_INFO, BI As BITMAPINFOHEADER, opts As AVI_COMPRESS_OPTIONS, avifile As String
Dim wav As cWAV, WH As WAVEHDR opts2 As AVI_COMPRESS_OPTIONS 'this line is to write their own

Dim strhdr2 As WAVEFORMATEX 'AVI_STREAM_INFO'

'turn to byte array using Integer array
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any Source, As Any, ByVal Length As Long)
'turn to byte array using Integer array

Public Function StartDecode (HWND As Long, base As String, path As String, FPS %) As a Boolean
Avifile=path: AVIFileInit: res=AVIFileOpen (pfile, path, OF_WRITE Or OF_CREATE, 0 & amp;)
If (res & lt;> Then AVIERR_OK)
EndDecode
The Exit Function
End the If

The Set of BMP=New cDIB
If BMP. CreateFromFile (base) & lt;> True Then
MsgBox "Could not load first bitmap file list in!" VbExclamation, App. The title
EndDecode
The Exit Function
End the If

With STRHDR
FccType=mmioStringToFOURCC (" vids, "0 & amp;)
. FccHandler=0 & amp;
. DwScale=1
. DwRate=Val (FPS)
. DwSuggestedBufferSize=BMP. SizeImage
SetRect. RcFrame, 0, 0, BMP. Width, BMP. Height
End With

If STRHDR. DwRate & lt; 1 Then STRHDR. DwRate=1
If STRHDR. DwRate & gt; 30 Then STRHDR. DwRate=30
Res=AVIFileCreateStream (pfile, ps, STRHDR)
If (res & lt;> Then AVIERR_OK)
EndDecode
The Exit Function
End the If

With strhdr2
. WFormatTag=1
NChannels=Val (2)
WBitsPerSample=Val (16)
NSamplesPerSec=Val (44100) 'sampling rate
NAvgBytesPerSec=Val (176400) 'the sound WAVE in the amount of data per second (CLng (cboSamplerate. Text) * (2 * (chkStereo. Value + 1)))=44100 * (2 * (1 + 1))
NBlockAlign=(10240) 'data block alignment marks
. BiSize=14 'this structure size
End With a 'SetFormat VarPtr (WFX), Len (WFX), "44.1 kHz 16 Bit Stereo", "PCM"

Dim strhdr3 As AVI_STREAM_INFO
With strhdr3
FccType=mmioStringToFOURCC (auds, 0 & amp;)
. FccHandler=1 & amp;
DwScale=Val (10240)
DwRate=Val (176400)
. DwSuggestedBufferSize=BMP. SizeImage
'SetRect. RcFrame, 0, 0, BMP, Width, BMP. Height
End With
'update recorded time
'lngMSEncoded=lngMSEncoded + ((lngLen/lngBytesPerSec) * 1000)
Res=AVIFileCreateStream (pfile, ps2, strhdr3)
If (res & lt;> Then AVIERR_OK)
EndDecode
The Exit Function
End the If

Dim (b) As Byte, I As Long
'the ReDim b (Len (strhdr2) * 2-1)
'For I=0 To UBound (intSamples)
'intSamples CopyMemory b (I * 2), (I), ByVal 2' LenB (intSamples (I))
'Next
Res=AVIStreamSetFormat (ps2, 0, ByVal VarPtr (strhdr2), Len (strhdr2))
If (res & lt;> Then AVIERR_OK)
EndDecode
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull