C++/VB - MPEG-4/VMR9 Graph RenderFile failed only in my application

Asked By Erakis
04-Feb-10 06:13 PM
Hi,

I open a MPEG-4 file using GraphEdit.

The filter chosen by the graph to render (vid??o and sound) on screen are :

--------------------------------------------------------------------
MPEG-4File --> ffdshow video decoder --> Video Renderer
--> ffdshow audio decoder --> AC3Filter --> DirectSoundDevice
--------------------------------------------------------------------

But when I am loading the same file in my application using the RenderFile
function of IGrahBuilder, i get the following error : E_NOINTERFACE

Here is the way I am loading the graph
--------------------------------------------------------------------
// Result of function calls
HRESULT hr;

// Create GraphBuilder
FAIL_RET( g_GraphBuilder.CoCreateInstance(CLSID_FilterGraph) );

// Create VMR9 interface
FAIL_RET( g_Filter.CoCreateInstance(CLSID_VideoMixingRenderer9, NULL,
CLSCTX_INPROC_SERVER) );

// Create VMR9 configuration interface
CComPtr<IVMRFilterConfig9> filterConfig;
FAIL_RET( g_Filter->QueryInterface(IID_IVMRFilterConfig9,
reinterpret_cast<void**>(&filterConfig)) );

// Set VMR9 rendering mode to Renderless because we have an
// allocator that will handle the drawing
FAIL_RET( filterConfig->SetRenderingMode( VMR9Mode_Renderless ) );

// Set number of streams to 1 because we will not mix any other video
FAIL_RET( filterConfig->SetNumberOfStreams(1) );

// Create the Alllocator presenter that will output media on the main window
FAIL_RET( SetAllocatorPresenter( g_Filter, window ) );

// Add VMR9 filter to Graph
FAIL_RET( g_GraphBuilder->AddFilter(g_Filter, L"Video Mixing Renderer 9") );

// Get MediaControl interface (Uses for playing, pausing, and stopping the
graph)
FAIL_RET( g_GraphBuilder->QueryInterface(IID_IMediaControl,
reinterpret_cast<void**>(&g_MediaControl)) );

// Get MediaSeeking interface (Uses for seeking through the graph)
FAIL_RET( g_GraphBuilder->QueryInterface(IID_IMediaSeeking,
reinterpret_cast<void**>(&g_MediaSeeking)) );

// Get MediaEvent interface (To know when the media has been completly read)
FAIL_RET( g_GraphBuilder->QueryInterface(IID_IMediaEvent,
reinterpret_cast<void**>(&g_MediaEvent)) );

// Ask to graph to render the file
// (Intelligent connect will choose the righ filters (codecs) to output the
media)
FAIL_RET( g_GraphBuilder->RenderFile(g_szMainMovieFilePath, NULL ));
--------------------------------------------------------------------

I thought if it worked in GraphEdit, the method RenderFile was guaranteed to
work on my application and that it gave the same grah at the end ?

If the only solution is to build the graph manually, is it someone could
help me start or give me a help on this ?
GraphBuilder.CoCreateInstance
(1)
Filter.CoCreateInstance
(1)
IVMRFilterConfig9
(1)
SzMainMovieFilePath
(1)
SetNumberOfStreams
(1)
SetAllocatorPresenter
(1)
VideoMixingRenderer9
(1)
DirectSoundDevice
(1)
  Alessandro Angeli replied to Erakis
04-Feb-10 06:54 PM
From: "Erakis"


Assuming that none of the filters are keyed so that they
only work in selected applications (some are) and that the
system filter registry is the same, RenderFile() will
produce the same results in GE or any another application.

However, you are not just calling RenderFile() like GE does
but you are doing a bunch of stuff before that. Bunch of
stuff that is probably failing because you did not add the
filter to the graph before using it. You should have stepped
through the code to see what call returns E_NOINTERFACE.


--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
  The March Hare [MVP] replied to Alessandro Angeli
05-Feb-10 12:14 AM
Note that the OP multi-posted here:

http://social.msdn.microsoft.com/Forums/en-US/windowsdirectshowdevelopment/thread/fadf32cc-b5a2-4d9c-ba30-2f4862772a5c

I have locked that thread.

--
Please read this before replying:
1. Dshow & posting help:  http://tmhare.mvps.org/help.htm
2. Trim & respond inline (please do not top post or snip everything)
3. Benefit others:  follow up if you are helped or you found a solution
  Erakis replied to The March Hare [MVP]
05-Feb-10 12:51 PM
I am sorry I did not know which of the 2 forums was the most active so I
posted both. I acknowledge that I should have read the rules before.

Obviously, you lock my Social.MSDN thread and it was the much more
convenient, Especially for code tag.
  Erakis replied to Alessandro Angeli
05-Feb-10 12:56 PM
Thanks for your help.

I will move the code that query interface (IMediaControl, IMediaSeeking,
etc...) after the RenderFile function call.

Also, do I have to set my Allocator/Presentor after the RenderFile calls or
it is correct to do it before ?

Best regards
  The March Hare [MVP] replied to Erakis
05-Feb-10 01:18 PM
An easy way to tell which is more active is to count the posts in the last
week.


I have unlocked that thread because of your acknowledgement.  Please be
more considerate in the future and if you have to multi-post because you
do not get an answer in a day or so, add a comment to both places that you
have multi-posted and where.  Thank you.

--
Please read this before replying:
1. Dshow & posting help:  http://tmhare.mvps.org/help.htm
2. Trim & respond inline (please do not top post or snip everything)
3. Benefit others:  follow up if you are helped or you found a solution
  Alessandro Angeli replied to Erakis
06-Feb-10 04:37 AM
From: "Erakis"


You need to do it before the pins are connected, so before
RenderFile() in your case.

--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm
Create New Account