Knowledge Base Nr: 00164 aviread.cpp - http://www.swe-kaiser.de
Downloads:
Win32: einzelne Bilder aus AVI-Datei extrahieren und anzeigen
void CAvitestDlg::OnFilm()
{
AVIFileInit();
PAVIFILE avifile;
PAVISTREAM pavi;
int nErr = AVIFileOpen(&avifile, "c:/temp/lulli-5f.avi", OF_READ, NULL);
nErr = AVIFileGetStream(avifile, &pavi,streamtypeVIDEO, 0);
AVISTREAMINFO psi;
nErr = AVIStreamInfo(pavi, &psi, sizeof(psi));
//psi.rcFrame (right, button): grösse x,y
//psi.dwStart, psi.dwLength frames
static LONG s_lStart = 0;
LONG lSamples = 1;
BYTE* pBuffer = new BYTE[psi.dwSuggestedBufferSize];
LONG lBytes;
nErr = AVIStreamRead(pavi, s_lStart, lSamples, pBuffer, psi.dwSuggestedBufferSize, &lBytes, &lSamples);
if (++s_lStart >= psi.dwLength)
s_lStart = 0;
//bild ausgeben
CImageSupport img;
img.SetBuffer(pBuffer, psi.rcFrame.right, psi.rcFrame.bottom, 24);
CWnd* pWnd = GetDlgItem(IDC_FRAME);
img.ShowThumbnail(pWnd);
//
delete[] pBuffer;
AVIFileRelease(avifile);
AVIFileExit();
}