MediaCapture Effect failed by "Not enough memory resources are available to complete this operation."

Ray

I am using MediaCapture(Windows.Media.Capture) class to add some effects to webcam input frames. For applying effects, I am working with Win2D library. After I clear and re-apply effects like below code few times, the exception is raised and the web cam doesn't work.

The MediaCapture's Failed event shows arguments like this :

MediaCaptureFailedEventArgs
Code : 2147942414
Message : "Not enough memory resources are available to complete this operation."

However, The performance counter in Task manager shows sufficient memory amount to use.

//Reset Effect Method
private async Task ApplyAllEffects()
{
  await ClearAllEffects();
  await ApplyRemoveGreenEffect();
}

//Clear All Effects Method
private async Task ClearAllEffects()
{
  //_previewMediaCapture is a MediaCapture object
  if (_previewMediaCapture == null) return;
  await _previewMediaCapture.ClearEffectsAsync(MediaStreamType.VideoPreview);
}

//Add Effect Method
private async Task ApplyRemoveGreenEffect()
{
  if (_previewMediaCapture == null) return;

  var properties = new PropertySet();
  properties[nameof(RemoveGreenMediaExtension.Value)] = (float)Preferences.RemoveGreen;

  var definition = new VideoEffectDefinition(typeof(RemoveGreenVideoEffect).FullName, properties);

  await _previewMediaCapture.AddVideoEffectAsync(definition, MediaStreamType.VideoPreview);
}

I checked the program and code of Win2d Sample offered by MS. It has same problem too. There's no way to avoid this problem?

Ray

I can guess why this things are happened.

Before I initialize the MediaCapture object and apply Win2D effects to it, I used MJPG codec for cam's by calling MediaCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(...) method.

It's supported one by my web cam(Logitech C920) for 30fps in 1080p. It caused GPU Memory leaks. When I use raw(YUV) codec or NV12 codec for input frames, GPU memory leak isn't happend.

I think, MJPG encoding process is added to cam's graphical pipe-line and by some reasons with it that pipe-line can't be released properly.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Not enough memory resources are available to complete this operation

Effect function failed to render on click of a button

MediaCapture and Window VisibilityChanged

UWP MediaCapture initialization fails

redux saga yield all cancel other effect when one failed

MediaCapture + CaptureElement lifecycle/navigation management

mediaCapture windows 8.1 winjs app

UWP MediaCapture Denied Access to Camera

Can't initialize mediaCapture UWP

Use UWP MediaCapture from WPF-application

"No capture devices are available" in mediaCapture.InitializeAsync

How does MediaCapture.StartPreviewToCustomSinkAsync method work?

MediaCapture class doesnt have AddVideoEffectAsync method

Console template application MediaCapture fails to record video

Locale variables have no effect in remote shell (perl: warning: Setting locale failed.)

My vs-code take me error - Failed to load jshint library. Install library does not give effect

MediaCapture: Photos have odd color letterboxing on Windows Phone

MediaCapture Windows 8 Desktop Application- Can't get it work

AudioDevice: recording sound using MediaCapture in WinRT/WP 8.1

Issue with aspect ratio / zoom level changing when using MediaCapture?

Camera stream using MediaCapture stops working after a while?

"InvalidOperationException: A method was called at an unexpected time" when calling MediaCapture.StartPreviewAsync

updateOnDuplicate not effect

Heartbeat effect

Effect of dircolors

Cannot open mp4's made from MediaCapture in C# UWP app

How to use existing camera app(not create one using MediaCapture) and take picture in windows phone 8.1(WinRT)?

How to catch UWP MediaCapture exception when capture device is used by another app?

WP8.1RT: Custom resolution image taken from mediacapture C#