VMR9 issue [modified]
-
This is more of a Video question. I hope someone out there can help me out, and if so, I really appreciate it. I am trying to modify the DVD Player sample for DirectShow to use VMR9 with the allocator and presenter. I setup code to RenderDvdVideoVolume with the VMR9Only flag and I added code to FindFilterByName for the Video Mixing Renderer 9 from the filtergraph. I get the filter and it is not null. Then I want to configure the filter, so I get the IVMRFilterConfig9 interface by casting my filter to that interface as done in quite a few of the examples. By the way, this is being done on a machine with Windows Vista. Next, when I use the config interface to configure the VMR9 filter, I run into problems. If I try to set the rendering mode or the number of streams I get an exception that tells me "The operation could not be performed because the filter is in the wrong state." I have looked all over for solutions to this, but I have not had any luck. Below is a snippet of my code and the VMR9 filter is declared outside of this snippet as a private IBaseFilter. int hr; AMDvdRenderStatus status; object comobj = null; try { dvdGraph = (IDvdGraphBuilder)new DvdGraphBuilder(); //filter = (IBaseFilter)new VideoMixingRenderer9(); //hr = dvdGraph.RenderDvdVideoVolume( null, AMDvdGraphFlags.None, out status ); hr = dvdGraph.RenderDvdVideoVolume(null, AMDvdGraphFlags.VMR9Only, out status); DsError.ThrowExceptionForHR( hr ); hr = dvdGraph.GetDvdInterface( typeof( IDvdInfo2 ).GUID, out comobj ); DsError.ThrowExceptionForHR( hr ); dvdInfo = (IDvdInfo2) comobj; comobj = null; hr = dvdGraph.GetDvdInterface( typeof( IDvdControl2 ).GUID, out comobj ); DsError.ThrowExceptionForHR( hr ); dvdCtrl = (IDvdControl2) comobj; comobj = null; hr = dvdGraph.GetFiltergraph( out graphBuilder ); DsError.ThrowExceptionForHR( hr ); hr = graphBuilder.FindFilterByName("Video Mixing Renderer 9", out filter); DsError.ThrowExceptionForHR(hr); if (filter == null) { MessageBox.Show("Need to add the VMR9 Filter"); } IVMRFilterConfig9 filterConfig = (IVMRFilterConfig9)filter; //********** // This is where I run into the exception //********** //hr = filterConfig.SetRenderingMode(VMR9Mode.Renderless); hr = filterConfig.SetRenderingMode(VMR9Mode.Windowed); DsError.ThrowExceptionForHR(hr); hr = filterConfig.SetNumberOfStreams(1); DsError.ThrowExceptionForHR(hr); SetAl
-
This is more of a Video question. I hope someone out there can help me out, and if so, I really appreciate it. I am trying to modify the DVD Player sample for DirectShow to use VMR9 with the allocator and presenter. I setup code to RenderDvdVideoVolume with the VMR9Only flag and I added code to FindFilterByName for the Video Mixing Renderer 9 from the filtergraph. I get the filter and it is not null. Then I want to configure the filter, so I get the IVMRFilterConfig9 interface by casting my filter to that interface as done in quite a few of the examples. By the way, this is being done on a machine with Windows Vista. Next, when I use the config interface to configure the VMR9 filter, I run into problems. If I try to set the rendering mode or the number of streams I get an exception that tells me "The operation could not be performed because the filter is in the wrong state." I have looked all over for solutions to this, but I have not had any luck. Below is a snippet of my code and the VMR9 filter is declared outside of this snippet as a private IBaseFilter. int hr; AMDvdRenderStatus status; object comobj = null; try { dvdGraph = (IDvdGraphBuilder)new DvdGraphBuilder(); //filter = (IBaseFilter)new VideoMixingRenderer9(); //hr = dvdGraph.RenderDvdVideoVolume( null, AMDvdGraphFlags.None, out status ); hr = dvdGraph.RenderDvdVideoVolume(null, AMDvdGraphFlags.VMR9Only, out status); DsError.ThrowExceptionForHR( hr ); hr = dvdGraph.GetDvdInterface( typeof( IDvdInfo2 ).GUID, out comobj ); DsError.ThrowExceptionForHR( hr ); dvdInfo = (IDvdInfo2) comobj; comobj = null; hr = dvdGraph.GetDvdInterface( typeof( IDvdControl2 ).GUID, out comobj ); DsError.ThrowExceptionForHR( hr ); dvdCtrl = (IDvdControl2) comobj; comobj = null; hr = dvdGraph.GetFiltergraph( out graphBuilder ); DsError.ThrowExceptionForHR( hr ); hr = graphBuilder.FindFilterByName("Video Mixing Renderer 9", out filter); DsError.ThrowExceptionForHR(hr); if (filter == null) { MessageBox.Show("Need to add the VMR9 Filter"); } IVMRFilterConfig9 filterConfig = (IVMRFilterConfig9)filter; //********** // This is where I run into the exception //********** //hr = filterConfig.SetRenderingMode(VMR9Mode.Renderless); hr = filterConfig.SetRenderingMode(VMR9Mode.Windowed); DsError.ThrowExceptionForHR(hr); hr = filterConfig.SetNumberOfStreams(1); DsError.ThrowExceptionForHR(hr); SetAl
This is a late comment, but the Microsoft documentation states that you can get the VMR9Config and VMR9AplhaBitmap interfaces by calling IDVDGraphBuilder:GetDVDInterface() IE: hr = dvdGraph.GetDvdInterface(typeof(IVMRFilterConfig9).GUID, out comobj); and hr = dvdGraph.GetDvdInterface(typeof(IVMRMixerBitmap9).GUID, out comobj); You do this before you call the RenderDVDAudioVideo and the graph understands that you want to use the VMR. Past that, you should be able to follow the VMR samples. I think that the only thing that you really need is to get the MixerBitmap interface and then you can send an Alpha bitmap from a mem dc anytime that you want. I could be incorrect on that. Myself, I am getting an hr = 1 on RenderDVDAudioVideo. Is strange, as I can manually build the graph I want. MB