2015-06-16 2 views
0

Я работаю над приложением для записи видео, которое поддерживает VideoStabilization effect, но когда я начала записи, я получаю следующее через событие MediaCapture.Failed почти мгновенно:MediaCapture VideoStabilization терпит неудачу с 0xC00D4A3E

образца аллокатора в настоящее время пуст, из-за невыполненных запросов. (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); 
    } 

ответ

0

Параметр метода GetRecommendedStreamConfigurationdesiredProperties должен получить MediaEncodingProfile, который будет использоваться при вызове вашего выбора MediaCapture.StartRecordTo* (то есть «выходные свойства») чтобы увидеть, что вы хотите VideoEncodingProperties.

Ошибка запускается, потому что вместо этого передаются VideoEncodingProperties из VideoDeviceController (т. Е. «Свойства ввода»). Если вы думаете об этом, экземпляр VideoDeviceController уже передается как параметр для метода, поэтому эффект уже может получить доступ к информации в этом properties var; это не имело бы смысла передавать их отдельно в одно и то же время. Вместо этого ему нужна информация о другой конечной точке. Имеет ли это смысл? По крайней мере, я пытаюсь его рационализировать.

official SDK sample for VideoStabilization на Microsoft github repo показывает, как сделать это правильно:

/// <summary> 
    /// Configures the pipeline to use the optimal resolutions for VS based on the settings currently in use 
    /// </summary> 
    /// <returns></returns> 
    private async Task SetUpVideoStabilizationRecommendationAsync() 
    { 
     Debug.WriteLine("Setting up VS recommendation..."); 

     // Get the recommendation from the effect based on our current input and output configuration 
     var recommendation = _videoStabilizationEffect.GetRecommendedStreamConfiguration(_mediaCapture.VideoDeviceController, _encodingProfile.Video); 

     // Handle the recommendation for the input into the effect, which can contain a larger resolution than currently configured, so cropping is minimized 
     if (recommendation.InputProperties != null) 
     { 
      // Back up the current input properties from before VS was activated 
      _inputPropertiesBackup = _mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoRecord) as VideoEncodingProperties; 

      // Set the recommendation from the effect (a resolution higher than the current one to allow for cropping) on the input 
      await _mediaCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.VideoRecord, recommendation.InputProperties); 
      Debug.WriteLine("VS recommendation for the MediaStreamProperties (input) has been applied"); 
     } 

     // Handle the recommendations for the output from the effect 
     if (recommendation.OutputProperties != null) 
     { 
      // Back up the current output properties from before VS was activated 
      _outputPropertiesBackup = _encodingProfile.Video; 

      // Apply the recommended encoding profile for the output, which will result in a video with the same dimensions as configured 
      // before VideoStabilization was added if an appropriate padded capture resolution was available. Otherwise, it will be slightly 
      // smaller (due to cropping). This prevents upscaling back to the original size, which can result in a loss of quality 
      _encodingProfile.Video = recommendation.OutputProperties; 
      Debug.WriteLine("VS recommendation for the MediaEncodingProfile (output) has been applied"); 
     } 
    } 
Смежные вопросы