Home > Software engineering >  Vb write avi audio returns an error - 2147205014, ChongXie (red envelopes oh)
Vb write avi audio returns an error - 2147205014, ChongXie (red envelopes oh)

Time:11-16

I'm going to go crazy. Not set for a few days. Where is wrong.
Always returns are avierr_ok, one to write a 2147205014 error. Image compression when no problem, if you can contact with avi video and audio processing experience I Q452781589 real-time chat audio data is saved as avi (similar to telephone recording), ChongXie (red envelopes oh)


Public Function InitWare (savefile As String) As Boolean 'save the byte stream
'SaveTofile save to file FPS shot per second PicFile picture sample size
If IsSaveAVI Then
MsgBox "file, you can not do this again!" , vbInformation, "ark hint"
The Exit Function
End the If

Dim res As Long
Dim strhdr_vides As AVI_STREAM_INFO
Dim BI As BITMAPINFOHEADER
Dim opts As AVI_COMPRESS_OPTIONS
Dim opts2 As AVI_COMPRESS_OPTIONS

Dim pOpts As Long, pOpts2 As Long
Dim Psfile As String
Res=AVIFileOpen (fileHDC savefile, OF_WRITE Or OF_CREATE, 0 & amp;) 'to create or open the AVI file
If (res & lt;> AVIERR_OK) Then GoTo the error




Dim strhdr_auds_info As AVI_STREAM_INFO

Audio stream structure With strhdr_auds_info '

FccType=mmioStringToFOURCC (auds, 0 & amp;)
'fccHandler=mmioFOURCC (" g ", "7", "2", "6")
. DwFlags=0 '
. DwCaps=0 '
. WPriority=0 '
. WLanguage=0 '
DwScale=1600 '//
DwRate=8000 '//Hz
. DwStart=0 '
. DwInitialFrames=0 '
DwSuggestedBufferSize=1600 '
. DwQuality=1 '
. DwSampleSize=1 '
'rcFrame. Bottom=0'
'rcFrame. Left=0'
'rcFrame. Right=0'
'rcFrame. Top=0'
. DwEditCount=0 '
. DwFormatChangeCount=0 '
. DwLength=0 '
End With

Res=AVIFileCreateStream (fileHDC AuStream, strhdr_auds_info) 'create audio stream
If (res & lt;> AVIERR_OK) Then GoTo the error



'equipment audio stream
Dim strhdr_auds As WAVEFORMATEX

Audio formats With strhdr_auds'
. WFormatTag=WAVE_FORMAT_PCM
. NChannels=1
NSamplesPerSec=8000
. WBitsPerSample=8
NBlockAlign=(. WBitsPerSample/8) *. NChannels
. NAvgBytesPerSec=. NSamplesPerSec *. NBlockAlign
'AVIStreamSetFormat (m_paviAudioStream m_aviAudioFrames, & amp; Wave_format, sizeof (wave_format))
End With

Dim strauds () As Byte
ReDim strauds (0 To Len (strhdr_auds) - 1)
CopyMemory strauds (0), strhdr_auds, Len (strhdr_auds)
Dim btBuf As Long
BtBuf=VarPtr (strauds (0))
Dim BufLen As Long
BufLen=UBound (strauds) + 1


Res=AVIStreamSetFormat (AuStream, 0, ByVal btBuf, BufLen) 'equipment audio formats
If (res & lt;> AVIERR_OK) Then GoTo the error


'res=AVIStreamSetFormat (AuStream, 0, ByVal strhdr_auds, Len (strhdr_auds)' equipment audio formats
'If (res & lt;> AVIERR_OK) Then GoTo the error


POpts2=VarPtr (opts2)
'res=AVISaveOptions (Form1 hWnd, ICMF_CHOOSE_KEYFRAME Or ICMF_CHOOSE_DATARATE, 1, AuStream, pOpts2)' audio compression way
Res=AVISaveOptions (Form1 HWND, _
ICMF_CHOOSE_KEYFRAME Or ICMF_CHOOSE_DATARATE, _
1, _
AuStream, _
POpts2) 'returns TRUE if the User presses the OK, FALSE if Cancel, or error code




'If res & lt;> 1 Then 'TRUE In C=1
'Call AVISaveOptionsFree (1, pOpts2)
'GoTo error
'End If

Res=AVIMakeCompressedStream (AuCompressed AuStream, opts2, 0 & amp;) 'set the audio compression mode



If res & lt;> AVIERR_OK Then GoTo the error



'res=AVIStreamSetFormat (AuCompressed, 0, ByVal VarPtr (strauds (0)), UBound (strauds) + 1)' equipment audio formats
'If (res & lt;> AVIERR_OK) Then GoTo the error



'Dim res As Long
"' Dim btBuf As Long
"' Dim BufLen As Long


'btBuf=VarPtr (btWare (0))
'BufLen=UBound (btWare) + 1

Dim byt (1 To 1600) As Byte
BufLen=UBound (byt)
BtBuf=VarPtr (byt (1))
ChunkID=1

Res=AVIStreamWrite (AuCompressed, _
ChunkID, _
1, _
BtBuf, _
BufLen, _
AVIIF_KEYFRAME, _
ByVal 0 & amp; , _
ByVal 0 & amp;)
'location error, bosses can't look at the trouble to write write avi audio returns an error - 2147205014

The Debug. Print res
If res & lt;> AVIERR_OK Then GoTo the error
ChunkID=ChunkID + 1







InitWare=True
InitWare=True
The Exit Function

Error:
StopSave res

CodePudding user response:

Error message mean parameter errors,
Nothing has studied video, suggest you go to the MSDN check the parameters of the API

CodePudding user response:

Thank you. About the video API, little information. I am also the feeling.
  • Related