Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. after calling GetCurrentBuffer(&lBufferSize,NULL), lBufferSize is minus value.

after calling GetCurrentBuffer(&lBufferSize,NULL), lBufferSize is minus value.

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rambojanggoon
    wrote on last edited by
    #1

    Hi, to capture video screen in DirectShow , I did as follwing... it's woring well in case of *.wmv file... but in case of *.avi didn't work... After calling ...GetCurrentBuffer(&lBufferSize,NULL); the value of lBufferSize is minus...(for example -2838382392 ) I don't know why lBufferSize is minus value... void CTest::play() { m_pGB = NULL; m_pMC = NULL; m_pVW = NULL; m_pBV = NULL; m_pME = NULL; m_pMS = NULL; m_pSampleGrabber = NULL; m_pSG = NULL; CoInitialize(NULL); CString m_file; WCHAR wFileName[MAX_PATH]; TCHAR m_szFileName[MAX_PATH]; m_file = m_,"C:\\cs\\mds\\movie\\a.avi"; #ifndef UNICODE MultiByteToWideChar(CP_ACP, 0, m_file , -1, wFileName, MAX_PATH) ; #else lstrcpy(wFileName, m_szFileName); #endif CoCreateInstance(CLSID_FilterGraph,NULL,CLSCTX_INPROC,IID_IGraphBuilder,(void**)&m_pGB); CoCreateInstance(CLSID_SampleGrabber,NULL,CLSCTX_INPROC,IID_IBaseFilter,(void**)&m_pSampleGrabber); m_pGB->AddFilter(m_pSampleGrabber,L"Sample Grabber"); AM_MEDIA_TYPE m_pMedia; ZeroMemory(&m_pMedia,sizeof(m_pMedia)); m_pMedia.majortype = MEDIATYPE_Video; m_pMedia.subtype = MEDIASUBTYPE_RGB24; m_pSampleGrabber->QueryInterface(IID_ISampleGrabber,(void**)&m_pSG); if(m_pSG != NULL) { m_pSG->;SetMediaType(&m_pMedia); m_pSG->SetBufferSamples(TRUE); } m_pGB->QueryInterface(IID_IMediaControl,(void**)&m_pMC); m_pGB->QueryInterface(IID_IVideoWindow,(void**)&m_pVW); m_pGB->QueryInterface(IID_IBasicVideo,(void**)&m_pBV); m_pGB->QueryInterface(IID_IMediaEventEx,(void**)&m_pME); m_pGB->QueryInterface(IID_IMediaSeeking,(void**)&m_pMS); m_pGB->RenderFile(wFileName,NULL); m_pMC->Run(); } void CTest::ScreenShot() { m_pSampleGrabber->QueryInterface(IID_ISampleGrabber,(void**)&m_pSG); if(m_pSG == NULL) { return; } long lBufferSize; m_pSG->GetCurrentBuffer(&lBufferSize, NULL); BYTE* pBuffer = new BYTE[lBufferSize]; if (!pBuffer) return; m_pSG->GetCurrentBuffer(&lBufferSize, (long *)pBuffer); if (m_pSG != NULL)SaveImage(...); delete pBuffer; }

    C 1 Reply Last reply
    0
    • R rambojanggoon

      Hi, to capture video screen in DirectShow , I did as follwing... it's woring well in case of *.wmv file... but in case of *.avi didn't work... After calling ...GetCurrentBuffer(&lBufferSize,NULL); the value of lBufferSize is minus...(for example -2838382392 ) I don't know why lBufferSize is minus value... void CTest::play() { m_pGB = NULL; m_pMC = NULL; m_pVW = NULL; m_pBV = NULL; m_pME = NULL; m_pMS = NULL; m_pSampleGrabber = NULL; m_pSG = NULL; CoInitialize(NULL); CString m_file; WCHAR wFileName[MAX_PATH]; TCHAR m_szFileName[MAX_PATH]; m_file = m_,"C:\\cs\\mds\\movie\\a.avi"; #ifndef UNICODE MultiByteToWideChar(CP_ACP, 0, m_file , -1, wFileName, MAX_PATH) ; #else lstrcpy(wFileName, m_szFileName); #endif CoCreateInstance(CLSID_FilterGraph,NULL,CLSCTX_INPROC,IID_IGraphBuilder,(void**)&m_pGB); CoCreateInstance(CLSID_SampleGrabber,NULL,CLSCTX_INPROC,IID_IBaseFilter,(void**)&m_pSampleGrabber); m_pGB->AddFilter(m_pSampleGrabber,L"Sample Grabber"); AM_MEDIA_TYPE m_pMedia; ZeroMemory(&m_pMedia,sizeof(m_pMedia)); m_pMedia.majortype = MEDIATYPE_Video; m_pMedia.subtype = MEDIASUBTYPE_RGB24; m_pSampleGrabber->QueryInterface(IID_ISampleGrabber,(void**)&m_pSG); if(m_pSG != NULL) { m_pSG->;SetMediaType(&m_pMedia); m_pSG->SetBufferSamples(TRUE); } m_pGB->QueryInterface(IID_IMediaControl,(void**)&m_pMC); m_pGB->QueryInterface(IID_IVideoWindow,(void**)&m_pVW); m_pGB->QueryInterface(IID_IBasicVideo,(void**)&m_pBV); m_pGB->QueryInterface(IID_IMediaEventEx,(void**)&m_pME); m_pGB->QueryInterface(IID_IMediaSeeking,(void**)&m_pMS); m_pGB->RenderFile(wFileName,NULL); m_pMC->Run(); } void CTest::ScreenShot() { m_pSampleGrabber->QueryInterface(IID_ISampleGrabber,(void**)&m_pSG); if(m_pSG == NULL) { return; } long lBufferSize; m_pSG->GetCurrentBuffer(&lBufferSize, NULL); BYTE* pBuffer = new BYTE[lBufferSize]; if (!pBuffer) return; m_pSG->GetCurrentBuffer(&lBufferSize, (long *)pBuffer); if (m_pSG != NULL)SaveImage(...); delete pBuffer; }

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      Please, read the posting guidelines before posting (use the code tags to format your code properly, to make it more readable). For your question, did you check the return value of GetCurrentBuffer ? See the documentation[^]

      Cédric Moonen Software developer
      Charting control [v2.0] OpenGL game tutorial in C++

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups