Media​Capture Media​Capture Media​Capture Class

Definition

Provides functionality for capturing photos, audio, and videos from a capture device, such as a webcam.

public : sealed class MediaCapture : IClosable, IMediaCapture, IMediaCapture2, IMediaCapture3, IMediaCapture4, IMediaCapture5, IMediaCapture6, IMediaCaptureVideoPreviewpublic sealed class MediaCapture : IDisposable, IMediaCapture, IMediaCapture2, IMediaCapture3, IMediaCapture4, IMediaCapture5, IMediaCapture6, IMediaCaptureVideoPreviewPublic NotInheritable Class MediaCapture Implements IDisposable, IMediaCapture, IMediaCapture2, IMediaCapture3, IMediaCapture4, IMediaCapture5, IMediaCapture6, IMediaCaptureVideoPreview
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

Examples

The following code sample shows how to create and initialize a MediaCapture object.

// Create and initialze the MediaCapture object.
public async void InitMediaCapture()
{
    _mediaCapture = null;
    _mediaCapture = new Windows.Media.Capture.MediaCapture();

    // Set the MediaCapture to a variable in App.xaml.cs to handle suspension.
    (App.Current as App).MediaCapture = _mediaCapture;

    await _mediaCapture.InitializeAsync(_captureInitSettings);

    CreateProfile();
}
// Create and initialze the MediaCapture object.
function initMediaCapture() {
    oMediaCapture = null;
    oMediaCapture = new Windows.Media.Capture.MediaCapture();
    oMediaCapture.initializeAsync(captureInitSettings).then (function (result) {
       createProfile();
    }, errorHandler);    
}
<StackPanel Orientation="Horizontal">
    <CaptureElement x:Name="capturePreview" Width="320" Height="240" />
    <Image x:Name="imagePreview" Stretch="None" Width="320" Height="240" />
</StackPanel>

<StackPanel Orientation="Horizontal">
    <Button Click="InitCamera_Click" Content="Initialize Camera" />
    <Button Click="StartCapturePreview_Click" Content="Start Capture Preview" />
    <Button Click="CapturePhoto_Click" Content="Capture Photo"/>
    <Button Click="StopCapturePreview_Click" Content="Stop Capture Preview" />
</StackPanel>
Windows.Media.Capture.MediaCapture captureManager;

async private void InitCamera_Click(object sender, RoutedEventArgs e)
{
    captureManager = new MediaCapture();
    await captureManager.InitializeAsync();
}

async private void StartCapturePreview_Click(object sender, RoutedEventArgs e)
{
    capturePreview.Source = captureManager;
    await captureManager.StartPreviewAsync();
}

async private void StopCapturePreview_Click(object sender, RoutedEventArgs e)
{
    await captureManager.StopPreviewAsync();
}

async private void CapturePhoto_Click(object sender, RoutedEventArgs e)
{
    ImageEncodingProperties imgFormat = ImageEncodingProperties.CreateJpeg();

    // create storage file in local app storage
    StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync(
        "TestPhoto.jpg",
        CreationCollisionOption.GenerateUniqueName);

    // take photo
    await captureManager.CapturePhotoToStorageFileAsync(imgFormat, file);

    // Get photo as a BitmapImage
    BitmapImage bmpImage = new BitmapImage(new Uri(file.Path));

    // imagePreview is a <Image> object defined in XAML
    imagePreview.Source = bmpImage;
}

Remarks

The MediaCapture class is used to capture audio, video, and images from a camera. For how-to guidance for displaying the camera preview, see Display the camera preview. To quickly get started capturing photos, audio, or video, see Basic photo, video, and audio capture with MediaCapture.

The Camera page is the main hub for how-to guidance for using MediaCapture in your app. In addition to the basic camera tasks, this page links to how-to articles for advanced scenarios including:

  • Using the hardware camera button on devices that have one
  • Handling device and screen orientation
  • Using camera profiles to determine device capabilities
  • Setting the format, resolution, and frame rate of captured video
  • Using AdvancedPhotoCapture to capture HDR or low-light photos
  • Using the VideoDeviceController to access manual camera controls like exposure, white balance, auto-focus, and flash
  • Using effects while capturing video
  • Capturing photo sequences
  • Using MediaFrameReader to get a stream of frames from one or more cameras, including rgb, infrared, and depth cameras
  • Getting a frame from the preview stream The Camera article also links to all of the UWP SDK samples for camera, such as the Camera starter kit sample.

The InitializeAsync method, which initializes the MediaCapture object, must be called before you can start previewing or capturing from the device. In C# or C++ apps, the first use of the MediaCapture object to call InitializeAsync should be on the STA thread. Calls from an MTA thread may result in undefined behavior. InitializeAsync will launch a consent prompt to get the user's permission for the app to access the microphone or camera. InitializeAsync should be called from the main UI thread of your app. Apps must handle app suspension or termination by properly cleaning up media capture resources. For information on shutting down the MediaCapture object properly, see Basic photo, video, and audio capture with MediaCapture.

On Windows, music and media capture apps should monitor the SystemMediaTransportControls.SoundLevel to determine whether the audio streams on the app have been Muted. For apps using the MediaCapture object, capture will be automatically stopped when the capture streams of the app are muted. Capture is not re-started automatically when the audio streams are unmuted, so the SoundLevel changed notification can be used to restart capture. Use the SystemMediaTransportControls.PropertyChanged event to determine when the SoundLevel property changes.

For Windows Phone Store app, music and media apps should clean up the MediaCapture object and associated resources in the Suspending event handler and recreate them in the Resuming event handler.

In Windows 8.1 audio only apps, if the MediaCategory setting is Other, then high latency mode is used. For low latency, set the MediaCategory setting to Communications.

Adding an in-place editing Media Foundation Transform effect into the capture preview will have no effect on the stream.

Windows 8Windows Store app that have declared both the webcam and microphone capabilities will not function in Windows 8.1 if the user has not enabled both the webcam and microphone privacy settings.

MediaCapture only supports one pass CBR encoding.

Notes on JPEG: JPEG types are passthrough only. To capture an image, the image encoding profile can be set to Auto or you need to specify an encoding profile that matches the native type. To add an effect, you need to switch to an uncompressed video native media type, such as NV12 or RGB32.

Notes on H.264: If the native type is H.264, you can record using a video media type with type identical to the native type. You cannot add an effect to an H.264 native type stream. To capture video, the image encoding profile can be set to Auto or you need to specify an encoding profile that matches the native type.

Note

: This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX) and Using Windows Runtime objects in a multithreaded environment (.NET).

Constructors

MediaCapture() MediaCapture() MediaCapture()

Creates a new instance of the MediaCapture object.

public : MediaCapture()public MediaCapture()Public Sub New()
Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

Remarks

You must call InitializeAsync before using the MediaCapture object.

Properties

AudioDeviceController AudioDeviceController AudioDeviceController

Gets an object that controls settings for the microphone.

public : AudioDeviceController AudioDeviceController { get; }public AudioDeviceController AudioDeviceController { get; }Public ReadOnly Property AudioDeviceController As AudioDeviceController
Value
AudioDeviceController AudioDeviceController AudioDeviceController

An AudioDeviceController object that controls settings for the microphone.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

CameraStreamState CameraStreamState CameraStreamState

Gets the current stream state of the camera stream.

public : CameraStreamState CameraStreamState { get; }public CameraStreamState CameraStreamState { get; }Public ReadOnly Property CameraStreamState As CameraStreamState
Value
CameraStreamState CameraStreamState CameraStreamState

The current stream state of the camera stream.

Attributes

Remarks

The state of the camera stream will change when recording is paused or resumed, when the system drops frames for privacy reasons, or when the camera stream is lost. To be notified when the camera stream state changes, handle the CameraStreamStateChanged event.

See Also

FrameSources FrameSources FrameSources

Gets a read-only dictionary of MediaFrameSource objects that can be used simultaneously to acquire media frames.

public : IMapView<string, MediaFrameSource> FrameSources { get; }public IReadOnlyDictionary<string, MediaFrameSource> FrameSources { get; }Public ReadOnly Property FrameSources As IReadOnlyDictionary<string, MediaFrameSource>
Value
IMapView<PlatForm::String, MediaFrameSource> IReadOnlyDictionary<string, MediaFrameSource> IReadOnlyDictionary<string, MediaFrameSource>

A read-only dictionary of MediaFrameSource objects that can be used simultaneously to acquire media frames.

Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)
Capabilities
microphone webcam

Remarks

Initialize a MediaCapture object to use media frame sources by setting the SourceGroup property of the MediaCaptureInitializationSettings object to a MediaFrameSourceGroup returned by FindAllAsync and then calling MediaCapture.InitializeAsync. The key for each entry in the dictionary is the Id property of the MediaFrameSourceInfo associated with each frame source in the group.

For more information on using frame sources, see Process media frames with MediaFrameReader.

MediaCaptureSettings MediaCaptureSettings MediaCaptureSettings

Gets the configuration settings for the MediaCapture object.

public : MediaCaptureSettings MediaCaptureSettings { get; }public MediaCaptureSettings MediaCaptureSettings { get; }Public ReadOnly Property MediaCaptureSettings As MediaCaptureSettings
Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

ThermalStatus ThermalStatus ThermalStatus

Gets a value that indicates the current thermal status of the capture device.

public : MediaCaptureThermalStatus ThermalStatus { get; }public MediaCaptureThermalStatus ThermalStatus { get; }Public ReadOnly Property ThermalStatus As MediaCaptureThermalStatus
Value
MediaCaptureThermalStatus MediaCaptureThermalStatus MediaCaptureThermalStatus

A value that indicates the current thermal status of the capture device.

Attributes

Remarks

Media capture scenarios that are extremely processor-intensive, such as high-resolution, high-frame rate, and real-time image processing can cause the capture hardware to overheat. On devices where the camera driver supports reporting of thermal status, you can check the ThermalStatus property to get the current thermal status of the capture device. You can also subscribe to the ThermalStatusChanged event to receive a notification when the thermal status changes. If the thermal status is Overheated , you should stop the current capture session and save any captured media. Once the thermal status has returned to normal, you can begin capturing again.

VideoDeviceController VideoDeviceController VideoDeviceController

Gets an object that controls settings for the video camera.

public : VideoDeviceController VideoDeviceController { get; }public VideoDeviceController VideoDeviceController { get; }Public ReadOnly Property VideoDeviceController As VideoDeviceController
Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

Remarks

Some drivers may require that the camera device preview to be in a running state before it can determine which controls are supported by the VideoDeviceController. If you check whether a certain control is supported by the VideoDeviceController before the preview stream is running, the control may be described as unsupported even though it is supported by the video device.

Methods

AddAudioEffectAsync(IAudioEffectDefinition) AddAudioEffectAsync(IAudioEffectDefinition) AddAudioEffectAsync(IAudioEffectDefinition)

Adds an audio effect to the capture pipeline.

public : IAsyncOperation<IMediaExtension> AddAudioEffectAsync(IAudioEffectDefinition definition)public IAsyncOperation<IMediaExtension> AddAudioEffectAsync(IAudioEffectDefinition definition)Public Function AddAudioEffectAsync(definition As IAudioEffectDefinition) As IAsyncOperation( Of IMediaExtension )
Parameters
definition
IAudioEffectDefinition IAudioEffectDefinition IAudioEffectDefinition

The object containing the definition of the effect to be added.

Returns

An asynchronous operation that returns an IMediaExtension upon successful completion.

Attributes

AddEffectAsync(MediaStreamType, String, IPropertySet) AddEffectAsync(MediaStreamType, String, IPropertySet) AddEffectAsync(MediaStreamType, String, IPropertySet)

Adds an audio or video effect.

public : IAsyncAction AddEffectAsync(MediaStreamType mediaStreamType, PlatForm::String effectActivationID, IPropertySet effectSettings)public IAsyncAction AddEffectAsync(MediaStreamType mediaStreamType, String effectActivationID, IPropertySet effectSettings)Public Function AddEffectAsync(mediaStreamType As MediaStreamType, effectActivationID As String, effectSettings As IPropertySet) As IAsyncAction
Parameters
mediaStreamType
MediaStreamType MediaStreamType MediaStreamType

Specifies the streams to which the effect will be applied.

effectActivationID
PlatForm::String String String

The class identifier of the activatable runtime class that implements the effect. The runtime class must implement the IMediaExtension interface.

effectSettings
IPropertySet IPropertySet IPropertySet

Configuration parameters for the effect.

Returns

Returns an IAsyncAction object that is used to control the asynchronous operation.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

Remarks

As of Windows 10, this method is deprecated. Use AddAudioEffectAsync or AddVideoEffectAsync instead. For how-to guidance on adding effects to the camera capture and preview streams, see Effects for video capture.

AddVideoEffectAsync(IVideoEffectDefinition, MediaStreamType) AddVideoEffectAsync(IVideoEffectDefinition, MediaStreamType) AddVideoEffectAsync(IVideoEffectDefinition, MediaStreamType)

Adds a video effect to the capture pipeline.

public : IAsyncOperation<IMediaExtension> AddVideoEffectAsync(IVideoEffectDefinition definition, MediaStreamType mediaStreamType)public IAsyncOperation<IMediaExtension> AddVideoEffectAsync(IVideoEffectDefinition definition, MediaStreamType mediaStreamType)Public Function AddVideoEffectAsync(definition As IVideoEffectDefinition, mediaStreamType As MediaStreamType) As IAsyncOperation( Of IMediaExtension )
Parameters
definition
IVideoEffectDefinition IVideoEffectDefinition IVideoEffectDefinition

The object containing the definition of the effect to be added.

mediaStreamType
MediaStreamType MediaStreamType MediaStreamType

Specifies the streams to which the effect will be applied.

Returns

An asynchronous operation that returns an IMediaExtension upon successful completion.

Attributes

Remarks

For how-to guidance on adding effects to the camera capture and preview streams, see Effects for video capture.

CapturePhotoToStorageFileAsync(ImageEncodingProperties, IStorageFile) CapturePhotoToStorageFileAsync(ImageEncodingProperties, IStorageFile) CapturePhotoToStorageFileAsync(ImageEncodingProperties, IStorageFile)

Captures a photo to a storage file.

public : IAsyncAction CapturePhotoToStorageFileAsync(ImageEncodingProperties type, IStorageFile file)public IAsyncAction CapturePhotoToStorageFileAsync(ImageEncodingProperties type, IStorageFile file)Public Function CapturePhotoToStorageFileAsync(type As ImageEncodingProperties, file As IStorageFile) As IAsyncAction
Parameters
type
ImageEncodingProperties ImageEncodingProperties ImageEncodingProperties

The encoding properties for the output image.

file
IStorageFile IStorageFile IStorageFile

The storage file where the image is saved.

Returns

Returns an IAsyncAction object that is used to control the asynchronous operation.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

Remarks

For how-to guidance on capturing a photo to a storage file, see Basic Basic photo, video, and audio capture with MediaCapture.

CapturePhotoToStreamAsync(ImageEncodingProperties, IRandomAccessStream) CapturePhotoToStreamAsync(ImageEncodingProperties, IRandomAccessStream) CapturePhotoToStreamAsync(ImageEncodingProperties, IRandomAccessStream)

Captures a photo to a random-access stream.

public : IAsyncAction CapturePhotoToStreamAsync(ImageEncodingProperties type, IRandomAccessStream stream)public IAsyncAction CapturePhotoToStreamAsync(ImageEncodingProperties type, IRandomAccessStream stream)Public Function CapturePhotoToStreamAsync(type As ImageEncodingProperties, stream As IRandomAccessStream) As IAsyncAction
Parameters
type
ImageEncodingProperties ImageEncodingProperties ImageEncodingProperties

The encoding properties for the output image.

stream
IRandomAccessStream IRandomAccessStream IRandomAccessStream

The stream where the image data is written.

Returns

Returns an IAsyncAction object that is used to control the asynchronous operation.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

ClearEffectsAsync(MediaStreamType) ClearEffectsAsync(MediaStreamType) ClearEffectsAsync(MediaStreamType)

Removes all audio and video effects from a stream.

public : IAsyncAction ClearEffectsAsync(MediaStreamType mediaStreamType)public IAsyncAction ClearEffectsAsync(MediaStreamType mediaStreamType)Public Function ClearEffectsAsync(mediaStreamType As MediaStreamType) As IAsyncAction
Parameters
mediaStreamType
MediaStreamType MediaStreamType MediaStreamType

The stream from which to remove the effects.

Returns

Returns a IAsyncAction object that is used to control the asynchronous operation.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

Close() Close() Close()

Closes the media capture object.

public : void Close()This member is not implemented in C#This member is not implemented in VB.Net
Attributes

CreateFrameReaderAsync(MediaFrameSource) CreateFrameReaderAsync(MediaFrameSource) CreateFrameReaderAsync(MediaFrameSource)

Creates a MediaFrameReader that is used to acquire frames from a MediaFrameSource.

public : IAsyncOperation<MediaFrameReader> CreateFrameReaderAsync(MediaFrameSource inputSource)public IAsyncOperation<MediaFrameReader> CreateFrameReaderAsync(MediaFrameSource inputSource)Public Function CreateFrameReaderAsync(inputSource As MediaFrameSource) As IAsyncOperation( Of MediaFrameReader )
Parameters
inputSource
MediaFrameSource MediaFrameSource MediaFrameSource

The media frame source from which the reader will acquire frames.

Returns
Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)
Capabilities
microphone webcam
See Also

CreateFrameReaderAsync(MediaFrameSource, String) CreateFrameReaderAsync(MediaFrameSource, String) CreateFrameReaderAsync(MediaFrameSource, String)

Creates a MediaFrameReader that is used to acquire frames with the specified media encoding subtype from a MediaFrameSource.

public : IAsyncOperation<MediaFrameReader> CreateFrameReaderAsync(MediaFrameSource inputSource, PlatForm::String outputSubtype)public IAsyncOperation<MediaFrameReader> CreateFrameReaderAsync(MediaFrameSource inputSource, String outputSubtype)Public Function CreateFrameReaderAsync(inputSource As MediaFrameSource, outputSubtype As String) As IAsyncOperation( Of MediaFrameReader )
Parameters
inputSource
MediaFrameSource MediaFrameSource MediaFrameSource

The media frame source from which the reader will acquire frames.

outputSubtype
PlatForm::String String String

A string specifying the requested media encoding subtype for the frames acquired by the frame reader. This value must be one of the strings defined by the properties of the MediaEncodingSubtypes class.

Returns
Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)
Capabilities
microphone webcam
See Also

CreateFrameReaderAsync(MediaFrameSource, String, BitmapSize) CreateFrameReaderAsync(MediaFrameSource, String, BitmapSize) CreateFrameReaderAsync(MediaFrameSource, String, BitmapSize)

Creates a MediaFrameReader that is used to acquire frames with the specified media encoding subtype and size from a MediaFrameSource.

public : IAsyncOperation<MediaFrameReader> CreateFrameReaderAsync(MediaFrameSource inputSource, PlatForm::String outputSubtype, BitmapSize outputSize)public IAsyncOperation<MediaFrameReader> CreateFrameReaderAsync(MediaFrameSource inputSource, String outputSubtype, BitmapSize outputSize)Public Function CreateFrameReaderAsync(inputSource As MediaFrameSource, outputSubtype As String, outputSize As BitmapSize) As IAsyncOperation( Of MediaFrameReader )
Parameters
inputSource
MediaFrameSource MediaFrameSource MediaFrameSource

The media frame source from which the reader will acquire frames.

outputSubtype
PlatForm::String String String

A string specifying the requested media encoding subtype for the frames acquired by the frame reader. This value must be one of the strings defined by the properties of the MediaEncodingSubtypes class.

outputSize
BitmapSize BitmapSize BitmapSize

An object specifying the requested size for the frames acquired by the frame reader.

Returns
Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)
Capabilities
microphone webcam
See Also

CreateMultiSourceFrameReaderAsync(IIterable<MediaFrameSource>) CreateMultiSourceFrameReaderAsync(IIterable<MediaFrameSource>) CreateMultiSourceFrameReaderAsync(IIterable<MediaFrameSource>)

Creates a MultiSourceMediaFrameReader that is used to acquire time-correlated frames from one or more MediaFrameSource objects.

public : IAsyncOperation<MultiSourceMediaFrameReader> CreateMultiSourceFrameReaderAsync(IIterable<MediaFrameSource> inputSources)public IAsyncOperation<MultiSourceMediaFrameReader> CreateMultiSourceFrameReaderAsync(IEnumerable<MediaFrameSource> inputSources)Public Function CreateMultiSourceFrameReaderAsync(inputSources As IEnumerable<MediaFrameSource>) As IAsyncOperation( Of MultiSourceMediaFrameReader )
Parameters
inputSources
IIterable<MediaFrameSource> IEnumerable<MediaFrameSource> IEnumerable<MediaFrameSource>

A IIterable list of MediaFrameSource objects to be used by the frame reader.

Returns
Attributes
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)
Capabilities
microphone webcam

Dispose() Dispose() Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

This member is not implemented in C++void Dispose()Sub Dispose
Attributes

FindAllVideoProfiles(String) FindAllVideoProfiles(String) FindAllVideoProfiles(String)

Retrieves the list of all video profiles supported by the specified video capture device.

public : static IVectorView<MediaCaptureVideoProfile> FindAllVideoProfiles(PlatForm::String videoDeviceId)public static IReadOnlyList<MediaCaptureVideoProfile> FindAllVideoProfiles(String videoDeviceId)Public Static Function FindAllVideoProfiles(videoDeviceId As String) As IReadOnlyList( Of MediaCaptureVideoProfile )
Parameters
videoDeviceId
PlatForm::String String String

The identifier of the video device for which supported video profiles are queried. For information on getting the video device ID, see DeviceInformation::FindAllAsync.

Returns
IVectorView<MediaCaptureVideoProfile> IReadOnlyList<MediaCaptureVideoProfile> IReadOnlyList<MediaCaptureVideoProfile>

The list of video profiles supported by the specified video capture device.

Attributes

Remarks

Before calling this method, call IsVideoProfileSupported to make sure that the capture device supports video profiles.

Use FindKnownVideoProfiles to request profiles with specific functionality using one of the KnownVideoProfile values.

For how-to guidance for working with camera profiles, see Discover and select camera capabilities with camera profiles.

See Also

FindConcurrentProfiles(String) FindConcurrentProfiles(String) FindConcurrentProfiles(String)

Retrieves the list of video profiles supported by the specified video capture device that can be used while another profile is used on a different capture device.

public : static IVectorView<MediaCaptureVideoProfile> FindConcurrentProfiles(PlatForm::String videoDeviceId)public static IReadOnlyList<MediaCaptureVideoProfile> FindConcurrentProfiles(String videoDeviceId)Public Static Function FindConcurrentProfiles(videoDeviceId As String) As IReadOnlyList( Of MediaCaptureVideoProfile )
Parameters
videoDeviceId
PlatForm::String String String

The identifier of the video device for which supported video profiles are queried. For information on getting the video device ID, see DeviceInformation::FindAllAsync.

Returns
IVectorView<MediaCaptureVideoProfile> IReadOnlyList<MediaCaptureVideoProfile> IReadOnlyList<MediaCaptureVideoProfile>

The list of video profiles supported by the specified video capture device that support concurrency.

Attributes

Remarks

Before calling this method, call IsVideoProfileSupported to make sure that the capture device supports video profiles.

This method supports the scenario where you capture video from two capture devices at the same time, such as a device's front camera and rear camera. Call the GetConcurrency method of one of the MediaCaptureVideoProfile objects in the returned list to get a list of profiles that can be used concurrently with that profile.

For how-to guidance for working with camera profiles, see Discover and select camera capabilities with camera profiles.

See Also

FindKnownVideoProfiles(String, KnownVideoProfile) FindKnownVideoProfiles(String, KnownVideoProfile) FindKnownVideoProfiles(String, KnownVideoProfile)

Retrieves the list of all video profiles supported by the specified video capture device that match the specified KnownVideoProfile value.

public : static IVectorView<MediaCaptureVideoProfile> FindKnownVideoProfiles(PlatForm::String videoDeviceId, KnownVideoProfile name)public static IReadOnlyList<MediaCaptureVideoProfile> FindKnownVideoProfiles(String videoDeviceId, KnownVideoProfile name)Public Static Function FindKnownVideoProfiles(videoDeviceId As String, name As KnownVideoProfile) As IReadOnlyList( Of MediaCaptureVideoProfile )
Parameters
videoDeviceId
PlatForm::String String String

The identifier of the video device for which supported video profiles are queried. For information on getting the video device ID, see DeviceInformation::FindAllAsync.

name
KnownVideoProfile KnownVideoProfile KnownVideoProfile

A value specifying one of the profile names known by the system.

Returns
IVectorView<MediaCaptureVideoProfile> IReadOnlyList<MediaCaptureVideoProfile> IReadOnlyList<MediaCaptureVideoProfile>

The list of video profiles supported by the specified video capture device that match the specified known profile name.

Attributes

Remarks

Before calling this method, call IsVideoProfileSupported to make sure that the capture device supports video profiles.

This method allows you to request profiles with specific functionality by using one of the KnownVideoProfile values. Some hardware may support additional profiles that do not correspond to any of the known profile names. Use FindAllVideoProfiles to retrieve all video profiles supported by the video capture device.

For how-to guidance for working with camera profiles, see Discover and select camera capabilities with camera profiles.

See Also

GetEncoderProperty(MediaStreamType, Guid) GetEncoderProperty(MediaStreamType, Guid) GetEncoderProperty(MediaStreamType, Guid)

Gets the value of an encoding property.

public : PlatForm::Object GetEncoderProperty(MediaStreamType mediaStreamType, PlatForm::Guid propertyId)public object GetEncoderProperty(MediaStreamType mediaStreamType, Guid propertyId)Public Function GetEncoderProperty(mediaStreamType As MediaStreamType, propertyId As Guid) As object
Parameters
mediaStreamType
MediaStreamType MediaStreamType MediaStreamType

Specifies the stream to query for the encoding property.

propertyId
PlatForm::Guid Guid Guid

The encoding property to retrieve.

Returns
PlatForm::Object object object

Returns the value of the encoding property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

GetPreviewFrameAsync() GetPreviewFrameAsync() GetPreviewFrameAsync()

Gets a preview frame from the capture device.

public : IAsyncOperation<VideoFrame> GetPreviewFrameAsync()public IAsyncOperation<VideoFrame> GetPreviewFrameAsync()Public Function GetPreviewFrameAsync() As IAsyncOperation( Of VideoFrame )
Returns

An asynchronous operation that returns a VideoFrame on successful completion.

Attributes

Remarks

This method returns the preview frame in the current format of the capture device without copying or converting the frame. To get the preview frame in another format, use the GetPreviewFrameAsync(VideoFrame) overload and pass in a VideoFrame with your desired format.

For how-to guidance on preview frames, see Get a preview frame.

See Also

GetPreviewFrameAsync(VideoFrame) GetPreviewFrameAsync(VideoFrame) GetPreviewFrameAsync(VideoFrame)

Gets a preview frame from the capture device, copied into the provided destination VideoFrame and converted into the destination frame's format.

public : IAsyncOperation<VideoFrame> GetPreviewFrameAsync(VideoFrame destination)public IAsyncOperation<VideoFrame> GetPreviewFrameAsync(VideoFrame destination)Public Function GetPreviewFrameAsync(destination As VideoFrame) As IAsyncOperation( Of VideoFrame )
Parameters
destination
VideoFrame VideoFrame VideoFrame

The video frame into which the preview frame will be copied.

Returns

An asynchronous operation that returns a VideoFrame on successful completion.

Attributes

Remarks

To get a preview frame without going through a copy or conversion operation, use the no argument overload of GetPreviewFrameAsync.

For how-to guidance on preview frames, see Get a preview frame.

See Also

GetPreviewMirroring() GetPreviewMirroring() GetPreviewMirroring()

Queries whether the video stream is mirrored horizontally.

public : PlatForm::Boolean GetPreviewMirroring()public bool GetPreviewMirroring()Public Function GetPreviewMirroring() As bool
Returns
PlatForm::Boolean bool bool

True if mirroring is enabled; false otherwise.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

GetPreviewRotation() GetPreviewRotation() GetPreviewRotation()

Gets the rotation of the video preview stream.

public : VideoRotation GetPreviewRotation()public VideoRotation GetPreviewRotation()Public Function GetPreviewRotation() As VideoRotation
Returns

The amount by which the video preview stream is rotated.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

GetRecordRotation() GetRecordRotation() GetRecordRotation()

Gets the rotation of the recorded video.

public : VideoRotation GetRecordRotation()public VideoRotation GetRecordRotation()Public Function GetRecordRotation() As VideoRotation
Returns

The amount by which the recorded video is rotated.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

InitializeAsync() InitializeAsync() InitializeAsync()

Initializes the MediaCapture object, using default settings.

public : IAsyncAction InitializeAsync()public IAsyncAction InitializeAsync()Public Function InitializeAsync() As IAsyncAction
Returns

Returns a IAsyncAction object that is used to control the asynchronous operation.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

Remarks

InitializeAsync will launch a consent prompt to get the user's permission for the app to access the microphone or camera. InitializeAsync should be called from the main UI thread of your app. In apps that use C# or C++, the first use of the MediaCapture object to call InitializeAsync should be on the STA thread. Calls from an MTA thread may result in undefined behavior.

For how-to guidance on initializing and shutting down the MediaCapture object, see Basic photo, video, and audio capture with MediaCapture.

See Also

InitializeAsync(MediaCaptureInitializationSettings) InitializeAsync(MediaCaptureInitializationSettings) InitializeAsync(MediaCaptureInitializationSettings)

Initializes the MediaCapture object.

public : IAsyncAction InitializeAsync(MediaCaptureInitializationSettings mediaCaptureInitializationSettings)public IAsyncAction InitializeAsync(MediaCaptureInitializationSettings mediaCaptureInitializationSettings)Public Function InitializeAsync(mediaCaptureInitializationSettings As MediaCaptureInitializationSettings) As IAsyncAction
Parameters
mediaCaptureInitializationSettings
MediaCaptureInitializationSettings MediaCaptureInitializationSettings MediaCaptureInitializationSettings

The initialization settings.

Returns

Returns a IAsyncAction object that is used to control the asynchronous operation.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

Remarks

InitializeAsync will launch a consent prompt to get the user's permission for the app to access the microphone or camera. InitializeAsync should be called from the main UI thread of your app. In apps that use C# or C++, the first use of the MediaCapture object to call InitializeAsync should be on the STA thread. Calls from an MTA thread may result in undefined behavior.

For how-to guidance on initializing and shutting down the MediaCapture object, see Basic photo, video, and audio capture with MediaCapture.

See Also

IsVideoProfileSupported(String) IsVideoProfileSupported(String) IsVideoProfileSupported(String)

Gets a boolean value indicating whether video profiles are supported by the specified video capture device.

public : static PlatForm::Boolean IsVideoProfileSupported(PlatForm::String videoDeviceId)public static bool IsVideoProfileSupported(String videoDeviceId)Public Static Function IsVideoProfileSupported(videoDeviceId As String) As bool
Parameters
videoDeviceId
PlatForm::String String String

The identifier of the video device for which supported video profile support is queried. For information on getting the video device ID, see DeviceInformation::FindAllAsync.

Returns
PlatForm::Boolean bool bool

True if video profiles are supported; otherwise, false.

Attributes

PauseRecordAsync(MediaCapturePauseBehavior) PauseRecordAsync(MediaCapturePauseBehavior) PauseRecordAsync(MediaCapturePauseBehavior)

Pauses an ongoing record operation.

public : IAsyncAction PauseRecordAsync(MediaCapturePauseBehavior behavior)public IAsyncAction PauseRecordAsync(MediaCapturePauseBehavior behavior)Public Function PauseRecordAsync(behavior As MediaCapturePauseBehavior) As IAsyncAction
Parameters
behavior
MediaCapturePauseBehavior MediaCapturePauseBehavior MediaCapturePauseBehavior

A value indicating whether the media capture hardware resources should be preserved or released while recording is paused.

Returns

An asynchronous action.

Attributes

Remarks

Resume recording by calling ResumeRecordAsync.

See Also

PauseRecordWithResultAsync(MediaCapturePauseBehavior) PauseRecordWithResultAsync(MediaCapturePauseBehavior) PauseRecordWithResultAsync(MediaCapturePauseBehavior)

Pauses an ongoing media record operation and provides a MediaCapturePauseResult that can be used to help the user align the camera with the last captured frame when resuming recording.

public : IAsyncOperation<MediaCapturePauseResult> PauseRecordWithResultAsync(MediaCapturePauseBehavior behavior)public IAsyncOperation<MediaCapturePauseResult> PauseRecordWithResultAsync(MediaCapturePauseBehavior behavior)Public Function PauseRecordWithResultAsync(behavior As MediaCapturePauseBehavior) As IAsyncOperation( Of MediaCapturePauseResult )
Parameters
behavior
MediaCapturePauseBehavior MediaCapturePauseBehavior MediaCapturePauseBehavior

A value indicating whether the media capture hardware resources should be preserved or released while recording is paused.

Returns
Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)
Capabilities
microphone webcam

PrepareAdvancedPhotoCaptureAsync(ImageEncodingProperties) PrepareAdvancedPhotoCaptureAsync(ImageEncodingProperties) PrepareAdvancedPhotoCaptureAsync(ImageEncodingProperties)

Initializes the advanced photo capture and provides the AdvancedPhotoCapture object used to manage the recording.

public : IAsyncOperation<AdvancedPhotoCapture> PrepareAdvancedPhotoCaptureAsync(ImageEncodingProperties encodingProperties)public IAsyncOperation<AdvancedPhotoCapture> PrepareAdvancedPhotoCaptureAsync(ImageEncodingProperties encodingProperties)Public Function PrepareAdvancedPhotoCaptureAsync(encodingProperties As ImageEncodingProperties) As IAsyncOperation( Of AdvancedPhotoCapture )
Parameters
encodingProperties
ImageEncodingProperties ImageEncodingProperties ImageEncodingProperties

The encoding properties used for the resulting image.

Returns
Attributes

PrepareLowLagPhotoCaptureAsync(ImageEncodingProperties) PrepareLowLagPhotoCaptureAsync(ImageEncodingProperties) PrepareLowLagPhotoCaptureAsync(ImageEncodingProperties)

Initializes the low shutter lag photo capture and provides the LowLagPhotoCapture object used to manage the recording.

public : IAsyncOperation<LowLagPhotoCapture> PrepareLowLagPhotoCaptureAsync(ImageEncodingProperties type)public IAsyncOperation<LowLagPhotoCapture> PrepareLowLagPhotoCaptureAsync(ImageEncodingProperties type)Public Function PrepareLowLagPhotoCaptureAsync(type As ImageEncodingProperties) As IAsyncOperation( Of LowLagPhotoCapture )
Parameters
type
ImageEncodingProperties ImageEncodingProperties ImageEncodingProperties

The encoding profile used for the image.

Returns

When this method completes, a LowLagPhotoCapture object is returned which can be used to start the photo capture.

Attributes

Remarks

Use PrepareLowLagPhotoCaptureAsync to initialize the capture. This is an asynchronous calls which returns a LowLagPhotoCapture object when it is finished, which is used to start the actual photo capture by calling LowLagPhotoCapture.CaptureAsync.

PrepareLowLagPhotoCaptureAsync must be called before LowLagPhotoCapture.CaptureAsync.

For how-to guidance on using LowLagPhotoCapture to capture a photo, see Basic photo, video, and audio capture with MediaCapture.

See Also

PrepareLowLagPhotoSequenceCaptureAsync(ImageEncodingProperties) PrepareLowLagPhotoSequenceCaptureAsync(ImageEncodingProperties) PrepareLowLagPhotoSequenceCaptureAsync(ImageEncodingProperties)

Initializes the low shutter lag photo sequence capture and provides the LowLagPhotoSequenceCapture object used to manage the recording.

public : IAsyncOperation<LowLagPhotoSequenceCapture> PrepareLowLagPhotoSequenceCaptureAsync(ImageEncodingProperties type)public IAsyncOperation<LowLagPhotoSequenceCapture> PrepareLowLagPhotoSequenceCaptureAsync(ImageEncodingProperties type)Public Function PrepareLowLagPhotoSequenceCaptureAsync(type As ImageEncodingProperties) As IAsyncOperation( Of LowLagPhotoSequenceCapture )
Parameters
type
ImageEncodingProperties ImageEncodingProperties ImageEncodingProperties

The encoding profile used for the image.

Returns

When this method completes, a LowLagPhotoSequenceCapture object is returned which can be used to start the photo sequence capture.

Attributes

Remarks

Use MediaCapture.PrepareLowLagPhotoSequenceCaptureAsync to initialize the photo sequence capture. This is an asynchronous call which returns a LowLagPhotoSequenceCapture object when it is finished, which is used start the photo sequence capture by calling LowLagPhotoSequenceCapture.StartAsync.

PrepareLowLagPhotoSequenceCaptureAsync must be called before LowLagPhotoSequenceCapture.StartAsync.

PrepareLowLagRecordToCustomSinkAsync(MediaEncodingProfile, String, IPropertySet) PrepareLowLagRecordToCustomSinkAsync(MediaEncodingProfile, String, IPropertySet) PrepareLowLagRecordToCustomSinkAsync(MediaEncodingProfile, String, IPropertySet)

Initializes the low lag recording using the specified custom sink to store the recording. This method provides the LowLagMediaRecording object used to managed the recording.

public : IAsyncOperation<LowLagMediaRecording> PrepareLowLagRecordToCustomSinkAsync(MediaEncodingProfile encodingProfile, PlatForm::String customSinkActivationId, IPropertySet customSinkSettings)public IAsyncOperation<LowLagMediaRecording> PrepareLowLagRecordToCustomSinkAsync(MediaEncodingProfile encodingProfile, String customSinkActivationId, IPropertySet customSinkSettings)Public Function PrepareLowLagRecordToCustomSinkAsync(encodingProfile As MediaEncodingProfile, customSinkActivationId As String, customSinkSettings As IPropertySet) As IAsyncOperation( Of LowLagMediaRecording )
Parameters
encodingProfile
MediaEncodingProfile MediaEncodingProfile MediaEncodingProfile

The encoding profile to use for the recording.

customSinkActivationId
PlatForm::String String String

The activatable class ID of the media extension for the custom media sink.

customSinkSettings
IPropertySet IPropertySet IPropertySet

Contains properties of the media extension.

Returns

When this method completes, a LowLagMediaRecording object is returned which can be used to start the photo capture.

Attributes
See Also

PrepareLowLagRecordToCustomSinkAsync(MediaEncodingProfile, IMediaExtension) PrepareLowLagRecordToCustomSinkAsync(MediaEncodingProfile, IMediaExtension) PrepareLowLagRecordToCustomSinkAsync(MediaEncodingProfile, IMediaExtension)

Initializes the low lag recording using the specified custom sink to store the recording. This method provides the LowLagMediaRecording object used to managed the capture.

public : IAsyncOperation<LowLagMediaRecording> PrepareLowLagRecordToCustomSinkAsync(MediaEncodingProfile encodingProfile, IMediaExtension customMediaSink)public IAsyncOperation<LowLagMediaRecording> PrepareLowLagRecordToCustomSinkAsync(MediaEncodingProfile encodingProfile, IMediaExtension customMediaSink)Public Function PrepareLowLagRecordToCustomSinkAsync(encodingProfile As MediaEncodingProfile, customMediaSink As IMediaExtension) As IAsyncOperation( Of LowLagMediaRecording )
Parameters
encodingProfile
MediaEncodingProfile MediaEncodingProfile MediaEncodingProfile

The encoding profile to use for the recording.

customMediaSink
IMediaExtension IMediaExtension IMediaExtension

The media extension for the custom media sink.

Returns

When this method completes, a LowLagMediaRecording object is returned which can be used to start the photo capture.

Attributes
See Also

PrepareLowLagRecordToStorageFileAsync(MediaEncodingProfile, IStorageFile) PrepareLowLagRecordToStorageFileAsync(MediaEncodingProfile, IStorageFile) PrepareLowLagRecordToStorageFileAsync(MediaEncodingProfile, IStorageFile)

Initializes the low lag recording using the specified file to store the recording. This method provides the LowLagMediaRecording object used to managed the recording.

