【发布时间】:2014-02-13 03:47:16
【问题描述】:
我正在尝试从 PS3 的采集卡 (720p) 基本上渲染预览到增强的视频渲染。
理想情况下,我想要这样的东西:
我曾经这样做过:
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 并试图把我的代码,但它不会呈现。
这是设置源代码的sn-p。假设setResolution 将设置AM_MEDIA_TYPE 格式,而getVideoSourceByKeyword 将获得圆刚采集卡设备。
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 采集卡的“Capture”引脚名称)。它表示已成功附加到 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 预览采集卡。我发现没有全面的教程或源代码可以做到这一点。如果您需要更多信息,我可以添加更多信息。
提前致谢。
【问题讨论】:
标签: c++ windows directshow video-capture renderer