|
企业版支持碎片
H-AVI Recovery v1.4(企业版).zip
(3.31 MB, 下载次数: 3036)
个人版不支持碎片
H-AVI Recovery v1.4.rar
(2.68 MB, 下载次数: 2193)
avi碎片提取原来 可以参照结构 和bmp可以互转 大家可以到网上找找相关源码 很多
void CAVI1Dlg::OnButtonOpen()
{
AVIFileInit(); //初始化AVI
PAVIFILE avi; //声明AVI文件句柄
int res = AVIFileOpen(&avi, "avi.avi ",OF_READ,NULL); //打开AVI文件并判断
if(res != AVIERR_OK)
{
AfxMessageBox( "error #1 ");
if(avi != NULL)
AVIFileRelease(avi);
return;
}
PAVISTREAM pStream; //声明AVI流
res = AVIFileGetStream(avi,&pStream,streamtypeVIDEO,0); //打开AVI流并判断
if(res != AVIERR_OK)
{
AfxMessageBox( "error #2 ");
if(pStream != NULL)
AVIStreamRelease(pStream);
AVIFileExit();
return;
}
int iNumFrames; //声明AVI总共帧数
int iFirstFrames; //声明AVI第一帧
iFirstFrames = AVIStreamStart(pStream); //第一帧付值并判断
if(iFirstFrames == -1)
{
AfxMessageBox( "error #3 ");
if(pStream != NULL)
AVIStreamRelease(pStream);
AVIFileExit();
return;
}
iNumFrames = AVIStreamLength(pStream); //总帧数付值并判断
if(iNumFrames == -1)
{
AfxMessageBox( "error #4 ");
if(pStream != NULL)
AVIStreamRelease(pStream);
AVIFileExit();
return;
}
BITMAPINFOHEADER bih; //声明BMP信息头
ZeroMemory(&bih,sizeof(BITMAPINFOHEADER)); //开内存付值为0
//写入信息头
bih.biBitCount = 24;
bih.biClrImportant = 0;
bih.biClrUsed = 0;
bih.biCompression = BI_RGB;
bih.biPlanes = 1;
bih.biSize = 40;
bih.biXPelsPerMeter = 0;
bih.biYPelsPerMeter = 0;
bih.biSizeImage = (((bih.biWidth * 3)+3)&0xFFFC)*bih.biHeight;
PGETFRAME pFrame; //声明AVI帧
pFrame = AVIStreamGetFrameOpen(pStream,NULL); //打开AVI帧付值
int index = 0;
for(int i = iFirstFrames;i <iNumFrames;i++) //循环,取出每一帧,写入每个BMP
{
index =i - iFirstFrames;
BYTE* pDIB = (BYTE*)AVIStreamGetFrame(pFrame,index); //取出每一帧
RtlMoveMemory(&bih.biSize,pDIB,sizeof(BITMAPINFOHEADER));
BYTE* Bits = new BYTE[bih.biSizeImage]; //小东西藏在这
RtlMoveMemory(Bits,pDIB + sizeof(BITMAPINFOHEADER),bih.biSizeImage);
BYTE memBitmapInfo[40];
RtlMoveMemory(memBitmapInfo,&bih,sizeof(bih));
BITMAPFILEHEADER bfh; //声明BMP文件头,并写入
bfh.bfType = 19778;
bfh.bfSize = 55 + bih.biSizeImage;
bfh.bfReserved1 = 0;
bfh.bfReserved2 = 0;
bfh.bfOffBits = sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER);
CString FileName; //建立文件
FileName.Format( "%d.bmp ",index);
FILE* fp = fopen(FileName, "wb ");
if(fp != NULL)
{
fwrite(&bfh,sizeof(bfh),1,fp); //写入文件头
fwrite(&memBitmapInfo,sizeof(memBitmapInfo),1,fp); //写入信息头
fwrite(Bits,bih.biSizeImage,1,fp); //写入每一帧
}
else
{
AfxMessageBox( "error #5 ");
}
delete[] Bits; //删掉小东西
}
AVIStreamGetFrameClose(pFrame); //关闭AVI帧付值,必须与打开对应
if(pStream != NULL) //善后
AVIStreamRelease(pStream);
AVIFileExit();
} |
|