无法在WMV MFT编码器

时间:2016-11-23 04:17:08

标签: ms-media-foundation

我在Win10 64bit上使用Windows Media Foundation WMV编码器。虽然它可用于正确编码,但我未能设置VBR质量。

以下是示例代码

const PROPERTYKEY MFPKEY_VBRENABLED = { { 0xe48d9459, 0x6abe, 0x4eb5, { 0x92, 0x11, 0x60, 0x8, 0xc, 0x1a, 0xb9, 0x84 } }, 0x14 };      
const PROPERTYKEY MFPKEY_DESIRED_VBRQUALITY = { { 0x6dbdf03b, 0xb05c, 0x4a03, { 0x8e, 0xc1, 0xbb, 0xe6, 0x3d, 0xb1, 0x0c, 0xb4 } }, 0x00 + 25 };          

CLSID* pCLSIDs = NULL;   // Pointer to an array of CLISDs.   UINT32 nCount = 0;      
MFT_REGISTER_TYPE_INFO encoderInfo;      encoderInfo.guidMajorType = MFMediaType_Video;  
encoderInfo.guidSubtype = MFVideoFormat_WMV3;      
HRESULT hr = fpMFTEnum(MFT_CATEGORY_VIDEO_ENCODER, 0, NULL, &encoderInfo, NULL, &pCLSIDs, &nCount);      
if (FAILED(hr) || (nCount == 0)) {}            ciEncoder.CreateObject(pCLSIDs[0], IID_IMFTransform);      
if (ciEncoder.IsInvalid()) {}          

LComInterface<IPropertyStore> ciPropertyStore; // WMV Encoder codec setting interface      
hr = ciEncoder->QueryInterface(IID_IPropertyStore, (void**)ciPropertyStore.GetAssignablePtrRef()); 

if (SUCCEEDED(hr)) {         
    PROPVARIANT  propVal;         
    propVal.vt = VT_BOOL;         
    propVal.boolVal = VARIANT_TRUE;                  
    hr = ciPropertyStore->SetValue(MFPKEY_VBRENABLED, propVal);                 
    propVal.vt = VT_UI4;         
    propVal.ulVal = 90;         
    hr = ciPropertyStore->SetValue(MFPKEY_DESIRED_VBRQUALITY, propVal);

当ciPropertyStore-&gt; SetValue(MFPKEY_VBRENABLED,propVal)返回S_OK时, ciPropertyStore-&gt; SetValue(MFPKEY_DESIRED_VBRQUALITY,propVal)失败,hr =“属性ID与转换支持的任何属性都不匹配”

由于

1 个答案:

答案 0 :(得分:0)

我刚刚找到根本原因:似乎我应该使用MFPKEY_VBRQUALITY而不是MFPKEY_DESIRED_VBRQUALITY

https://msdn.microsoft.com/en-us/library/windows/desktop/dd206749%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396中的

似乎MFPKEY_VBRQUALITY用于视频,MFPKEY_DESIRED_VBRQUALITY用于音频?