Cant render a .avi file
- by Manish
Hi,
This is my 3rd post regarding this issue of cropping a file into smaller (same format files) .Please some one help me with this.Here is my code :
CoInitialize(NULL);
//Create the FGM
CoCreateInstance(CLSID_FilterGraph,NULL,CLSCTX_INPROC_SERVER,IID_IGraphBuilder,(void**)(&pGraphBuilder));
//Query the Interfaces
pGraphBuilder->QueryInterface(IID_IMediaControl,(void**)&pMediaControl);
pGraphBuilder->QueryInterface(IID_IMediaEvent,(void**)&pMediaEvent);
pGraphBuilder->QueryInterface(IID_IMediaPosition,(void**)&pMediaPosition);
//Adding a Filewriter before calling the renderfile
IBaseFilter *pWriter=NULL;
IFileSinkFilter *pSink=NULL;
CoCreateInstance(CLSID_FileWriter,NULL,CLSCTX_INPROC_SERVER,IID_PPV_ARGS(&pWriter));
pWriter->QueryInterface(IID_IFileSinkFilter,(void**)&pSink);
pSink->SetFileName(OUTFILE,NULL);
//Create a source filter
IBaseFilter* pSource=NULL;
HRESULT hr11=pGraphBuilder->AddSourceFilter(FILENAME,L"Source",&pSource);
//Create a AVI mux
IBaseFilter *pAVImux;
CoCreateInstance(CLSID_AviDest,NULL,CLSCTX_INPROC_SERVER,IID_PPV_ARGS(&pAVImux));
pGraphBuilder->AddFilter(pAVImux,L"AVI Mux");
pGraphBuilder->AddFilter(pWriter,L"File Writer");
//Connect Source and Mux
IEnumPins* pEnum1=NULL;
IPin* pPin1=NULL;
IEnumPins *pEnum2=NULL;
IPin *pPin2=NULL;
pSource->EnumPins(&pEnum1);
pEnum1->Next(1,&pPin1,NULL);
HRESULT hr1=ConnectFilters(pGraphBuilder,pPin1,pAVImux);
//Mux to Writer
HRESULT hr4=ConnectFilters(pGraphBuilder,pAVImux,pWriter);
//Render the input file
HRESULT hr3=pGraphBuilder->RenderFile(FILENAME,NULL);
//Set Display times
pMediaPosition->put_CurrentPosition(0);
pMediaPosition->put_StopTime(2);
//Run the graph
HRESULT hr=pMediaControl->Run();
On running no video is shown. All the hresults return S_OK .A .avi file( larger than original is created) and I cannot play that file.