locked
Webcam disconnects when moving application between dual monitors RRS feed

  • Question

  • Hi

    I'm developing a c# application using DirectShow. To make my question really simple my problem can be visualized in GraphEdit by:

    1) Add webcam filter

    2) Right click "Capture" pin and select "Render Pin"

    If a play the graph i capture webcam images. The problem occurs when moving this form to another monitor. The webcam reconnects. I have tried with two different cameraes and can see on the light ball of the camera that it shuts down and reconnect.

    Now if i go to "My Computer" in Win XP and move around the image that can be captured by the same camera it works. It doesn't reconnect.

    What do i have to do in DirectShow to stay connected when moving my application between monitors?

    Br

    AHR

    Thursday, June 16, 2011 2:51 PM

All replies

  • What's happening is that the renderer requests a reconnection so it can renegotiate formats and surfaces using what is available on the new display, which may be in a different format etc. With file-based playback, the stop/disconnect/run is followed by a seek back to where it was, so the overall effect is not that noticeable. 

    You can override the handler for EC_DISPLAY_CHANGED (but I think the renderer will still need to be disconnected to renegotiate). I think you could also use GDI rendering with the original video renderer (not one of the VMRs or EVR).

     

    G

     

    Thursday, June 16, 2011 4:13 PM
  • I just did override WndProc on my form and can see and EventCode.Paused is send when moving my app from one monitor to another.

    protected

    override void WndProc(ref Message m)

    {

     

    if (m.Msg == WMGraphNotify)

    {

     

    IntPtr p1, p2;

     

    EventCode code;

    media.GetEvent(

    out code, out p1, out p2, 0);

     

    if (code == EventCode.Paused)

     

    MessageBox.Show("Video Paused");

    media.FreeEventParams(code, p1, p2);

    }

     

    base.WndProc(ref m);

    }

    Any idea on how not to get my webcam paused?

    Br

    AHR

    Thursday, June 16, 2011 4:16 PM
  • The problem is I'm recording video while moving my application around. If I move the window from one monitor to another i will lose the recording from the first monitor and it will start recording again on the second monitor.

     

    Can you explain the last part of you idea better? The EC_DISPLAY_CHANGED and GDI part I'm not sure what to do about that.

     

    Br

    AHR

    Thursday, June 16, 2011 4:23 PM
  • Hey there,

    have you gone through the following link? Combining Video Capture and Preview

    The reason of this issue and possible solutions are mentioned there...

    Hope this might help you!

    Monday, June 20, 2011 5:45 AM
  • Thanks bhavesh

    Do you have any good links or some sample code on how to implement the Stream Buffer Engine solution?

    Br

    AHR

    Monday, June 20, 2011 7:57 PM