MediaCapture.SetEncodingPropertiesAsync 方法

定義

以非同步方式設定媒體編碼屬性。

public:
 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

參數

mediaStreamType
MediaStreamType

資料流程所代表的媒體資料類型,例如視訊或音訊。

mediaEncodingProperties
IMediaEncodingProperties

媒體編碼的屬性。

encoderProperties
MediaPropertySet

編碼器的屬性。

傳回

用來控制非同步作業的物件。

Windows 需求

應用程式功能
backgroundMediaRecording

備註

這個方法會設定編碼器的編碼屬性,這些編碼器會先處理資料,再傳遞至 要顯示的 CaptureElement 、寫出 至 IRandomAccessStreamStorageFile,或傳遞至自訂媒體接收。 這個方法不會變更資料來源的設定,也就是相機裝置。 可以將編碼屬性設定為相機原生不支援的解析度。 在此情況下, MediaCapture 管線會使用編碼器來執行對要求格式的轉換。 請注意,此轉換會耗用系統資源,而且可能會導致效能不佳或甚至發生錯誤,特別是在具有有限或沒有圖形加速的裝置上。 針對一般案例,建議您選擇最接近所需解析度的相機所支援的解析度。 您可以呼叫 VideoDeviceController.GetAvailableMediaStreamProperties,以取得擷取裝置支援的解析度清單。 如需詳細資訊,請參閱設定 MediaCapture 的格式、解析度和畫面播放速率和相機解析度範例

注意

只有在預設預覽資料流程處於串流狀態時,SetEncodingPropertiesAsync才會成功,也就是成功呼叫StartPreviewAsync之後。 如果在MediaCapture物件透過MediaPlayerElementMediaFrameReaderMediaFrameSource串流視訊時呼叫SetEncodingPropertiesAsync,此呼叫將會失敗。

若要旋轉記錄或預覽資料流程,請使用MF_MT_VIDEO_ROTATION定義的GUID,將中繼資料新增至資料流程。 請注意,此旋轉是由資料流程的取用者執行,例如 CaptureElement 或視訊播放程式應用程式,而資料流程中的實際圖元仍會保留其原始方向。 如需使用相機時處理方向的操作指南,請參閱 使用 MediaCapture 處理裝置方向

若要修改擷取裝置的屬性,請使用 VideoDeviceController.SetMediaStreamPropertiesAsync

適用於

另請參閱