MediaCapture VideoStabilization因0xC00D4A3E而失败

时间:2015-06-16 18:10:43

标签: c# windows-store-apps win-universal-app windows-10

我正在制作支持VideoStabilization effect的视频录制应用,但是当我开始录制时,我几乎立即通过MediaCapture.Failed事件收到以下内容:

  

由于未完成的请求,样本分配器当前为空。   (0xC00D4A3E)

只有当我使用效果中的推荐配置时才会发生这种情况。如果我不打电话SetUpVideoStabilizationRecommendationAsync,它可以正常工作。

以下是我如何设置它:

    private MediaEncodingProfile _encodingProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto);

    private async Task CreateVideoStabilizationEffectAsync()
    {
        var definition = new VideoStabilizationEffectDefinition();

        _videoStabilizationEffect = (VideoStabilizationEffect)await _mediaCapture.AddVideoEffectAsync(definition, MediaStreamType.VideoRecord);
        _videoStabilizationEffect.Enabled = true;

        await SetUpVideoStabilizationRecommendationAsync();
    }

    private async Task SetUpVideoStabilizationRecommendationAsync()
    {
        var properties = _mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoRecord) as VideoEncodingProperties;
        var recommendation = _videoStabilizationEffect.GetRecommendedStreamConfiguration(_mediaCapture.VideoDeviceController, properties);

        if (recommendation.InputProperties != null)
        {
            await _mediaCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.VideoRecord, recommendation.InputProperties);
        }

        if (recommendation.OutputProperties != null)
        {
            _encodingProfile.Video = recommendation.OutputProperties;
        }
    }

    private async Task StartRecordingAsync()
    {
        var videoFile = await KnownFolders.PicturesLibrary.CreateFileAsync("StableVideo.mp4", CreationCollisionOption.GenerateUniqueName);
        await _mediaCapture.StartRecordToStorageFileAsync(_encodingProfile, videoFile);
    }

1 个答案:

答案 0 :(得分:0)

调用您选择的desiredProperties(即“输出属性”)时,GetRecommendedStreamConfiguration方法的MediaEncodingProfile参数需要获取MediaCapture.StartRecordTo*才能看到你想要的VideoEncodingProperties是什么。

正在触发错误,因为正在传递来自VideoEncodingProperties的{​​{1}}(即“输入属性”)。如果您考虑一下,VideoDeviceController的实例已作为参数传递给方法,因此效果已经可以访问VideoDeviceController var中的信息。必须同时分开传递它们是没有多大意义的。相反,它需要的是有关另一个端点的信息。那有意义吗?至少这就是我尝试合理化的方式。

official SDK sample for VideoStabilization上的Microsoft github repo显示了如何正确执行此操作:

properties