MediaCapture.SetEncodingPropertiesAsync Method


Asynchronously sets the media encoding properties.

 virtual IAsyncAction ^ SetEncodingPropertiesAsync(MediaStreamType mediaStreamType, IMediaEncodingProperties ^ mediaEncodingProperties, MediaPropertySet ^ encoderProperties) = SetEncodingPropertiesAsync;
IAsyncAction SetEncodingPropertiesAsync(MediaStreamType const& mediaStreamType, IMediaEncodingProperties const& mediaEncodingProperties, MediaPropertySet const& encoderProperties);
public IAsyncAction SetEncodingPropertiesAsync(MediaStreamType mediaStreamType, IMediaEncodingProperties mediaEncodingProperties, MediaPropertySet encoderProperties);
function setEncodingPropertiesAsync(mediaStreamType, mediaEncodingProperties, encoderProperties)
Public Function SetEncodingPropertiesAsync (mediaStreamType As MediaStreamType, mediaEncodingProperties As IMediaEncodingProperties, encoderProperties As MediaPropertySet) As IAsyncAction



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


The properties for the media encoding.


The properties for the encoder.


Object that is used to control the asynchronous operation.

Windows requirements

App capabilities


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.


SetEncodingPropertiesAsync will only succeed when the default preview stream is in a streaming state, i.e. after StartPreviewAsync has been called successfully. If SetEncodingPropertiesAsync is called while the MediaCapture object is streaming video from a MediaFrameSource via a MediaPlayerElement or MediaFrameReader, this call will fail.

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.

Applies to

See also