【问题标题】:Capture preview to Enhanced video renderer捕获预览到增强型视频渲染器
【发布时间】: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


    【解决方案1】:

    EVR 可以像 VMR-7/9 一样以编程方式使用。唯一的区别是 EVR 需要“无窗口”模式,而早期的渲染器也支持“窗口”模式,您需要对渲染器进行最少的初始化。

    我想你可以在 GraphEdit 中看到 EVR 上的视频吗?您应该可以这样做,只需使用 Preview pin,而不是 Capture。或者,通过 Smart Tee 过滤器及其预览输出连接 Capture。

    错误代码表明您没有正确构建图表。特别是,VFW_E_NOT_IN_GRAPH 表示您的过滤器不在图中,因此参数无效。您不需要使用getRender,只需使用CoCreateInstance EVR 即可。一开始您会遇到一个错误,您有兴趣将所有内容暂停并查看您目前拥有的过滤器图拓扑。

    Windows SDK 示例包含 \Samples\multimedia\directshow\vmr9\windowless,它显示 VMR-9 处于无窗口模式,这应该是从 VMR-9 切换到 EVR 的最近起点。

    【讨论】:

    • 谢谢,我想通了。也许我会在上面添加代码
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-07
    • 2014-11-06
    • 2016-01-16
    • 2020-04-06
    • 1970-01-01
    相关资源
    最近更新 更多