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

2016-02-19 20:56 67 1 收藏

下面图老师小编跟大家分享一个简单易学的用AVIFile函数制做AVI文件基本步骤教程,get新技能是需要行动的,喜欢的朋友赶紧收藏起来学习下吧!

【 tulaoshi.com - 编程语言 】

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();

来源:http://www.tulaoshi.com/n/20160219/1624863.html

延伸阅读
标签: ASP
  选择自 mind_1220 的 Blog 要求:  能够读取按照  INI文件的Section和Key来读出相应的Value。  比如一个配置文件    SMSVote.ini  ---------------------------------  [SMSVote]  Server=(local)  DB=SMSVote  User=sa  PassWord=123  [DB2Vote] ...
相信很多爱美的MM们都不会忽视对自己肌肤的保养,并且乐此不疲。但是,如果护肤的步骤做错了,那就得不偿失了。特别是现在,经历过严冬后的皮肤逐渐出现各种各样的肌肤问题。那么,现在赶紧通过下面这五方面来检测看看,你做的保养功夫是否正确,是否最符合自己皮肤状况的吧。 方法 1 肌肤护理最好是使用同一系列的产...
标签: excel
Excel如何利用函数制作带负值的数据条   本节实例中通过公式函数模拟一个数据条,并且比条件格式更加强大,因为它可以将负值变成反向伸展。 具体操作步骤: 1、启动Excel2013,输入一些数据,包括员工姓名,以及各个人员的销售情况,在B2单元格输入:=IF(D20,REPT("|",ABS(D2)),"")。 2、按下...
MIDP 2.0里面包括一个用来简化编写二维游戏的API函数。这个API函数是非常简凑的,只包括javax.microedition.lcdui.game包里的五个类。这五个类主要提供了两个重要的功能:  新的GameCanvas类使得在一个游戏循环体内画一个screen和响应键盘输入成为可能,而不需要调用系统的paint和input线程。  功能强大而复杂的...
标签: word
如何通过用Word制做灯笼   如何通过用Word制做灯笼 中国的灯笼又统称为灯彩,起源于1800多年前的西汉时期,每年的农历正月十五元宵节前后,人们都挂起象征团圆意义的红灯笼,来营造一种喜庆的氛围。后来灯笼就成了中国人喜庆的象征。下面教你一种用word制作灯笼的方法。主要运用了word中的绘图工具。 1、新建一个word文...

经验教程

816

收藏

75
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部