那位牛人知道AVI 文件的结构是如何组织的?一般常用的组织方式时,每个结构占多大字节?
解决方案 »
- VC 多个窗体时,如何设置启动窗体?
- 获取.exe 执行过程中返回的数据(DLL可以吗i)
- 如何对以显示的位图选定区域然后进行颜色变换
- 请问下CBlockingSocket类要包含哪个头文件?
- 在windows系统中,监控文件操作,能不能获得每个操作的用户名和导致此文件变动的程序名
- 请问rgn类如何动态变形?
- 字符串转码:UTF-8转为GBK
- 为什么我的TerminateProcess无法结束进程?
- 如何使得VC5.0用向导生成一个project时是中文的,即菜单是中文的?
- 近日学习t-sql,搜索了半天找不到一个有大量代码的网站,谁能不能介绍一下啊?
- 请问,,用计算机的答应口能否实现6位i/o的输入啊!!!!!!
- 一本《深入潜出MFC》出售,4折,有要买的吗,在北京,自取!
class CAvi file://AVI类,处理AVI文件
{
public:
int cy;//图象高
int cx;//图象宽
file://long m_maxFrame;
BYTE *pData;//寸储图象数据
BITMAPINFO *m_pBMI;//位图文件信息头
PAVISTREAM pavi;//AVI流
PAVIFILE pfile;//AVI文件指针
AVIFILEINFO * pfi; file://AVI信息
BOOL AviRead(int mFrame);//读AVI文件的第mFrame帧
CAvi();//标准构造函数
CAviCreate(CString &string);//用文件名初始化AVI类的成员
virtual ~CAvi();
};
//Cavi类文件实现部分;
CAvi::CAvi()
{ AVIFileInit();//初始化AVI库
cx=0;//定义图象宽、高、等成员
cy=0;
m_pBMI=NULL;
pData=NULL;
file://m_maxFrame=0;
pfi=NULL;
}
CAvi::~CAvi()//析构、释放指针
{
// AVIFileClose(pfile);
AVIFileExit();
if(pData!=NULL)
delete pData;
pData=NULL; if(m_pBMI!=NULL)
delete m_pBMI;
m_pBMI=NULL;
if(pfi!=NULL)
delete pfi;
pfi=NULL;
}
{
HRESULT hr;
pfi=new AVIFILEINFO;
hr = AVIFileOpen(&pfile, // returned file pointer
string, // file name
OF_READ, // mode to open file with
NULL);
hr= AVIFileInfo(pfile, file://获取AVI信息,放入pfi中
pfi,
sizeof(AVIFILEINFO)
);
cx=pfi->dwWidth;//图象宽、高
cy=pfi->dwHeight;
hr=AVIFileGetStream(//将AVI变成视频流
pfile,
&pavi,
streamtypeVIDEO,
0//LONG lParam
);
m_pBMI=new BITMAPINFO;//定义BMP信息头
m_pBMI->bmiHeader.biBitCount=24;
m_pBMI->bmiHeader.biClrImportant=0;
m_pBMI->bmiHeader.biClrUsed=0;
m_pBMI->bmiHeader.biCompression=BI_RGB;
m_pBMI->bmiHeader.biHeight=cy;
m_pBMI->bmiHeader.biWidth=cx;
m_pBMI->bmiHeader.biPlanes=1;
m_pBMI->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
m_pBMI->bmiHeader.biXPelsPerMeter=0;
m_pBMI->bmiHeader.biYPelsPerMeter=0;
m_pBMI->bmiHeader.biSizeImage=cx*cy*3;
pData=(BYTE*)new char[cx*cy*3];//根据AVI中BMP图象的信息定义缓冲区
}
BOOL CAvi::AviRead(int mFrame)//将AVI文件的M帧数据读入PData缓冲区
{
HRESULT hr;
hr= AVIStreamRead( pavi,
mFrame,
1,
pData,
cx*cy*3,
NULL,
NULL
);
if(hr==0)
return TRUE;
else
return FALSE;
}
上述Cavi类实现部分所涉及到的API函数可以参考微软提供的MSDN。Cavi类中的pData缓冲区存放AVI文件中的具体某一帧图像数据,同时Cavi类的m_pBMI为BMP图像文件信息结构,这时可以根据图像的大小定义BMP图像文件头结构
The AVIFILEINFO structure contains global information for an entire AVI file. typedef struct {
DWORD dwMaxBytesPerSec;
DWORD dwFlags;
DWORD dwCaps;
DWORD dwStreams;
DWORD dwSuggestedBufferSize;
DWORD dwWidth;
DWORD dwHeight;
DWORD dwScale;
DWORD dwRate;
DWORD dwLength;
DWORD dwEditCount;
char szFileType[64];
} AVIFILEINFO;
Members
dwMaxBytesPerSec
Approximate maximum data rate of the AVI file.
dwFlags
Applicable flags. The following flags are defined:
AVIFILEINFO_HASINDEX
The AVI file has an index at the end of the file. For good performance, all AVI files should contain an index.
AVIFILEINFO_MUSTUSEINDEX
The file index contains the playback order for the chunks in the file. Use the index rather than the physical ordering of the chunks when playing back the data. This could be used for creating a list of frames for editing.
AVIFILEINFO_ISINTERLEAVED
The AVI file is interleaved.
AVIFILEINFO_WASCAPTUREFILE
The AVI file is a specially allocated file used for capturing real-time video. Applications should warn the user before writing over a file with this flag set because the user probably defragmented this file.
AVIFILEINFO_COPYRIGHTED
The AVI file contains copyrighted data and software. When this flag is used, software should not permit the data to be duplicated.
dwCaps
Capability flags. The following flags are defined:
AVIFILECAPS_CANREAD
An application can open the AVI file with with the read privilege.
AVIFILECAPS_CANWRITE
An application can open the AVI file with the write privilege.
AVIFILECAPS_ALLKEYFRAMES
Every frame in the AVI file is a key frame.
AVIFILECAPS_NOCOMPRESSION
The AVI file does not use a compression method.
dwStreams
Number of streams in the file. For example, a file with audio and video has at least two streams.
dwSuggestedBufferSize
Suggested buffer size, in bytes, for reading the file. Generally, this size should be large enough to contain the largest chunk in the file. For an interleaved file, this size should be large enough to read an entire record, not just a chunk.
If the buffer size is too small or is set to zero, the playback software will have to reallocate memory during playback, reducing performance. dwWidth
Width, in pixels, of the AVI file.
dwHeight
Height, in pixels, of the AVI file.
dwScale
Time scale applicable for the entire file. Dividing dwRate by dwScale gives the number of samples per second.
Any stream can define its own time scale to supersede the file time scale. dwRate
Rate in an integer format. To obtain the rate in samples per second, divide this value by the value in dwScale.
dwLength
Length of the AVI file. The units are defined by dwRate and dwScale.
dwEditCount
Number of streams that have been added to or deleted from the AVI file.
szFileType
Null-terminated string containing descriptive information for the file type.
到MSDN中找,多的是