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. About DirectX Video Capture

About DirectX Video Capture

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsgame-devhelpannouncementlearning
8 Posts 3 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.
  • C Offline
    C Offline
    crazymubashir
    wrote on last edited by
    #1

    :(( Hey, I am having trouble capturing video from my pc cammera. The directx SDK directshow sample "Play Cap" have developed my previewing skills. But capturing is not going so well. In the DX9 Book it is said that just by making some minor changes in the ICaptureBuilderGraph2::RenderStream() we developers be able to capture live video. But thats not happening. In the "Play Cap" sample code when i do this minor changes as told it raises an error. //After g_pCapture->AddFilter(pSrcFilter); IBaseFilter *pMux; hr = g_Capture->SetOutPutFileName(&MEDIASUBTYPE_Avi, L"C:\\Test.avi", &pMux, NULL); hr = g_Capture->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Avi, pSrcFilter, NULL, pMux /*NULL*/); pMux->Release(); pSrcFilter->Release(); hr = setupVideoWindow(); // Raises an error at the first line // if i leave the renderstream last variable NULL then the program runs // succesfully. But capturing doesn't takes place.

    J C A 3 Replies Last reply
    0
    • C crazymubashir

      :(( Hey, I am having trouble capturing video from my pc cammera. The directx SDK directshow sample "Play Cap" have developed my previewing skills. But capturing is not going so well. In the DX9 Book it is said that just by making some minor changes in the ICaptureBuilderGraph2::RenderStream() we developers be able to capture live video. But thats not happening. In the "Play Cap" sample code when i do this minor changes as told it raises an error. //After g_pCapture->AddFilter(pSrcFilter); IBaseFilter *pMux; hr = g_Capture->SetOutPutFileName(&MEDIASUBTYPE_Avi, L"C:\\Test.avi", &pMux, NULL); hr = g_Capture->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Avi, pSrcFilter, NULL, pMux /*NULL*/); pMux->Release(); pSrcFilter->Release(); hr = setupVideoWindow(); // Raises an error at the first line // if i leave the renderstream last variable NULL then the program runs // succesfully. But capturing doesn't takes place.

      J Offline
      J Offline
      Justin Tay
      wrote on last edited by
      #2

      I don't see a video renderer filter, so how can you setup the video window? You seem to have only created a graph for capturing video to disk.

      1 Reply Last reply
      0
      • C crazymubashir

        :(( Hey, I am having trouble capturing video from my pc cammera. The directx SDK directshow sample "Play Cap" have developed my previewing skills. But capturing is not going so well. In the DX9 Book it is said that just by making some minor changes in the ICaptureBuilderGraph2::RenderStream() we developers be able to capture live video. But thats not happening. In the "Play Cap" sample code when i do this minor changes as told it raises an error. //After g_pCapture->AddFilter(pSrcFilter); IBaseFilter *pMux; hr = g_Capture->SetOutPutFileName(&MEDIASUBTYPE_Avi, L"C:\\Test.avi", &pMux, NULL); hr = g_Capture->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Avi, pSrcFilter, NULL, pMux /*NULL*/); pMux->Release(); pSrcFilter->Release(); hr = setupVideoWindow(); // Raises an error at the first line // if i leave the renderstream last variable NULL then the program runs // succesfully. But capturing doesn't takes place.

        C Offline
        C Offline
        crazymubashir
        wrote on last edited by
        #3

        :sigh: dear hfry, I didn't gave the whole code. In the paragraph it is mentioned that the "Play Cap" sample code which comes with dx9 SDK helped me develop some understanding of video capture. Now if you have seen the Source Code of "Play Cap" you will understand where in between that code i have inserted these lines. I have mention that after the line "g_pCapture->AddFilter()". Which you will find in the Funtion VideoCapture() "(Play Cap)" Source code. If even then you need the code then i will write the code for you. Thanks for the reply.

        J 1 Reply Last reply
        0
        • C crazymubashir

          :sigh: dear hfry, I didn't gave the whole code. In the paragraph it is mentioned that the "Play Cap" sample code which comes with dx9 SDK helped me develop some understanding of video capture. Now if you have seen the Source Code of "Play Cap" you will understand where in between that code i have inserted these lines. I have mention that after the line "g_pCapture->AddFilter()". Which you will find in the Funtion VideoCapture() "(Play Cap)" Source code. If even then you need the code then i will write the code for you. Thanks for the reply.

          J Offline
          J Offline
          Justin Tay
          wrote on last edited by
          #4

          I have taken the trouble to look at the sample. Did you add your capture code after hr = g_pCapture->RenderStream (&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, pSrcFilter, NULL, NULL) ? Or did you modify it into your capture code? If you render a video stream with the destination as NULL, it will render it to the default video renderer (The old video renderer usually, and VMR7 in non-mixing mode on Windows XP). edit: That said, if you want to do both capturing to disk and previewing to the screen, always render the preview pin first. That way in the event that there isn't a real preview pin, a smart-T filter will be inserted so you can do the capture. From memory AFAIK, I don't think the smart-T gets inserted if you render the capture pin first and there isn't a preview pin. -- modified at 9:09 Monday 27th March, 2006

          C 1 Reply Last reply
          0
          • J Justin Tay

            I have taken the trouble to look at the sample. Did you add your capture code after hr = g_pCapture->RenderStream (&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, pSrcFilter, NULL, NULL) ? Or did you modify it into your capture code? If you render a video stream with the destination as NULL, it will render it to the default video renderer (The old video renderer usually, and VMR7 in non-mixing mode on Windows XP). edit: That said, if you want to do both capturing to disk and previewing to the screen, always render the preview pin first. That way in the event that there isn't a real preview pin, a smart-T filter will be inserted so you can do the capture. From memory AFAIK, I don't think the smart-T gets inserted if you render the capture pin first and there isn't a preview pin. -- modified at 9:09 Monday 27th March, 2006

            C Offline
            C Offline
            crazymubashir
            wrote on last edited by
            #5

            Million thanks, Now it seems you have almost understood my problem. I have added the code below before the line you have mentioned and ommited it. The code below gives error when i give "renderstream" pMux Pointer. If i leave it null the code runs but video doesn't gets saved. This code is supposed to capture the live video. IBaseFilter *pMux; hr = g_pCapture->SetOutputFileName( &MEDIASUBTYPE_Avi, // Specifies AVI for the target file. L"C:\\Example.avi", // File name. &pMux, // Receives a pointer to the mux. NULL); // (Optional) Receives a pointer to the file sink. if(FAILED(hr)) { Msg(TEXT("Couldn't create save file...")); } hr = g_pCapture->RenderStream( &PIN_CATEGORY_CAPTURE, // Pin category. &MEDIATYPE_Video, // Media type. pSrcFilter, // Capture filter. NULL, // Intermediate filter (optional). pMux /*NULL*/); // Mux or file sink filter. // Release the mux filter. pMux->Release(); the code below remains as it is. // hr = g_pCapture->RenderStream( // &PIN_CATEGORY_PREVIEW, // Pin category. // &MEDIATYPE_Video, // Media type. // pSrcFilter, // Capture filter. // NULL, // Intermediate filter (optional). // NULL);

            J 1 Reply Last reply
            0
            • C crazymubashir

              Million thanks, Now it seems you have almost understood my problem. I have added the code below before the line you have mentioned and ommited it. The code below gives error when i give "renderstream" pMux Pointer. If i leave it null the code runs but video doesn't gets saved. This code is supposed to capture the live video. IBaseFilter *pMux; hr = g_pCapture->SetOutputFileName( &MEDIASUBTYPE_Avi, // Specifies AVI for the target file. L"C:\\Example.avi", // File name. &pMux, // Receives a pointer to the mux. NULL); // (Optional) Receives a pointer to the file sink. if(FAILED(hr)) { Msg(TEXT("Couldn't create save file...")); } hr = g_pCapture->RenderStream( &PIN_CATEGORY_CAPTURE, // Pin category. &MEDIATYPE_Video, // Media type. pSrcFilter, // Capture filter. NULL, // Intermediate filter (optional). pMux /*NULL*/); // Mux or file sink filter. // Release the mux filter. pMux->Release(); the code below remains as it is. // hr = g_pCapture->RenderStream( // &PIN_CATEGORY_PREVIEW, // Pin category. // &MEDIATYPE_Video, // Media type. // pSrcFilter, // Capture filter. // NULL, // Intermediate filter (optional). // NULL);

              J Offline
              J Offline
              Justin Tay
              wrote on last edited by
              #6

              And what is the hr error code from g_pCapture->RenderStream()? Before starting all this did you use GraphEdit to check what kind of graph you should be building?

              C 1 Reply Last reply
              0
              • J Justin Tay

                And what is the hr error code from g_pCapture->RenderStream()? Before starting all this did you use GraphEdit to check what kind of graph you should be building?

                C Offline
                C Offline
                crazymubashir
                wrote on last edited by
                #7

                Dear hfry, Sorry for the delayed answer. I am posting this message to inform you that my boss has shifted me directx to C#. Now I am doing work on some other project. The answer to your question is i didn't used graphEdit to check what kind of graph i should use. Now my final question is after using graphEdit in my application will i be able to generate a captured file successfully. Because with your help i am now able to just create blank file with nothing on it. Which gives an error that ClassFactory couldn't generate xxx. I will do as you have told me and give it a last try. By the way thanks for all ur time an patience. Forever gratefull. Mubashir

                1 Reply Last reply
                0
                • C crazymubashir

                  :(( Hey, I am having trouble capturing video from my pc cammera. The directx SDK directshow sample "Play Cap" have developed my previewing skills. But capturing is not going so well. In the DX9 Book it is said that just by making some minor changes in the ICaptureBuilderGraph2::RenderStream() we developers be able to capture live video. But thats not happening. In the "Play Cap" sample code when i do this minor changes as told it raises an error. //After g_pCapture->AddFilter(pSrcFilter); IBaseFilter *pMux; hr = g_Capture->SetOutPutFileName(&MEDIASUBTYPE_Avi, L"C:\\Test.avi", &pMux, NULL); hr = g_Capture->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Avi, pSrcFilter, NULL, pMux /*NULL*/); pMux->Release(); pSrcFilter->Release(); hr = setupVideoWindow(); // Raises an error at the first line // if i leave the renderstream last variable NULL then the program runs // succesfully. But capturing doesn't takes place.

                  A Offline
                  A Offline
                  aloha1812
                  wrote on last edited by
                  #8

                  Can you send me soure code of this programing ?( Visual c++ 6.0) I'm doing a project about"capturing video from webcam" Thanks aloha

                  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