Infognition forum
August 01, 2010, 07:08:03 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Last GraphEditPlus version: 1.4.0   Last Video Enhancer version: 1.9.3
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Troubles with Video Renderer in C# on secondary screen  (Read 982 times)
armin
Newbie
*

Karma: +2/-0
Posts: 2


View Profile
« on: March 05, 2009, 07:57:18 PM »

Hello
I used GraphEditPlus to create some C# code to render video and TV signals.
I don't get it working the way I would like.
With "Video Renderer" {6BC1CFFA-8FC1-4261-AC22-CFB4CC38DB50}, it runs only on the main screen, but when I move the window to the secondary screen, the image is blank.
With "Video Renderer" {70E102B0-5556-11CE-97C0-00AA0055595A}, it runs on both screens and I can move the window flawless between the screens. But when I try to run this graph in my C# app the video is flipped upside down (mirrored).Huh?
I also tried "VideoMixingRenderer9" in both modes (windowed/windowless). As soon as I move the window between the screens, the image freezes.

How is the GraphEditPlus "Video Renderer" window created? This seems not to flip the image (unless you play around with properties too much)

Here the code I used to build the graph and connect the window. It flips the image and I don't have a clue why.

        public void BuildGraph( string videoFileName, Control previewWindow )
        {
            FilterGraph graph = new FilterGraph( );
            graphBuilder = ( IGraphBuilder ) graph;

            // Get the Capture Graph Builder
            captureGraphBuilder = ( ICaptureGraphBuilder2 ) new CaptureGraphBuilder2( );

            // Link the CaptureGraphBuilder to the filter graph
            int hr = captureGraphBuilder.SetFiltergraph( graphBuilder );
            if ( hr < 0 ) Marshal.ThrowExceptionForHR( hr );

            IBaseFilter vr = ( IBaseFilter ) Activator.CreateInstance( typeof( VideoRenderer ) );
            hr = graphBuilder.AddFilter( vr, "Video Renderer" );
            if ( hr < 0 ) Marshal.ThrowExceptionForHR( hr );

            this.graphBuilder.RenderFile( videoFileName, "" );

            rotCookie = new DsROTEntry( graphBuilder );

            // Get the IVideoWindow interface
            this.videoWindow = ( IVideoWindow ) this.graphBuilder;
            this.previewWindow = previewWindow;

            // Set the video window to be a child of the main window
            hr = videoWindow.put_Owner( previewWindow.Handle );
            if ( hr < 0 ) Marshal.ThrowExceptionForHR( hr );

            // Set video window style
            hr = videoWindow.put_WindowStyle( WindowStyle.Child | WindowStyle.ClipChildren | WindowStyle.ClipSiblings );
            if ( hr < 0 ) Marshal.ThrowExceptionForHR( hr );

            // Position video window in client rect of owner window
            previewWindow.Resize += new EventHandler( onPreviewWindowResize );
            onPreviewWindowResize( previewWindow, null );

            // Make the video window visible, now that it is properly positioned
            hr = videoWindow.put_Visible( OABool.True );
            if ( hr < 0 ) Marshal.ThrowExceptionForHR( hr );
        }

        protected void onPreviewWindowResize( object sender, EventArgs e )
        {
            if ( videoWindow != null )
            {
                // Position video window in client rect of owner window
                Rectangle rc = previewWindow.ClientRectangle;
                videoWindow.SetWindowPosition( 0, 0, rc.Right, rc.Bottom );
            }
        }


Thanks for any help on this. I googled hours and couln't find an answer.
Logged
Dee Mon
Administrator
Sr. Member
*****

Karma: +7/-0
Posts: 271



View Profile WWW
« Reply #1 on: March 07, 2009, 09:57:47 AM »

When GraphEditPlus enumerates filters in a category to show the list in the left window, it remembers their DisplayNames.
When one double clicks a filter in the list, GEP creates the filter via a moniker using its DisplayName (see MSDN for CreateBindCtx, MkParseDisplayName and BindToObject). This way is more complicated but the result shouldn't differ from creating the way you quoted above. For video renderer window there is just one special thing:
Code:
                IVideoWindow vw = basefilter as IVideoWindow;
                if (vw != null)
                {
                    string s;
                    vw.get_Caption(out s);
                    string gname = Graph.Form.Text + ": " + name + ": ";
                    vw.put_Caption(gname + s);
                    WindowStyleEx wex;
                    vw.get_WindowStyleEx(out wex);
                    vw.put_WindowStyleEx(wex | WindowStyleEx.Topmost);
                }

When video decoder and renderer connect they agree on a media type. If you examine its contents you'll find BitmapInfoHeader with value Height. This value can sometimes be negative meaning a flipped picture. If the decoder and renderer do not pay attention to the sign of this field, you can get the video upside down.
In your program you add the graph to the ROT. Connect to it in GEP and look at the media types before and after the decoder. If you find the case with the sign of Height, you should either try asking video renderer to flip it back (see interfaces IBasicVideo, IBasicVideo2, IVideoWindow, maybe some functions there can help) or force the media type with proper sign by inserting another filter between the decoder and the renderer (your own or SampleGrabber, for example).
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!