public : IAsyncOperation<LowLagMediaRecording> PrepareLowLagRecordToStorageFileAsync(MediaEncodingProfile encodingProfile, IStorageFile file)public IAsyncOperation<LowLagMediaRecording> PrepareLowLagRecordToStorageFileAsync(MediaEncodingProfile encodingProfile, IStorageFile file)Public Function PrepareLowLagRecordToStorageFileAsync(encodingProfile As MediaEncodingProfile, file As IStorageFile) As IAsyncOperation( Of LowLagMediaRecording )
Parameters
encodingProfile
MediaEncodingProfile MediaEncodingProfile MediaEncodingProfile

The encoding profile for the recording.

file
IStorageFile IStorageFile IStorageFile

The storage file where the image is saved.

Returns

When this method completes, a LowLagMediaRecording object is returned which can be used to start the photo capture.

Attributes

PrepareLowLagRecordToStreamAsync(MediaEncodingProfile, IRandomAccessStream) PrepareLowLagRecordToStreamAsync(MediaEncodingProfile, IRandomAccessStream) PrepareLowLagRecordToStreamAsync(MediaEncodingProfile, IRandomAccessStream)

Initializes the low lag recording using the specified random-access stream to store the recording. This method provides the LowLagMediaRecording object used to managed the recording.

public : IAsyncOperation<LowLagMediaRecording> PrepareLowLagRecordToStreamAsync(MediaEncodingProfile encodingProfile, IRandomAccessStream stream)public IAsyncOperation<LowLagMediaRecording> PrepareLowLagRecordToStreamAsync(MediaEncodingProfile encodingProfile, IRandomAccessStream stream)Public Function PrepareLowLagRecordToStreamAsync(encodingProfile As MediaEncodingProfile, stream As IRandomAccessStream) As IAsyncOperation( Of LowLagMediaRecording )
Parameters
encodingProfile
MediaEncodingProfile MediaEncodingProfile MediaEncodingProfile

The encoding profile for the recording.

stream
IRandomAccessStream IRandomAccessStream IRandomAccessStream

The stream where the image data is written.

Returns

When this method completes, a LowLagMediaRecording object is returned which can be used to start the photo capture.

Attributes

PrepareVariablePhotoSequenceCaptureAsync(ImageEncodingProperties) PrepareVariablePhotoSequenceCaptureAsync(ImageEncodingProperties) PrepareVariablePhotoSequenceCaptureAsync(ImageEncodingProperties)

Initializes the variable photo sequence capture and provides the VariablePhotoSequenceCapture object used to manage the recording.

public : IAsyncOperation<VariablePhotoSequenceCapture> PrepareVariablePhotoSequenceCaptureAsync(ImageEncodingProperties type)public IAsyncOperation<VariablePhotoSequenceCapture> PrepareVariablePhotoSequenceCaptureAsync(ImageEncodingProperties type)Public Function PrepareVariablePhotoSequenceCaptureAsync(type As ImageEncodingProperties) As IAsyncOperation( Of VariablePhotoSequenceCapture )
Parameters
type
ImageEncodingProperties ImageEncodingProperties ImageEncodingProperties

The encoding profile used for the image.

Returns

When this method completes, a VariablePhotoSequenceCapture object is returned which can be used to start the photo sequence capture.

Attributes

RemoveEffectAsync(IMediaExtension) RemoveEffectAsync(IMediaExtension) RemoveEffectAsync(IMediaExtension)

Removes the specified effect from the capture pipeline.

public : IAsyncAction RemoveEffectAsync(IMediaExtension effect)public IAsyncAction RemoveEffectAsync(IMediaExtension effect)Public Function RemoveEffectAsync(effect As IMediaExtension) As IAsyncAction
Parameters
effect
IMediaExtension IMediaExtension IMediaExtension

The effect to remove from the capture pipeline.

Returns

Returns an IAsyncAction object that is used to control the asynchronous operation.

Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)
Capabilities
microphone webcam

Remarks

Pass the effect instance returned by AddVideoEffectAsync or AddAudioEffectAsync into this method to remove the effect from the pipeline.

ResumeRecordAsync() ResumeRecordAsync() ResumeRecordAsync()

Resumes a paused recording operation.

public : IAsyncAction ResumeRecordAsync()public IAsyncAction ResumeRecordAsync()Public Function ResumeRecordAsync() As IAsyncAction
Returns

An asynchronous operation.

Attributes

Remarks

Pause recording by calling PauseRecordAsync.

SetEncoderProperty(MediaStreamType, Guid, Object) SetEncoderProperty(MediaStreamType, Guid, Object) SetEncoderProperty(MediaStreamType, Guid, Object)

Sets an encoding property.

public : void SetEncoderProperty(MediaStreamType mediaStreamType, PlatForm::Guid propertyId, PlatForm::Object propertyValue)public void SetEncoderProperty(MediaStreamType mediaStreamType, Guid propertyId, Object propertyValue)Public Function SetEncoderProperty(mediaStreamType As MediaStreamType, propertyId As Guid, propertyValue As Object) As void
Parameters
mediaStreamType
MediaStreamType MediaStreamType MediaStreamType

The type of media data the stream represents, such as video or audio.

propertyId
PlatForm::Guid Guid Guid

The encoding property to set.

propertyValue
PlatForm::Object Object Object

The new value of the encoding property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

Remarks

You can only call SetEncoderProperty with mediaStreamType equal to MediaStreamType.Audio, if the encoder property is applied to only the audio encoder in the record sink. The preview sink does not allow you to set an encoding profile with compressed audio.

For non-H.264 cameras, when you call SetEncoderProperty before recording or previewing has started, the property is stored locally. When you start recording, the property is applied to the encoder at the time of encoder initialization. To configure static encoding properties, you must call SetEncoderProperty before recording or previewing starts. Before recording or previewing starts, GetEncoderProperty will return the value of the property stored locally.

If the camera is a H.264 camera and the stream that SetEncoderProperty is called on is of type MediaStreamType.VideoRecord, then the property is applied directly to the camera. This is true both before and after recording has started.

For non-H.264 cameras, when you call SetEncoderProperty after you get the record or preview started completion callback, the property is set directly on the encoder and is therefore used to configure dynamic encoding properties.

If you call SetEncoderProperty after you issue a call to start recording or previewing and before you get the record or preview started completion callback, you will receive an MF_E_INVALIDREQUEST error since the property cannot be applied to static nor dynamic settings.

To rotate the preview stream, use the GUID defined as MF_MT_VIDEO_ROTATION. For how-to guidance on handling orientation when using the camera, see Handle device orientation with MediaCapture.

SetEncodingPropertiesAsync(MediaStreamType, IMediaEncodingProperties, MediaPropertySet) SetEncodingPropertiesAsync(MediaStreamType, IMediaEncodingProperties, MediaPropertySet) SetEncodingPropertiesAsync(MediaStreamType, IMediaEncodingProperties, MediaPropertySet)

Asynchronously sets the media encoding properties.

public : IAsyncAction SetEncodingPropertiesAsync(MediaStreamType mediaStreamType, IMediaEncodingProperties mediaEncodingProperties, MediaPropertySet encoderProperties)public IAsyncAction SetEncodingPropertiesAsync(MediaStreamType mediaStreamType, IMediaEncodingProperties mediaEncodingProperties, MediaPropertySet encoderProperties)Public Function SetEncodingPropertiesAsync(mediaStreamType As MediaStreamType, mediaEncodingProperties As IMediaEncodingProperties, encoderProperties As MediaPropertySet) As IAsyncAction
Parameters
mediaStreamType
MediaStreamType MediaStreamType MediaStreamType

The type of media data the stream represents, such as video or audio.

mediaEncodingProperties
IMediaEncodingProperties IMediaEncodingProperties IMediaEncodingProperties

The properties for the media encoding.

encoderProperties
MediaPropertySet MediaPropertySet MediaPropertySet

The properties for the encoder.

Returns

Object that is used to control the asynchronous operation.

Attributes

Remarks

This method sets the encoding properties of the encoder that processes the data before it’s passed on to a CaptureElement to be displayed, written out to a IRandomAccessStream or StorageFile, or delivered to a custom media sink. This method does not change the configuration of the source of the data, which is the camera device. It is possible to set the encoding properties to a resolution that is not natively supported by the camera. In this case, the MediaCapture pipeline will use an encoder to perform the conversion to the requested format. Note that this conversion does consume system resources and can result in poor performance or even errors, especially on devices that with limited or no graphics acceleration. For typical scenarios, it is recommended that you choose a resolution supported by the camera that is closest to your desired resolution. You can get a list of a capture device's supported resolutions by calling VideoDeviceController.GetAvailableMediaStreamProperties. For more information, see Set format, resolution, and frame rate for MediaCapture and the Camera Resolution Sample.

