我通过以下方式解决了镜像倒置视频录制的问题Front-Camera
:
解决我的问题的一行是:
//here videoCapture is AudioVideoCaptureDevice object
videoCapture.SetProperty(KnownCameraGeneralProperties.EncodeWithOrientation, -90);
完整代码:
XAML 代码
<Canvas x:Name="CanvasLayoutRoot" RenderTransformOrigin="0.5 0.5"
Width="{Binding ActualHeight, ElementName=LayoutRoot}"
Height="{Binding ActualWidth, ElementName=LayoutRoot}"
Margin="-160 0 0 0">
<Canvas.RenderTransform>
<RotateTransform x:Name="rt" />
</Canvas.RenderTransform>
<Canvas.Background>
<VideoBrush x:Name="videoBrush" />
</Canvas.Background>
</Canvas>
后端 C# 代码
// in any specific method or event handler write
// the below code while initializing the Front camera
private AudioVideoCaptureDevice videoCapture = await AudioVideoCaptureDevice.OpenAsync(CameraSensorLocation.Front, new Windows.Foundation.Size(640, 480));
videoCapture.SetProperty(KnownCameraGeneralProperties.EncodeWithOrientation, -90);
rt.Angle = -90;
videoBrush.SetSource(videoCapture);
经过数十次努力,这段代码帮助了我..!