Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,
I'm tring to develop a SW that extracts single bmp frames from a video file encoded with 3ivx codec. I must use vfw interfaces...
First of all I'have installed 3ivx decoder (3ivx_MPEG-4_504) and check that with "mediaplayer classic" video is played correctly. Im'm working on win8.1 64bit machine - Vs2010 c++.
Then if I run my SW (w32 app) with "Administrator Privileges" or in "compatibility mode" works; otherwise, if run it with normal privileges and with no compatibility function, "AVIStreamGetFrameOpen" always returns NULL.
Searching on the web i found a lot of possible configuration, almost all of them works correctly with compatibilty mode but not without.
If I run the SW in WIN_XP everything works.

Follows an extract of the source code:

C++
PGETFRAME m_pFrame;
	PAVIFILE  m_Avi;
	PAVISTREAM m_pStream;
	bool m_bAviLibInitialized;
	bool m_bAviFileOpened;
	unsigned int m_nSize;


	AVIFileInit();
	
	
    int res=AVIFileOpen(&m_Avi, szFileName, OF_READ, NULL);

    
	
    AVIFILEINFO avi_info;
    AVIFileInfo(m_Avi, &avi_info, sizeof(AVIFILEINFO));

    res=AVIFileGetStream(m_Avi, &m_pStream, streamtypeVIDEO /*video stream*/, 
                                               0 /*first stream*/);


    //do some task with the stream
    int iNumFrames;
    int iFirstFrame;

    iFirstFrame=AVIStreamStart(m_pStream);
    if (iFirstFrame==-1)
    {
        //Error getteing the frame inside the stream

        if (m_pStream!=NULL)
            AVIStreamRelease(m_pStream);

        AVIFileExit();
		
        return FALSE;
    }

    iNumFrames=AVIStreamLength(m_pStream);
    if (iNumFrames==-1)
    {
        //Error getteing the number of frames inside the stream
        
        if (m_pStream!=NULL)
            AVIStreamRelease(m_pStream);
        
        AVIFileExit();
		
        return FALSE;
    }

    //getting bitmap from frame
   BITMAPINFOHEADER bih;
    ZeroMemory(&bih, sizeof(BITMAPINFOHEADER));

    bih.biBitCount=24;    //24 bit per pixel
    bih.biClrImportant=0;
    bih.biClrUsed = 0;
    bih.biCompression = BI_RGB;
    bih.biPlanes = 1;
    bih.biSize = 40;
    bih.biXPelsPerMeter = 0;
    bih.biYPelsPerMeter = 0;
    //calculate total size of RGBQUAD scanlines (DWORD aligned)
    bih.biSizeImage = (((bih.biWidth * 3) + 3) & 0xFFFC) * bih.biHeight;

   AVIStreamStart(m_pStream);

   m_pFrame=AVIStreamGetFrameOpen(m_pStream, &bih);
 
   if (m_pFrame == NULL)
   {
	   AfxMessageBox(_T("Unable to Open Video File"),MB_ICONERROR | MB_OK);
   }


I also try to call AVIStreamGetFrameOpen with following parameters:

m_pFrame=AVIStreamGetFrameOpen(m_pStream, NULL);
m_pFrame=AVIStreamGetFrameOpen(m_pStream, (BITMAPINFOHEADER*) AVIGETFRAMEF_BESTDISPLAYFMT);


Thanks in advance for any suggestion!
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900