To rotate the record or preview stream, use the GUID defined by MF_MT_VIDEO_ROTATION to add metadata to the stream. Note that this rotation is performed by the consumer of the stream, such as the CaptureElement or a video player app, while the actual pixels in the stream still retain their original orientation. For how-to guidance on handling orientation when using the camera, see Handle device orientation with MediaCapture.

To modify the properties of the capture device, use VideoDeviceController.SetMediaStreamPropertiesAsync.

See Also

SetPreviewMirroring(Boolean) SetPreviewMirroring(Boolean) SetPreviewMirroring(Boolean)

Enables or disables horizontal mirroring of the video preview stream. This is not the preferred method for mirroring. See the Remarks section below for details.

public : void SetPreviewMirroring(bool value)public void SetPreviewMirroring(Boolean value)Public Function SetPreviewMirroring(value As Boolean) As void
Parameters
value
bool Boolean Boolean

True to enable mirroring; false to disable mirroring.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

Remarks

Horizontal mirroring is useful for video conferencing or video chat applications, because the users typically want to see a reflected image of themselves. The non-mirrored view can look strange, because we are used to seeing ourselves in a mirror.

To mirror the preview video, apps should instead use the following method. Windows app using JavaScript should use the msHorizontalMirror property of the video object. Windows Store app using C++, C#, or Visual Basic should use the FlowDirection property on the CaptureElement.

SetPreviewMirroring can potentially be used as a performance optimization on some devices

For how-to guidance on handling orientation and mirroring when using the camera, see Handle device orientation with MediaCapture.

SetPreviewRotation(VideoRotation) SetPreviewRotation(VideoRotation) SetPreviewRotation(VideoRotation)

Rotates the video preview stream.

public : void SetPreviewRotation(VideoRotation value)public void SetPreviewRotation(VideoRotation value)Public Function SetPreviewRotation(value As VideoRotation) As void
Parameters
value
VideoRotation VideoRotation VideoRotation

The amount by which to rotate the video.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

Remarks

For how-to guidance on handling orientation when using the camera, see Handle device orientation with MediaCapture.

SetRecordRotation(VideoRotation) SetRecordRotation(VideoRotation) SetRecordRotation(VideoRotation)

Rotates the recorded video.

public : void SetRecordRotation(VideoRotation value)public void SetRecordRotation(VideoRotation value)Public Function SetRecordRotation(value As VideoRotation) As void
Parameters
value
VideoRotation VideoRotation VideoRotation

The amount by which to rotate the video.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

Remarks

For how-to guidance on handling orientation when using the camera, see Handle device orientation with MediaCapture.

StartPreviewAsync() StartPreviewAsync() StartPreviewAsync()

Starts preview.

public : IAsyncAction StartPreviewAsync()public IAsyncAction StartPreviewAsync()Public Function StartPreviewAsync() As IAsyncAction
Returns

Returns a IAsyncAction object that is used to control the asynchronous operation.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

StartPreviewToCustomSinkAsync(MediaEncodingProfile, String, IPropertySet) StartPreviewToCustomSinkAsync(MediaEncodingProfile, String, IPropertySet) StartPreviewToCustomSinkAsync(MediaEncodingProfile, String, IPropertySet)

Starts sending a preview stream to a custom media sink using the specified encoding profile and sink settings.

public : IAsyncAction StartPreviewToCustomSinkAsync(MediaEncodingProfile encodingProfile, PlatForm::String customSinkActivationId, IPropertySet customSinkSettings)public IAsyncAction StartPreviewToCustomSinkAsync(MediaEncodingProfile encodingProfile, String customSinkActivationId, IPropertySet customSinkSettings)Public Function StartPreviewToCustomSinkAsync(encodingProfile As MediaEncodingProfile, customSinkActivationId As String, customSinkSettings As IPropertySet) As IAsyncAction
Parameters
encodingProfile
MediaEncodingProfile MediaEncodingProfile MediaEncodingProfile

The encoding profile to use for the recording.

customSinkActivationId
PlatForm::String String String

The activatable class ID of the media extension for the custom media sink.

customSinkSettings
IPropertySet IPropertySet IPropertySet

Contains properties of the media extension.

Returns

An object that is used to control the asynchronous operation.

Attributes

Remarks

When you call StartPreviewToCustomSinkAsync, the system will call the custom sink’s IMFMediaTypeHandler::IsMediaTypeSupported method, passing in the native media type of the capture device. This check is performed in an effort to avoid unnecessary video conversion. If the custom sink returns S_OK from IsMediaTypeSupported when this check is made, then the preview stream will use the native media type instead of the type specified by the encodingProfile parameter.

See Also

StartPreviewToCustomSinkAsync(MediaEncodingProfile, IMediaExtension) StartPreviewToCustomSinkAsync(MediaEncodingProfile, IMediaExtension) StartPreviewToCustomSinkAsync(MediaEncodingProfile, IMediaExtension)

Starts sending a preview stream to a custom media sink using the specified encoding profile.

public : IAsyncAction StartPreviewToCustomSinkAsync(MediaEncodingProfile encodingProfile, IMediaExtension customMediaSink)public IAsyncAction StartPreviewToCustomSinkAsync(MediaEncodingProfile encodingProfile, IMediaExtension customMediaSink)Public Function StartPreviewToCustomSinkAsync(encodingProfile As MediaEncodingProfile, customMediaSink As IMediaExtension) As IAsyncAction
Parameters
encodingProfile
MediaEncodingProfile MediaEncodingProfile MediaEncodingProfile

The encoding profile to use for the recording.

customMediaSink
IMediaExtension IMediaExtension IMediaExtension

The media extension for the custom media sink.

Returns

An object that is used to control the asynchronous operation.

Attributes

Remarks

When you call StartPreviewToCustomSinkAsync, the system will call the custom sink’s IMFMediaTypeHandler::IsMediaTypeSupported method, passing in the native media type of the capture device. This check is performed in an effort to avoid unnecessary video conversion. If the custom sink returns S_OK from IsMediaTypeSupported when this check is made, then the preview stream will use the native media type instead of the type specified by the encodingProfile parameter.

See Also

StartRecordToCustomSinkAsync(MediaEncodingProfile, String, IPropertySet) StartRecordToCustomSinkAsync(MediaEncodingProfile, String, IPropertySet) StartRecordToCustomSinkAsync(MediaEncodingProfile, String, IPropertySet)

Start recording to a custom media sink using the specified encoding profile and sink settings.

public : IAsyncAction StartRecordToCustomSinkAsync(MediaEncodingProfile encodingProfile, PlatForm::String customSinkActivationId, IPropertySet customSinkSettings)public IAsyncAction StartRecordToCustomSinkAsync(MediaEncodingProfile encodingProfile, String customSinkActivationId, IPropertySet customSinkSettings)Public Function StartRecordToCustomSinkAsync(encodingProfile As MediaEncodingProfile, customSinkActivationId As String, customSinkSettings As IPropertySet) As IAsyncAction
Parameters
encodingProfile
MediaEncodingProfile MediaEncodingProfile MediaEncodingProfile

The encoding profile to use for the recording.

customSinkActivationId
PlatForm::String String String

The activatable class ID of the media extension for the custom media sink.

customSinkSettings
IPropertySet IPropertySet IPropertySet

Contains properties of the media extension.

Returns

An object that is used to control the asynchronous operation.

Attributes

Remarks

A RecordLimitationExceeded event is raised if the record limit is exceeded. In the current release, the record limit is three hours.

See Also

StartRecordToCustomSinkAsync(MediaEncodingProfile, IMediaExtension) StartRecordToCustomSinkAsync(MediaEncodingProfile, IMediaExtension) StartRecordToCustomSinkAsync(MediaEncodingProfile, IMediaExtension)

Start recording to a custom media sink using the specified encoding profile.

