我想基本渲染從捕獲卡(720p)預覽從PS3到增強視頻渲染。捕獲預覽到增強視頻渲染
理想情況下,我想是這樣的:
我曾經這樣做:
hr = m_pCapture->RenderStream (&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, m_pSrcFilter, NULL, NULL);
但我覺得這只是呈現一個古老的默認渲染器,這是不足以將圖像拉伸至1080p(圖像變得像素化)。 [http://msdn.microsoft.com/en-us/library/aa930715.aspx]
我想使用增強視頻渲染器作爲接收器,但我不知道如何去做。我在這裏查看了教程:http://msdn.microsoft.com/en-us/library/windows/desktop/ff625867%28v=vs.85%29.aspx 並試圖放入我的代碼,但它不會呈現。
以下是設置源代碼的代碼片段。假設setResolution
將設置AM_MEDIA_TYPE格式,並且getVideoSourceByKeyword
將獲得AVermedia採集卡設備。
HRESULT DShowPlayer::SetPreviewDevice(PCWSTR keyname)
{
IBaseFilter *pSource = NULL;
// Create a new filter graph. (This also closes the old one, if any.)
HRESULT hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL,
CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_pCapture));
if (FAILED(hr))
{
goto done;
}
hr = InitializeGraph();
if (FAILED(hr))
{
goto done;
}
// Add the source filter to the graph.
hr = getVideoSourceByKeyword(keyname, &pSource);
if (FAILED(hr))
{
goto done;
}
hr = m_pGraph->AddFilter(pSource, L"Source filter");
if (FAILED(hr))
{
goto done;
}
setResolution(pSource, 1280, 720);
// Try to render the streams.
hr = RenderStreams(pSource);
if (FAILED(hr))
{
goto done;
}
hr = m_pControl->Run();
done:
if (FAILED(hr))
{
TearDownGraph();
}
SafeRelease(&pSource);
return hr;
}
當代碼運行RenderStreams,這是代碼(從http://msdn.microsoft.com/en-us/library/windows/desktop/ff625878%28v=vs.85%29.aspx):
// Enumerate the pins on the source filter.
hr = pSource->EnumPins(&pEnum);
if (FAILED(hr))
{
goto done;
}
// Loop through all the pins
IPin *pPin;
while (S_OK == pEnum->Next(1, &pPin, NULL))
{
PIN_INFO pInfo;
pPin->QueryPinInfo(&pInfo);
// Try to render this pin.
// It's OK if we fail some pins, if at least one pin renders.
HRESULT hr2 = pGraph2->RenderEx(pPin, AM_RENDEREX_RENDERTOEXISTINGRENDERERS, NULL);
pPin->Release();
if (SUCCEEDED(hr2))
{
bRenderedAnyPin = TRUE;
}
}
在Visual Studio中我的腳調試獲取源名稱(「捕獲」的引腳名AVermedia採集卡)。它說,它是成功的附着到渲染在RenderEx
然而在
hr = m_pControl->Run();
它失敗,並且有錯誤設備未連接。
我也試圖直接將EVR渲染器,並試圖呈現流:
IBaseFilter* render;
m_pVideo->getRender(&render);
m_pGraph->AddFilter(render, L"EVR Filter");
hr = m_pCapture->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pSource, NULL, render);
if (FAILED(hr))
{
goto done;
}
但它失敗和VFW_E_NOT_IN_GRAPH說。
我在問什麼:我在學習Directshow方面還很新,我希望能夠使用EVR預覽捕獲卡。我找不到完整的教程或源代碼來執行此操作。如果您需要更多信息,我可以添加更多信息。
在此先感謝。
謝謝,我想通了。也許我會添加上面的代碼 – user654628