[問題] 自己加Filter在directshow中撥放影片
大家好 我是新手
這禮拜開始學directshow的運作 只有看了些網站的資料跟MSDN
我是用Visual Studio 2005
目標是希望能夠開mov格式的檔案
我從網路上找到了一個免費的QuickTime source filter
http://www.roguestream.com/quicktime_source_filter.html 這是官網
我下載了之後 開GraphEdit可以正常撥放mov影片
但是我想實作的時候 卻卡在無法取得輸出pin
也就無法把他丟給renderer撥放出來
我想請問是哪邊出了問題呢?
另外我還想問 如果我今天希望在別的電腦跑的時候
即使沒有裝這個Filter 也可以正常撥放
那我應該怎麼做呢?
非常感謝大家
======以下是我的程式碼======
if (dlg.DoModal()==IDOK)
{
CString m_sourceFile = dlg.GetPathName();
IGraphBuilder *pGraph = NULL;
IBaseFilter *pAddSource = NULL;
IMediaControl *pControl = NULL;
IMediaEvent *pEvent = NULL;
IPin *pVideoPinOut = NULL;
IPin *pAudioPinOut = NULL;
//Initialize the COM libary
HRESULT hr = CoInitialize(NULL);
if (FAILED(hr))
{
MessageBoxA(NULL, "Could not initialize COM library", "", NULL);
return;
}
//Create the Filter Graph Manager
hr=CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&pGraph);
if (FAILED(hr))
{
MessageBoxA(NULL, "Could not create the Filter Graph Manager.", "",
NULL);
return;
}
//Add an existing source filter
hr = pGraph->AddSourceFilter(m_sourceFile, L"Rogue Stream QuickTime Source
Filter", &pAddSource);
if(SUCCEEDED(hr))
{
//Try to get the output pin from the previous filter
hr = pAddSource->FindPin(L"Video", &pVideoPinOut);
if(FAILED(hr)) //程式會卡在這無法完成動作
{
MessageBoxA(NULL, "Could not find the video pin.", "", NULL);
return;
}
hr = pAddSource->FindPin(L"Audio", &pAudioPinOut);
if(FAILED(hr))
{
MessageBoxA(NULL, "Could not find the audio pin.", "", NULL);
return;
}
//Get the interface of media control and media event
hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
//Directly render the data from the output pin
hr = pGraph->Render(pVideoPinOut);
if (SUCCEEDED(hr))
{
hr = pControl->Run();
if (SUCCEEDED(hr))
{
//Wait until the media is complete
long evCode;
pEvent->WaitForCompletion(INFINITE, &evCode);
}
}
}
//Release all the resources and COM libary
pControl->Release();
pEvent->Release();
pGraph->Release();
CoUninitialize();
return;
}
--
████████ ████████ █ █
◥████████◤ █ █
◥◣ ◢◤ █ █
◥◣ ◢◤ █ █
◥◣◢◤ █ █
◥◤http://www.wretch.cc/album/MysterySW
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.166.102.57
※ 編輯: MysterySW 來自: 218.166.102.57 (06/01 03:17)
→
06/01 10:03, , 1F
06/01 10:03, 1F
→
06/01 10:05, , 2F
06/01 10:05, 2F
→
06/01 10:05, , 3F
06/01 10:05, 3F
→
06/01 21:08, , 4F
06/01 21:08, 4F
→
06/01 21:10, , 5F
06/01 21:10, 5F