Now, I have some avi files. Some file have key frame every 30 frame.
and i want to compress them to be a new file which every frame is key frame.
So I write a codec as following: (and use vitrualDub to compress file)
__declspec(dllexport) LRESULT WINAPI DriverProc(DWORD dwDriverID, HDRVR hDriver, UINT uiMessage, LPARAM lParam1, LPARAM lParam2)
{
CCodec *pCodec = (CCodec *)(UINT) dwDriverID;
//ASSERT(NULL);
ICOPEN *icinfo = (ICOPEN *)lParam2;
switch(uiMessage)
{
.......
case ICM_COMPRESS:
return pCodec->EncodeEncode(lParam1, lParam2);
}
}
and
long CCodec::EncodeEncode(LPARAM lParam1, LPARAM lParam2)
{
ICCOMPRESS *icc = (ICCOMPRESS *)lParam1;
BITMAPV4HEADER *lpbihdr_i = (BITMAPV4HEADER *)icc->lpbiInput;
BITMAPV4HEADER *lpbihdr_o = (BITMAPV4HEADER *)icc->lpbiOutput;
icc->dwFlags=ICCOMPRESS_KEYFRAME; //add for KF!!!!!!!
*icc->lpdwFlags=AVIIF_KEYFRAME; //add for KF!!!!!!!
Convert(lpbihdr_i->bV4V4Compression, FOURCC_I420,
(PUCHAR)icc->lpInput,
m_pConvertBuffer,
lpbihdr_i->bV4Width,
lpbihdr_i->bV4Height,
lpbihdr_i->bV4BitCount);
CompressOneFrame(m_pConvertBuffer,*pdwDataSize);
memcpy((PUCHAR)icc->lpOutput,puc264Picture,*pdwDataSize);
lpbihdr_o->bV4SizeImage = *pdwDataSize;
return ICERR_OK;
}
After compress the file which there is a key frame every 30 frame, the key frame in compressed file is still unchanged. in another word, there is still one key fame every 30 frame. In track bar
How to compress every frame with setting it to be key frame?
any answer will be appreciate!
and i want to compress them to be a new file which every frame is key frame.
So I write a codec as following: (and use vitrualDub to compress file)
__declspec(dllexport) LRESULT WINAPI DriverProc(DWORD dwDriverID, HDRVR hDriver, UINT uiMessage, LPARAM lParam1, LPARAM lParam2)
{
CCodec *pCodec = (CCodec *)(UINT) dwDriverID;
//ASSERT(NULL);
ICOPEN *icinfo = (ICOPEN *)lParam2;
switch(uiMessage)
{
.......
case ICM_COMPRESS:
return pCodec->EncodeEncode(lParam1, lParam2);
}
}
and
long CCodec::EncodeEncode(LPARAM lParam1, LPARAM lParam2)
{
ICCOMPRESS *icc = (ICCOMPRESS *)lParam1;
BITMAPV4HEADER *lpbihdr_i = (BITMAPV4HEADER *)icc->lpbiInput;
BITMAPV4HEADER *lpbihdr_o = (BITMAPV4HEADER *)icc->lpbiOutput;
icc->dwFlags=ICCOMPRESS_KEYFRAME; //add for KF!!!!!!!
*icc->lpdwFlags=AVIIF_KEYFRAME; //add for KF!!!!!!!
Convert(lpbihdr_i->bV4V4Compression, FOURCC_I420,
(PUCHAR)icc->lpInput,
m_pConvertBuffer,
lpbihdr_i->bV4Width,
lpbihdr_i->bV4Height,
lpbihdr_i->bV4BitCount);
CompressOneFrame(m_pConvertBuffer,*pdwDataSize);
memcpy((PUCHAR)icc->lpOutput,puc264Picture,*pdwDataSize);
lpbihdr_o->bV4SizeImage = *pdwDataSize;
return ICERR_OK;
}
After compress the file which there is a key frame every 30 frame, the key frame in compressed file is still unchanged. in another word, there is still one key fame every 30 frame. In track bar
How to compress every frame with setting it to be key frame?
any answer will be appreciate!
Comment