2

I'm using DirectShow.NET with GMFBridge to build an application similar to the the GMFPreview example application, which allows one to render a preview from the video without glitches when video capture is stopped.

In my application, instead of starting/stopping to capture when a button is clicked, it does so every 30 minutes, so that I have continuous recording from the video source, broken into 30 minutes files - it shouldn't lose a single frame during the stop/start interval.

A simplified layout of the filters would be:

[ Source Graph ]
RTSP/RTMP Source [video+audio] --> Inf. Tee Filter --> Bridge Sink -->
--> [ Bridge Controller ] -->
    --> Bridge Source --> AsfWriter [Capture graph]
    --> Bridge Source --> NullRenderer [Preview graph]

The point of using GMFBridge here is that it allows the RTSP/RTMP Source to be always connected. BTW, my source comes from a device in the LAN.

When I stop capturing I do this:

public void Break()
{
    int hr = BridgeController.BridgeGraphs(null, null);
    int hr = RecMediaControl.Stop(); // stops the capture graph
    ... // Set filename for next recording
    int hr = RecMediaControl.Run();  // starts the capture graph
    int hr = BridgeController.BridgeGraphs(bridgeSink, captureGraph);
}

The problem is that the thread running this code sometimes gets stuck inside the "disconnect" method:

BridgeGraphs(null, null);

No error is thrown, it just stays there forever. Other threads continue executing normally, so I get a huge video file, instead of several 30 minutes files.

Preview graph is started when application starts to run and is also stopped when application finishes. The article explaining how to use GMFBridge seems to be written for a device which had a Capture pin and a Preview pin, which is not my case. I think that what I've done sets the Bridge Controller in suspend mode instead of discard mode, which would probably be more appropriate, but I'm not sure. Still, if I eliminate the preview graph, the same problem occurs.

This problem doesn't happen on all machines, and also it happens randomly - sometimes I have to wait several hours or even days for it to happen. I'm running out of ideas, anyone has a clue of what is going on? Thanks.

Eric Omine
  • 489
  • 4
  • 15
  • 1
    If you have a RTSP Source, why didn't you just build multiple graphs with it. If you start the second graph before you stop the first graph you should have no missing frames (but maybe some frames in both files). – CPlusSharp Oct 16 '15 at 06:51
  • 1
    I guess you have to debug GMFBridge itself. And look exactly where it gets stuck inside the GMFBridge classes. – wimh Oct 16 '15 at 11:19
  • @CPlusSharp I've considered this idea before, but I was worried that connecting the second RTSP filter would lead to sync issues between different videos. If I have 2 different filters connected to the same RTSP source, there'll be delay to create a new connection (that's why I want to keep the connection always alive) and also buffering, so I think it'd be hard to have these 2 graphs in sync. – Eric Omine Oct 16 '15 at 13:58

0 Answers0