Voici le code que les 14 premières streams et je ne sais pas pourquoimais après ilne veut pas faire le "AVICreateStream":
int AVIExtraction(char* Name)
{
AVIFileInit();/*initialisation*/
PAVIFILE avi;
/*openning and test of the avi file*/
int r=AVIFileOpen(&avi, Name, OF_READ, NULL);
if(r!=AVIERR_OK)
{
if(avi!=NULL)
AVIFileRelease(avi);
puts("error in openning avi file");
return -1;
}
/*copy of the information*/
AVIFILEINFO info;
AVIFileInfo(avi, &info, sizeof(AVIFILEINFO));
/*getting and test of the stream for a video*/
PAVISTREAM avistream;
r=AVIFileGetStream(avi, &avistream, streamtypeVIDEO, 0);
if(r!=AVIERR_OK)
{
if(avistream!=NULL)
AVIStreamRelease(avistream);
AVIFileExit();
puts("error in getting the stream of the avi file");
return -1;
}
/*creation of bitmap pictures*/
int NFrames=AVIStreamLength(avistream);/*number of frame*/
int FirstFrame=AVIStreamStart(avistream);/*First Frame*/
BITMAPINFOHEADER BInfo;
ZeroMemory(&BInfo, sizeof(BITMAPINFOHEADER));/*restoring*/
BInfo.biBitCount = 12; /*24 bit per pixel*/
BInfo.biCompression = 0; /*BI_RGB;*/
BInfo.biHeight = info.dwHeight;
BInfo.biWidth = info.dwLength;
BInfo.biPlanes = 1;
BInfo.biSize = sizeof(BInfo);
/*prepare to decopress*/
PGETFRAME frame;
frame=AVIStreamGetFrameOpen(avistream, NULL);
if(frame==NULL)
{
puts("error in the preparation");
return -1;
}
PAVIFILE newavi;
/*openning and test of the avi file*/
r=AVIFileOpen(&newavi, "test.avi",OF_WRITE | OF_CREATE, NULL);
if(r!=0)
{
if(newavi!=NULL)
AVIFileRelease(newavi);
puts("error in openning avi file2");
return -1;
}
/*get the frames*/
int i,j=0;
for (i=FirstFrame; i<NFrames; i++)
{
j= i-FirstFrame;
puts("hello1");
int* pDIB =(int*) AVIStreamGetFrame(frame, j);
r=AVICreation(BInfo,pDIB, newavi);puts("hello2");
//BitmapCreation(pDIB, j);
if(r==FALSE)
{
puts("error in the avi movie creation loop");
printf("number of created stream : %d\n",j);
return -1;
}
}
AVIStreamGetFrameClose(frame);
/*close the stream */
if (avistream!=NULL)
AVIStreamRelease(avistream);
AVIFileExit();
puts(" the extraction is finshed");
return NFrames;
}
BOOL AVICreation(BITMAPINFOHEADER bih, int* pDIB,PAVIFILE newavi)
{
int r;
/*copy of the information*/
AVISTREAMINFO streaminfo;
ZeroMemory(&streaminfo, sizeof(AVISTREAMINFO));/*restoring*/
streaminfo.fccType = streamtypeVIDEO;
streaminfo.fccHandler =0;//mmioFOURCC('M','P','G','4');
streaminfo.dwScale = 1;
streaminfo.dwRate =30;
streaminfo.dwSuggestedBufferSize =0;
streaminfo.dwQuality =1000;
streaminfo.rcFrame.right =bih.biWidth;
streaminfo.rcFrame.bottom =bih.biHeight;
/*creation of the new stream*/
PAVISTREAM avistream;
r=AVIFileCreateStream(newavi,&avistream, &streaminfo);
if (r!=0)
{
puts("error in the creation of the new stream");
AVIFileRelease (newavi);
AVIFileExit ();
return FALSE;
}
/*format of the stream*/
AVIStreamSetFormat(avistream, 0, &bih, sizeof(bih));
if (r!=0)
{
puts("error in the setting of the stream format");
AVIStreamClose(avistream);
AVIFileRelease (newavi);
AVIFileExit ();
return FALSE;
}
/*stream writing */
AVIStreamWrite(avistream,0,30,pDIB,bih.biSizeImage,AVIIF_KEYFRAME,NULL,NULL);
puts("hello");
AVIFileRelease (newavi);
return TRUE;
}
MERCI de m'aider je me suis inspirer du WRITEAVI de MSDN et de différents code trouvés ici où sur d'autres sites.