public : IAsyncAction StartRecordToCustomSinkAsync(MediaEncodingProfile encodingProfile, IMediaExtension customMediaSink)public IAsyncAction StartRecordToCustomSinkAsync(MediaEncodingProfile encodingProfile, IMediaExtension customMediaSink)Public Function StartRecordToCustomSinkAsync(encodingProfile As MediaEncodingProfile, customMediaSink As IMediaExtension) As IAsyncAction
Parameters
encodingProfile
MediaEncodingProfile MediaEncodingProfile MediaEncodingProfile

The encoding profile to use for the recording.

customMediaSink
IMediaExtension IMediaExtension IMediaExtension

The media extension for the custom media sink.

Returns

An object that is used to control the asynchronous operation.

Attributes

Remarks

A RecordLimitationExceeded event is raised if the record limit is exceeded. In the current release, record limit is three hours.

See Also

StartRecordToStorageFileAsync(MediaEncodingProfile, IStorageFile) StartRecordToStorageFileAsync(MediaEncodingProfile, IStorageFile) StartRecordToStorageFileAsync(MediaEncodingProfile, IStorageFile)

Starts recording asynchronously to a storage file.

public : IAsyncAction StartRecordToStorageFileAsync(MediaEncodingProfile encodingProfile, IStorageFile file)public IAsyncAction StartRecordToStorageFileAsync(MediaEncodingProfile encodingProfile, IStorageFile file)Public Function StartRecordToStorageFileAsync(encodingProfile As MediaEncodingProfile, file As IStorageFile) As IAsyncAction
Parameters
encodingProfile
MediaEncodingProfile MediaEncodingProfile MediaEncodingProfile

The encoding profile for the recording.

file
IStorageFile IStorageFile IStorageFile

The storage file where the image is saved.

Returns

Returns a IAsyncAction object that is used to control the asynchronous operation.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

Remarks

For how-to guidance on recording to a file, see Basic photo, video, and audio capture with MediaCapture.

See Also

StartRecordToStreamAsync(MediaEncodingProfile, IRandomAccessStream) StartRecordToStreamAsync(MediaEncodingProfile, IRandomAccessStream) StartRecordToStreamAsync(MediaEncodingProfile, IRandomAccessStream)

Starts recording to a random-access stream.

public : IAsyncAction StartRecordToStreamAsync(MediaEncodingProfile encodingProfile, IRandomAccessStream stream)public IAsyncAction StartRecordToStreamAsync(MediaEncodingProfile encodingProfile, IRandomAccessStream stream)Public Function StartRecordToStreamAsync(encodingProfile As MediaEncodingProfile, stream As IRandomAccessStream) As IAsyncAction
Parameters
encodingProfile
MediaEncodingProfile MediaEncodingProfile MediaEncodingProfile

The encoding profile for the recording.

stream
IRandomAccessStream IRandomAccessStream IRandomAccessStream

The stream where the image data is written.

Returns

Returns a IAsyncAction object that is used to control the asynchronous operation.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

Remarks

For how-to guidance on recording to a file, see Basic photo, video, and audio capture with MediaCapture.

StopPreviewAsync() StopPreviewAsync() StopPreviewAsync()

Stops preview.

public : IAsyncAction StopPreviewAsync()public IAsyncAction StopPreviewAsync()Public Function StopPreviewAsync() As IAsyncAction
Returns

Returns a IAsyncAction object that is used to control the asynchronous operation.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

StopRecordAsync() StopRecordAsync() StopRecordAsync()

Stops recording.

public : IAsyncAction StopRecordAsync()public IAsyncAction StopRecordAsync()Public Function StopRecordAsync() As IAsyncAction
Returns

Returns a IAsyncAction object that is used to control the asynchronous operation.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

Remarks

Before playing back a video, the RandomAccessStream should be closed when StopRecordAsync completes.

StopRecordWithResultAsync() StopRecordWithResultAsync() StopRecordWithResultAsync()

Asynchronously stops the media recording and provides a MediaCaptureStopResult that can be used to help the user align the camera with the last captured frame when restarting recording.

public : IAsyncOperation<MediaCaptureStopResult> StopRecordWithResultAsync()public IAsyncOperation<MediaCaptureStopResult> StopRecordWithResultAsync()Public Function StopRecordWithResultAsync() As IAsyncOperation( Of MediaCaptureStopResult )
Returns
Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)
Capabilities
microphone webcam

Events

CameraStreamStateChanged CameraStreamStateChanged CameraStreamStateChanged

Occurs when the state of the camera stream changes.

public : event TypedEventHandler CameraStreamStateChangedpublic event TypedEventHandler CameraStreamStateChangedPublic Event CameraStreamStateChanged
Attributes

Remarks

The state of the camera stream will change when recording is paused or resumed, when the system drops frames for privacy reasons, or when the camera stream is lost.

CaptureDeviceExclusiveControlStatusChanged CaptureDeviceExclusiveControlStatusChanged CaptureDeviceExclusiveControlStatusChanged

Occurs when the exclusive control status of the capture device changes.

public : event TypedEventHandler CaptureDeviceExclusiveControlStatusChangedpublic event TypedEventHandler CaptureDeviceExclusiveControlStatusChangedPublic Event CaptureDeviceExclusiveControlStatusChanged
Attributes
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)
Capabilities
microphone webcam

Remarks

When an app has exclusive control of the capture device, it can modify the settings of the device. An app that does not have exclusive control of the capture device can still capture media, but it can't change the capture settings. Request exclusive control by setting the MediaCaptureInitializationSettings.SharingMode property to ExclusiveControl before passing the structure into InitializeAsync. The call to InitializeAsync will fail if you request exclusive control when another app already has exclusive access to the device. In this case, you can listen for CaptureDeviceExclusiveControlStatusChanged, and if the value of MediaCaptureDeviceExclusiveControlStatusChangedEventArgs.Status is ExclusiveControlAvailable, then you can attempt to reinitialize the MediaCapture with exclusive control.

If the CaptureDeviceExclusiveControlStatusChanged event is raised and the value of MediaCaptureDeviceExclusiveControlStatusChangedEventArgs.Status is SharedReadOnlyAvailable, then another app has acquired exclusive control of the device. In this case, you may want to update your UI to alert the user that another app may adjust the capture device settings.

Failed Failed Failed

Raised when an error occurs during media capture.

public : event MediaCaptureFailedEventHandler Failedpublic event MediaCaptureFailedEventHandler FailedPublic Event Failed
Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
microphone webcam

FocusChanged FocusChanged FocusChanged

Occurs when the capture device changes focus.

public : event TypedEventHandler FocusChangedpublic event TypedEventHandler FocusChangedPublic Event FocusChanged
Attributes

PhotoConfirmationCaptured PhotoConfirmationCaptured PhotoConfirmationCaptured

Occurs when a photo confirmation frame is captured.

public : event TypedEventHandler PhotoConfirmationCapturedpublic event TypedEventHandler PhotoConfirmationCapturedPublic Event PhotoConfirmationCaptured
Attributes

Remarks

The CapturedFrame object passed to this event contains raw pixel data and therefore must be manually copied into the pixel buffer of a bitmap. For information on how to do this, see the Remarks section of the Frame property.

RecordLimitationExceeded RecordLimitationExceeded RecordLimitationExceeded

Occurs when the record limit is exceeded.

public : event RecordLimitationExceededEventHandler RecordLimitationExceededpublic event RecordLimitationExceededEventHandler RecordLimitationExceededPublic Event RecordLimitationExceeded
Attributes

Remarks

If an app receives a RecordLimitationExceeded event, it is expected to finalize the file it is recording. If it does not finalize, the capture engine will stop sending samples to the file that the app was recording to.

In the current release, the record limit is three hours.

See Also

ThermalStatusChanged ThermalStatusChanged ThermalStatusChanged

Occurs when the thermal status of the capture device changes.

public : event TypedEventHandler ThermalStatusChangedpublic event TypedEventHandler ThermalStatusChangedPublic Event ThermalStatusChanged
Attributes

Remarks

Media capture scenarios that are extremely processor-intensive, such as high-resolution, high-frame rate, and real-time image processing can cause the capture hardware to overheat. On devices where the camera driver supports reporting of thermal status, you can check the MediaCaptureThermalStatus property to get the current thermal status of the capture device. You can also subscribe to the ThermalStatusChanged event to receive a notification when the thermal status changes. If the thermal status is Overheated , you should stop the current capture session and save any captured media. Once the thermal status has returned to normal, you can begin capturing again.

See Also