locked
VideoRenderer freezes on second use RRS feed

  • Question

  • I'm building an app that switches between preview/record/playback modes (using a webcam as input) by constructing then tearing town a FilterGraph for each mode. The problem is that the second time I try to add a VideoRenderer to a new graph, its output freezes. The graph appears to run fine, but there is no way to view the output. The first time works fine, in any mode. I've tried all kinds of threading combinations, but get the same result. There is an Infinite Tee between the webcam filter and the video renderer, as I'm concurrently streaming the result across a network sink. Again, this works fine. It's just the VideoRenderer....



    Can anyone help? I've spent days and days on this.
    Wednesday, December 9, 2009 4:57 PM

Answers

  • If I don't use IVideoWindow::put_Owner(hwnd), I see the ActiveMovie window for a fraction of a second.

    I do understand that you checked your COM management staff far more than once but could you double check that you are still holding a reference to your filter graph while you expect to have it running? Basically it would be sufficient to make an extra unmatching AddRef once, just for a test. A disappearing window looks like the graph being released and automatically stopped.

    BTW you can also register my spy DLL and see, from the log file, what calls you are getting on your filter graph. Maybe the graph unexpextedly receives Stop command or being released.

    http://alax.info/blog/tag/directshow
    • Marked as answer by The March Hare Tuesday, January 19, 2010 3:10 PM
    Thursday, December 31, 2009 9:23 AM

All replies

  • If the output freezes then this typically means that the time stamps it is receiving are wrong.  You can remove the graph clock by calling IMediaFilter::SetSyncSource(NULL) as a test to see if this is the case.  Retrieve the IMediaFilter interface from IGraphBuilder.


    www.chrisnet.net
    Wednesday, December 9, 2009 5:26 PM
  • Thank you for your very prompt reply. I tried this, and unfortunately the symptoms are the same. The worrying thing is that I am adding a completely new instance of VideoRenderer to a completely new instance of a FilterGraph. The first time I do it, the videoWindow works fine. The second time - freeze. It looks like there is some underlying static resource problem.
    Wednesday, December 9, 2009 5:43 PM
  • Do you see the renderer display the initial frame?  Does the streaming thread block inside the renderer or does the renderer return an error on it's Receive() method?
    www.chrisnet.net
    Wednesday, December 9, 2009 6:23 PM
  • Hi Chris

    I get an error (unspecified) when I make the call to Receive - but this could be down to my lack of understanding. I successfully got the IMemInputPin interface, but got the same error immediately before, and after the graph was run. But the answer tto your other question is clear. I don't get any frames in the ActiveMovie window- just the last frame from the previous graph! I am most definitely releasing the owner of the videoWindow, and nulling it before creating a new instance, so this is a puzzle.

    Like I said, the rest of the graph runs fine. I am recording, and streaming out across the web. It's just that the video preview window is not playing ball...
    Thursday, December 10, 2009 9:35 AM
  • I think that possibly the old instance is not getting freed like you think it is.  You are releasing your instance pointer, but the filter is not going to get deleted unless all references, interfaces, etc from anywhere in the graph are also released.

    Try this.

    Remove the renderer from the graph first, then release your interfaces to the renderer (all of them!).


    www.chrisnet.net
    Thursday, December 10, 2009 4:16 PM
  • Several weeks later, and I still haven't solved this problem, despite stripping everything right back. Now I have the opposite problem - I can't make the ActiveMovie window appear for more than a fraction of a second. The only fundamental difference between my design and the PlayCap sample is that I'm explicitly creating and adding the VideoRenderer to the graph. (This is because I'm recording and simultaneously streaming to a remote source, and Intelligent Connect just didn't seem to be able to create the graph.)

    Originally I was running the whole graph in a worker thread loop, which was when I was getting the freezing window. Now I'm just simply building the graph and running it on the application thread. I am sure I'm dealing correctly with the COM + lifecyle, releasing objects as I should.
    If I don't use IVideoWindow::put_Owner(hwnd), I see the ActiveMovie window for a fraction of a second. If I do, then my form window just doesn't show anything. In this latter situation, while my form window is correctly forwarding messages using IVideoWindow::NotifyOwnerMessage, I can't see it forwarding WM_DISPLAYCHANGED etc. messages. The rest of the graph is working perfectly, making a local recording and streaming to the remote. It seems absolutely crazy that I can't achieve this basic functionality after weeks of work.


    In 30 years of development, this has become the most frustrating project I've ever worked on!

    Thursday, December 31, 2009 9:13 AM
  • If I don't use IVideoWindow::put_Owner(hwnd), I see the ActiveMovie window for a fraction of a second.

    I do understand that you checked your COM management staff far more than once but could you double check that you are still holding a reference to your filter graph while you expect to have it running? Basically it would be sufficient to make an extra unmatching AddRef once, just for a test. A disappearing window looks like the graph being released and automatically stopped.

    BTW you can also register my spy DLL and see, from the log file, what calls you are getting on your filter graph. Maybe the graph unexpextedly receives Stop command or being released.

    http://alax.info/blog/tag/directshow
    • Marked as answer by The March Hare Tuesday, January 19, 2010 3:10 PM
    Thursday, December 31, 2009 9:23 AM
  • Hi. I recently have been experiencing the same problem as you. Even if the graph we are (re)building is different (it captures an rtp video and shows it on the monitor) the result is the same. The first time it works like a charm while the second time either it freezes without showing anything or it shows only some frames. Did you happen to solve your problem? How?
    Friday, January 29, 2010 8:35 AM