Hi !
I'm trying to do a small app to reverse avi (in time domain) and save a new avi like this.
In my first attempt, I use AVIFileOpen() function then AVIFileGetStream() to open a video stream, AVIStreamInfo() to get stream information, I create a new stream with same information with AVIFileCreateStream(), then i use this peace of code to read/write frames :
// read input file frame per frame and write output file
unsigned int i;
for (i=0; i<m_AviStreamInfo.dwLength; i++)
{
long StSize;
result = AVIStreamRead(*pAviStream,m_AviStreamInfo.dwLength-i-1,1,NULL,0,&StSize,NULL);
char * StBuffer = new char[StSize];
result = AVIStreamRead(*pAviStream,m_AviStreamInfo.dwLength-i-1,1,StBuffer,StSize,&StSize,NULL);
if (result !=0)
{
MessageBox("Error while reading stream"
delete StBuffer;
break;
}
result = AVIStreamWrite(*pOutputAviStream,i,1,StBuffer,StSize,0,NULL,&StSize);
if (result !=0)
{
MessageBox("Error while writing stream"
delete StBuffer;
break;
}
delete StBuffer;
m_Progress.SetPos(i+1);
Sleep(0);
}
BUT this does not work as i would because of the compression of the avi : Depending on the codec used, it is good or not.
So i would like to decompress frames and then to recompress them in the same format but i don't really know how to do it...
Do i need to use AVIStreamGetFrame() and then compress the frame, or do i need to open a decompressor then a compressor with ILocate() or ICOpen() and then do the decompression / compression process ?...
I need help on this point (if anybody has souce code it would be great ;-)) )
if anybody can help me
thanks a lot.
xander
I'm trying to do a small app to reverse avi (in time domain) and save a new avi like this.
In my first attempt, I use AVIFileOpen() function then AVIFileGetStream() to open a video stream, AVIStreamInfo() to get stream information, I create a new stream with same information with AVIFileCreateStream(), then i use this peace of code to read/write frames :
// read input file frame per frame and write output file
unsigned int i;
for (i=0; i<m_AviStreamInfo.dwLength; i++)
{
long StSize;
result = AVIStreamRead(*pAviStream,m_AviStreamInfo.dwLength-i-1,1,NULL,0,&StSize,NULL);
char * StBuffer = new char[StSize];
result = AVIStreamRead(*pAviStream,m_AviStreamInfo.dwLength-i-1,1,StBuffer,StSize,&StSize,NULL);
if (result !=0)
{
MessageBox("Error while reading stream"
delete StBuffer;
break;
}
result = AVIStreamWrite(*pOutputAviStream,i,1,StBuffer,StSize,0,NULL,&StSize);
if (result !=0)
{
MessageBox("Error while writing stream"
delete StBuffer;
break;
}
delete StBuffer;
m_Progress.SetPos(i+1);
Sleep(0);
}
BUT this does not work as i would because of the compression of the avi : Depending on the codec used, it is good or not.
So i would like to decompress frames and then to recompress them in the same format but i don't really know how to do it...
Do i need to use AVIStreamGetFrame() and then compress the frame, or do i need to open a decompressor then a compressor with ILocate() or ICOpen() and then do the decompression / compression process ?...
I need help on this point (if anybody has souce code it would be great ;-)) )
if anybody can help me
thanks a lot.
xander