problems editing a video stream in a AVIFile
I''m currently making a project where a I have to edit a uncompressed AVI file. The video stream is compressed in the IR32 format.
I''m trying to open the file and streams and then read each video frame and copy it in to a new file. But when I copy the information in to the new file, the information is not the same when I read it again. This means that when I''m playing the file there is a lot of gitter. how can I solve this problem??
Some of my sample code:
//opening videostream//
AVIFileGetStream(m_AviFile,&m_VideoStream,streamtypeVIDEO,0);
AVIStreamInfo(m_VideoStream,&m_VideoStreamInfo,sizeof(m_VideoStreamInfo));
m_GetFrame = AVIStreamGetFrameOpen(m_VideoStream,NULL);
//creating videostream in which to write//
//streamInfo contains the info of the original stream.
m_VideoStreamInfo.fccHandler = streamInfo>fccHandler;
m_VideoStreamInfo.dwFlags = 0; // don''t use - set to zero
m_VideoStreamInfo.dwCaps = 0; // not used - set to zero
m_VideoStreamInfo.wPriority = 0;
m_VideoStreamInfo.wLanguage = 0; // not used - set to zero
m_VideoStreamInfo.dwStart = 0; // don''t use - set to zero
m_VideoStreamInfo.dwLength = 0;
m_VideoStreamInfo.dwInitialFrames = 0;
m_VideoStreamInfo.dwSuggestedBufferSize =
3*bitmapWidth*bitmapHeight;
m_VideoStreamInfo.dwQuality = 10000; m_VideoStreamInfo.dwSampleSize = 0;
m_VideoStreamInfo.dwScale = streamInfo->dwScale;
m_VideoStreamInfo.dwRate = streamInfo->dwRate;
m_VideoStreamInfo.rcFrame = streamInfo->rcFrame;
m_VideoStreamInfo.dwEditCount = 0;
m_VideoStreamInfo.dwFormatChangeCount = 0;
strcpy(m_VideoStreamInfo.szName,"audio");
AVIFileCreateStream(m_AviFile,&m_VideoStream,&m_VideoStreamInfo);
LPAVICOMPRESSOPTIONS lpOptions;
lpOptions = new AVICOMPRESSOPTIONS;
lpOptions->fccType = streamtypeVIDEO;
lpOptions->fccHandler = streamInfo->fccHandler;
lpOptions->dwKeyFrameEvery = 20;
lpOptions->dwQuality = 10000;
lpOptions->dwBytesPerSecond = 0;
lpOptions->dwFlags = AVICOMPRESSF_KEYFRAMES /
AVICOMPRESSF_INTERLEAVE;
lpOptions->lpFormat = 0;
lpOptions->cbFormat = 0;
lpOptions->lpParms = 0;
lpOptions->cbParms = 0;
lpOptions->dwInterleaveEvery = 1;
AVIMakeCompressedStream(&m_CompressedVideoStream,m_VideoStream,lpOptions,NULL);
delete lpOptions;
// fill in the bitmapinfoheader
lpbmih = new BITMAPINFOHEADER;
lpbmih->biBitCount = 24; // 3-byte colour triplets
lpbmih->biClrImportant = 0; // all colours are used
lpbmih->biClrUsed = 0; // maximum colours
lpbmih->biCompression = 0;
lpbmih->biWidth = bitmapWidth;
lpbmih->biHeight = bitmapHeight;
lpbmih->biPlanes = 1; // always 1
lpbmih->biSize = sizeof(BITMAPINFOHEADER);
lpbmih->biSizeImage = lpbmih->biHeight*lpbmih->biWidth*3;
lpbmih->biXPelsPerMeter = 0; // uncompressed
lpbmih->biYPelsPerMeter = 0; // uncompressed
AVIStreamSetFormat(m_CompressedVideoStream, 0, lpbmih,
lpbmih->biSize );
m_VideoFormat = *lpbmih;
delete lpbmih;
//reading and writing///
lpSize = 3*bitmapwidth*bitmapheight;
LPBYTE lpData = new BYTE[lpSize];
LPBITMAPINFOHEADER lpbi;
lpbi = (LPBITMAPINFOHEADER)AVIStreamGetFrame(m_GetFrame,
frameNumber);
// grab the rgb data
memcpy(lpData,(LPBYTE)lpbi + lpbi->biSize,lpSize);
PAVISTREAM videoStream;
videoStream = m_VideoStream;
DWORD flags = AVIIF_KEYFRAME;
if(m_CompressedVideoStream != 0)
{
videoStream = m_CompressedVideoStream;
flags = 0;
}
AVIStreamWrite(videoStream,
frameNumber,
1,
lpData,
lpSize,
flags,
0,
0);
Jesper Tejlgaard Pedersen
(44) 01473 606535
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement