Media Foundation使用PROPVARIANT结构设置视频捕获帧速率 [英] Media Foundation set video capture frame rate using PROPVARIANT structure

查看:281
本文介绍了Media Foundation使用PROPVARIANT结构设置视频捕获帧速率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写一个媒体基础应用程序,我需要为视频设备设置捕获帧速率。我写的函数是:

I'm writing a media foundation application where I need to set the capture frame rate for a video device. The function I'm writing is something like:

bool SetRequestedFrameRate(const size_t requestedFramesPerSecond);

其中,我传递一个用户定义的整数作为帧速率参数。我按照上的代码段https://msdn.microsoft.com/en-us/library/windows/desktop/ff485859(v=vs.85).aspx

where I pass a user-defined integer as the frame rate parameter. I'm following the code snippet on https://msdn.microsoft.com/en-us/library/windows/desktop/ff485859(v=vs.85).aspx :

PROPVARIANT var;
if (SUCCEEDED(pType->GetItem(MF_MT_FRAME_RATE_RANGE_MAX, &var)))
{
    hr = pType->SetItem(MF_MT_FRAME_RATE, var);

    PropVariantClear(&var);

    if (FAILED(hr))
    {
        goto done;
    }

    hr = pHandler->SetCurrentMediaType(pType);
}



此外,它使用PROVARIANT结构来保存帧速率数据。但是如何从我的const size_t requestedFramesPerSecond参数构造一个PROVARIANT结构?如果我已经有一个PROVARIANT保存帧速率,如何检索实际帧速率整数从它?另外,COM是否提供了一种比较代表帧速率的两个PROVARIANT结构的方法?

Apparantly it uses the PROVARIANT structure to hold frame rate data. But how do I construct a PROVARIANT structure from my "const size_t requestedFramesPerSecond" parameter? If I already have a PROVARIANT that holds the frame rate, how do I retrieve the actual frame rate integer from it ? Also, does COM provide a way to compare two PROVARIANT structures that represent frame rate ?

请帮助,谢谢!

推荐答案

罗马指出,您可以避免处理 PROPVARIANT 结构,通过使用效用函数访问 IMFAttributes store。不过,
as#7指出了您引用的页面

As Roman pointed out, you can avoid dealing with the PROPVARIANT structure, by using the utility functions to access the IMFAttributes store. However, as #7 points out on the page you referenced:



  1. 查询媒体类型为MF_MT_FRAME_RATE_RANGE_MAX和MF_MT_FRAME_RATE_RANGE_MIN属性。此值提供了
    支持的帧速率的范围。该设备可能支持此范围内的其他帧速率


枚举本地媒体类型的捕获设备,只需选择(选择一个)并重新使用媒体类型设置当前媒体类型。否则,您将失败的呼叫与捕获设备的功能不匹配的沮丧。我稍微讨论帧速率,并显示如何枚举本地媒体类型这里。祝你好运。

Enumerate the native media types of the capture device, and simply select (choose one) and reuse the media type to set the current media type. Otherwise you will be frustrated with failed calls which do not match the capabilities of the capture device. I discuss frame rates a bit and show how to enumerate the native media type here. Good luck.

这篇关于Media Foundation使用PROPVARIANT结构设置视频捕获帧速率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