用AVIFile函数制做AVI文件基本步骤

340520623

340520623

2016-02-19 20:56

下面图老师小编跟大家分享一个简单易学的用AVIFile函数制做AVI文件基本步骤教程,get新技能是需要行动的,喜欢的朋友赶紧收藏起来学习下吧!
AVIFile,AVIFileOpen,AVIFileCreateStream....制做AVI文件,基相实现方法。 !-- frame contents -- !-- /frame contents -- AVIFileInit();//创建AVI文件if(AVIFileOpen(&m_aviFile,aviFileFullName,OF_CREATEOF_WRITE,0)){MessageBox("create file '"+aviFileFullName+"' error");return;}//设置视频流格式AVISTREAMINFOW m_aviVideoStreamInfo;m_aviVideoStreamInfo.fccType = streamtypeVIDEO;m_aviVideoStreamInfo.fccHandler = 0;m_aviVideoStreamInfo.dwFlags = 0;m_aviVideoStreamInfo.dwCaps = 0;m_aviVideoStreamInfo.wPriority = 0;m_aviVideoStreamInfo.wLanguage = 0;m_aviVideoStreamInfo.dwRate = 5; //每秒5帧m_aviVideoStreamInfo.dwScale = 1;m_aviVideoStreamInfo.dwQuality = 0;m_aviVideoStreamInfo.dwSuggestedBufferSize = m_ImageWidth*m_ImageHeight*3;m_aviVideoStreamInfo.dwStart = 0;m_aviVideoStreamInfo.dwInitialFrames = 0;m_aviVideoStreamInfo.dwSampleSize = 0;m_aviVideoStreamInfo.rcFrame.left = 0;m_aviVideoStreamInfo.rcFrame.top = 0;m_aviVideoStreamInfo.rcFrame.right = m_ImageWidth;m_aviVideoStreamInfo.rcFrame.bottom = m_ImageHeight;m_aviVideoStreamInfo.dwEditCount = 0;m_aviVideoStreamInfo.dwFormatChangeCount = 0;strcpy((char *)m_aviVideoStreamInfo.szName,"ScreenCap.avi");m_aviVideoStreamInfo.dwLength = 0;//设置音频流格式AVISTREAMINFOW m_aviAudioStreamInfo;m_aviAudioStreamInfo.fccType = streamtypeAUDIO;m_aviAudioStreamInfo.fccHandler = 0;m_aviAudioStreamInfo.dwFlags = 0;m_aviAudioStreamInfo.dwCaps = 0;m_aviAudioStreamInfo.wPriority = 0;m_aviAudioStreamInfo.wLanguage = 0;m_aviAudioStreamInfo.dwScale = 1; //声道数m_aviAudioStreamInfo.dwRate = 8000; //Hzm_aviAudioStreamInfo.dwStart = 0;m_aviAudioStreamInfo.dwInitialFrames = 0;m_aviAudioStreamInfo.dwSuggestedBufferSize = m_dwBufferSize; m_aviAudioStreamInfo.dwQuality = 0;m_aviAudioStreamInfo.dwSampleSize = 1;m_aviAudioStreamInfo.rcFrame.bottom = 0;m_aviAudioStreamInfo.rcFrame.left = 0;m_aviAudioStreamInfo.rcFrame.right = 0;m_aviAudioStreamInfo.rcFrame.top = 0;m_aviAudioStreamInfo.dwEditCount = 0;m_aviAudioStreamInfo.dwFormatChangeCount = 0;m_aviAudioStreamInfo.dwLength = 0;//创建数据流AVIFileCreateStream(m_aviFile,&m_aviVideoStream,(AVISTREAMINFO *)&m_aviVideoStreamInfo);AVIFileCreateStream(m_aviFile,&m_aviAudioStream,(AVISTREAMINFO *)&m_aviAudioStreamInfo);//写数据流//-----视屏流BITMAPINFOHEADER bmpInfoHdr;bmpInfoHdr.biSize = sizeof(BITMAPINFOHEADER);bmpInfoHdr.biWidth = m_ImageWidth;bmpInfoHdr.biHeight = m_ImageHeight;bmpInfoHdr.biBitCount = image1.GetBPP();bmpInfoHdr.biCompression = BI_RGB;
   bmpInfoHdr.biSizeImage = 0;bmpInfoHdr.biClrImportant = 0;bmpInfoHdr.biClrUsed = 0;bmpInfoHdr.biXPelsPerMeter = 0;bmpInfoHdr.biYPelsPerMeter = 0;bmpInfoHdr.biPlanes = 1;//设置帧格式AVIStreamSetFormat(m_aviVideoStream,m_aviVideoFrames,&bmpInfoHdr,sizeof(bmpInfoHdr));//写数据AVIStreamWrite(m_aviVideoStream,m_aviVideoFrames ,1,(LPBYTE) buffer,size ,AVIIF_KEYFRAME,NULL,NULL);m_aviVideoFrames++;///-------------//----音频流WAVEFORMAT waveFormat;waveFormat.nAvgBytesPerSec = m_Format.nAvgBytesPerSec;waveFormat.nBlockAlign = m_Format.nBlockAlign;waveFormat.nChannels = m_Format.nChannels;waveFormat.nSamplesPerSec = m_Format.nSamplesPerSec;waveFormat.wFormatTag = m_Format.wFormatTag;//设置音频格式AVIStreamSetFormat(m_aviAudioStream,m_aviAudioFrames,&m_Format,sizeof(m_Format));//写数据AVIStreamWrite(m_aviAudioStream,m_aviAudioFrames ,1,(LPBYTE)pBuffer,pWaveHdr-dwBytesRecorded ,AVIIF_KEYFRAME,NULL,NULL);m_aviAudioFrames++;///-----------//释放数据流及文件if(m_aviVideoStream){m_aviVideoStream-Release();m_aviVideoStream = NULL;}if(m_aviAudioStream){m_aviAudioStream-Release();m_aviAudioStream = NULL;}if(m_aviFile){m_aviFile-Release();m_aviFile = NULL;}AVIFileExit();
展开更多 50%)
分享

猜你喜欢

用AVIFile函数制做AVI文件基本步骤

编程语言 网络编程
用AVIFile函数制做AVI文件基本步骤

满屏播放AVI文件

编程语言 网络编程
满屏播放AVI文件

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

AVI文件格式

编程语言 网络编程
AVI文件格式

如何满屏播放AVI文件

编程语言 网络编程
如何满屏播放AVI文件

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

在VB中播放AVI文件

编程语言 网络编程
在VB中播放AVI文件

Windows XP系统中巧删AVI文件

windows 操作系统
Windows XP系统中巧删AVI文件

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

Linux终端提示符路径长度的修改方法

Linux终端提示符路径长度的修改方法

Java语言编程技术中汉字问题的分析及解决

Java语言编程技术中汉字问题的分析及解决
下拉加载更多内容 ↓