AVI文件中封装G711音频

两个结构体:

typedef struct { char fccType[4] ; // offset 0x00: 'iavs' char fccHandler[4] ; // offset 0x04: 'dvsd' or 'DIVX' unsigned long dwFlags ; // offset 0x08: 0x0 unsigned short wPriority ; // offset 0x0c: 0 unsigned short wLanguage ; // offset 0x0e: 0x0 undefined unsigned long dwInitialFrames ; // offset 0x10: 0 unsigned long dwScale ; // offset 0x14: 100 (29.970 Frames/Sec) unsigned long dwRate ; // offset 0x18: 2997 unsigned long dwStart ; // offset 0x1c: 0 unsigned long dwLength ; // offset 0x20: 2192 unsigned long dwSuggestedBufferSize ; // offset 0x24: 120000 unsigned long dwQuality ; // offset 0x28: 0 unsigned long dwSampleSize ; // offset 0x2c: 0 unsigned short frameTop ; // offset 0x30: 0 unsigned short frameLeft ; // offset 0x32: 0 unsigned short frameBottom ; // offset 0x34: 720 unsigned short frameRight ; // offset 0x36: 480 } AviStreamHeader_t; typedef struct { unsigned short formatTag ; unsigned short nChannels ; unsigned long nSamplesPerSec ; unsigned long nAvgBytesPerSec ; unsigned short nBlockAlign ; unsigned short wBitsPerSample ; unsigned short cbSize ; } AviStreamFormat_auds_t ;

 填数据:

AviStreamHeader_t       tAUDSH      ;

tAUDSH.fccType[0]='a'; tAUDSH.fccType[1]='u'; tAUDSH.fccType[2]='d'; tAUDSH.fccType[3]='s'; tAUDSH.fccHandler[0]='G'; tAUDSH.fccHandler[1]='7'; tAUDSH.fccHandler[2]='1'; tAUDSH.fccHandler[3]='1'; tAUDSH.dwFlags = 0 ; tAUDSH.wPriority = 0 ; // offset 0x0c: 0 tAUDSH.wLanguage = 0 ; // offset 0x0e: 0x0 undefined tAUDSH.dwInitialFrames = 0 ; // offset 0x10: 0 tAUDSH.dwScale = 1 ; // offset 0x14: tAUDSH.dwRate = 8000 ; // offset 0x18: tAUDSH.dwStart = 0 ; // offset 0x1c: 0 tAUDSH.dwLength = 325 ; // offset 0x20: tAUDSH.dwSuggestedBufferSize = 32768 ; // offset 0x24: 120000 tAUDSH.dwQuality = 0 ; // offset 0x28: 0 tAUDSH.dwSampleSize = 8000 ; // offset 0x2c: 0 tAUDSH.frameTop = 0 ; // offset 0x30: 0 tAUDSH.frameLeft = 0 ; // offset 0x32: 0 tAUDSH.frameBottom = 0 ; // offset 0x34: tAUDSH.frameRight = 0 ; // offset 0x36:  

AviStreamFormat_auds_t  tAuds             ;

tAuds.formatTag = 0x07 ;// tAuds.nChannels = 0x01 ; tAuds.nSamplesPerSec = 8000 ; tAuds.wBitsPerSample = 8 ; // if pcm: 32 tAuds.nBlockAlign = tAuds.nChannels *(tAuds.wBitsPerSample/8) ; tAuds.nAvgBytesPerSec = tAuds.nBlockAlign*tAuds.nSamplesPerSec ; ///x80/x3e:16000 tAuds.cbSize = 18;

G.711音频编码分a-law和u-law,其中a-law 的tAuds.formatTag=0x06,u-law 的tAuds.formatTag=0x07

 

 

 

 

 

网上搜一些东西都头晕,像这么详细的东西难找啊。

 

                                      

你可能感兴趣的:(c,struct,avi)