I am having problems writing a good C++/DirectX9/DirectShow video player.
I have tried using the DirectShow samples and modifying them. I've tried VMR9 and TextureRenderer.
In all my attempts the video playback is choppy and jerky. In one case I got it nearly smooth, but the audio was out of sync!
Windows Media Player always manages to play back the files smoothly. How can I harness that magic?
Or is there something I should have done in my app? Setting up threading or similar?
I am using MSVC2008, Win7, trying to play back AVI and WMV files.
Thanks
Si
EDIT
bool VMR::RenderVideo(LPSTR fileName)
{
if(!fileName && file == "")
return false;
file = fileName;
CloseGraph();
SmartPtr<IVMRFilterConfig9> pFilterConfig = NULL;
if(FAILED(CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**)&pGraph)))
return false;
if(FAILED(CoCreateInstance(CLSID_VideoMixingRenderer9, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pVMR)))
return false;
if(FAILED(pVMR->QueryInterface(IID_IVMRFilterConfig9, reinterpret_cast<void**>(&pFilterConfig))))
return false;
//if(FAILED(pFilterConfig->SetNumberOfStreams(1)))
// return false;
if(FAILED(pFilterConfig->SetRenderingMode( VMR9Mode_Renderless )))
return false;
if(FAILED(SetupAllocPresenter()))
return false;
if(FAILED(pGraph->AddFilter(pVMR, L"Video Mixing Renderer 9")))
return false;
if(FAILED(pGraph->QueryInterface(IID_IMediaControl, reinterpret_cast<void**>(&pControl))))
return false;
if(FAILED(pGraph->QueryInterface(IID_IMediaSeeking, reinterpret_cast<void**>(&pSeek))))
return false;
WCHAR wcTemp[256] = L"";
::MultiByteToWideChar(CP_UTF8, 0, file.c_str(), -1, wcTemp, 256);
if(FAILED(pGraph->RenderFile( wcTemp, NULL )))
return false;
return true;
}