How to apply effects to captured video (HTML)

[This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation]

Use the MediaCapture.AddEffectAsync method to apply effects to captured video.

Effects can be a built-in effect, such as the VideoStabilization effect which is supported on Windows or the SlowMotionEffectDefinition which is supported on Windows Phone, or custom effects which are Media Foundation Transforms (MFTs). For information about how to create and use MFTs, see Media Foundation Transforms and the Media Extension Sample.

Objective: This tutorial describes how to apply effects to captured video.

Prerequisites

This topic assumes that you can create a basic Windows Runtime app using JavaScript. For help creating your first app, see Create your first Windows Store app using JavaScript.

Instructions

To add an effect to captured video, call the AddEffectAsync method. This method takes the following parameters:

  • MediaStreamType - One of the values of the MediaStreamType enumeration that specifies whether the stream is for video recording, video preview, audio, or photo.
  • effectActivationID - The class identifier of the activatable runtime class that implements the effect. This parameter is added to the chain of effects that get added to the source stream coming out of the device source. The runtime class must implement the IMediaExtension interface.
  • effectSettings - An IPropertySet that contains additional configuration parameters for the effect. If no additional configuration is needed for the effect, then this parameter should be null.

The application can call this method multiple times to add several effects.

This example calls AddEffectAsync to add the VideoStabilization effect to a MediaCapture object.

    // captureMgr is a MediaCapture object defined elsewhere
    capturMgr.addEffectAsync(
        Windows.Media.Capture.MediaStreamType.videoRecord,
        "Windows.Media.VideoEffects.VideoStabilization",
        null);

Note  This example uses the VideoStabilizationEffect, which is not supported for Windows Phone Store apps, but AddEffectAsync can be used to add other, supported effects.

Summary

For another example of how to apply an effect to video, see the How to add video stabilization topic and the Media Capture Sample.

Media Capture Sample

Media Extension Sample