VideoStabilizationEnabled在webtc Hololens 2不工作



我正在尝试在webbrtc lib中启用Hololens 2的视频稳定功能。我在https://github.com/webrtc-uwp/webrtc-uwp-sdk/tree/master

中的impl_webrtc_VideoCapturer.cpp中修改了以下代码
mrcVideoEffectDefinition.VideoStabilizationEnabled(true);
mrcVideoEffectDefinition.VideoStabilizationBufferLength(15);

在"ConvertToI420"功能如下:

const int conversionResult = libyuv::ConvertToI420(
videoFrame, videoFrameLength, buffer.get()->MutableDataY(),
buffer.get()->StrideY(), buffer.get()->MutableDataU(),
buffer.get()->StrideU(), buffer.get()->MutableDataV(),
buffer.get()->StrideV(), 0, 0,  // No Cropping
width, height, target_width, target_height, rotation_mode,
frameInfo.fourcc);

我发现当VideoStabilizationEnabled设置为true时,videoFrameLength不正确,如果width = 896, height = 504,那么对于converttoi420, videoFrameLength应该是677376 (896x504x3/2, yuv)功能正常工作

normal: videoFrameLength: 677376 (VideoStabilizationEnabled设置为false)
wrong: videoFrameLength: 497664 (VideoStabilizationEnabled设置为true)这是不正确的

任何想法?由于

我通过以下编辑修复了它,启用视频防抖动后分辨率发生了变化,需要更新相关变量

在impl_webrtc_VideoCaptureMediaSink.cpp,获得缓冲区的宽度和高度,并添加回调警报impl_webrtc_VideoCapturer.cpp

VideoCaptureStreamSink::SetCurrentMediaType(IMFMediaType *pMediaType)
{
.....
MFGetAttributeSize(pMediaType, MF_MT_FRAME_SIZE, &width, &height);
_callback->OnResolutionChanged(width, height);
}

在impl_webrtc_VideoCaptureMediaSink.h中添加新的接口功能

class ISinkCallback {
public:
.....
virtual void OnResolutionChanged(UINT32 width, UINT32 height) = 0;
};

在impl_webrtc_VideoCapturer.cpp中添加以下函数来更新分辨率

void CaptureDevice::OnResolutionChanged(UINT32 width, UINT32 height) 
{
OutputDebugString(L"OnResolutionChanged ");
frame_info_.width = width;
frame_info_.height = height;
}

最新更新