How to record video using AudioVideoCptureDevice in WP8

情到浓时终转凉″ 提交于 2019-12-01 22:22:26

For the problem of Displaying a Thumbnail of the video recording...there is an event called PreviewFrameAvailable on the AudioVideoCaptureDevice. I think if you setup this event handler it will tell you when the data is available to get a preview (image/thumbnail) of the video.

There are also 3 methods for grabbing a byte array of a preview image (GetPreviewBufferARGB, GetPreviewBufferY, GetPreviewBufferYCbCr). All three of these methods return a byte[] of the pixel data for the image in the corresponding format (ex: GetPreviewBufferARGB should return the raw bytes of a raw bitmap in ARGB format). After getting the byte array of the preview data you should be able to encode it as a PNG or JPEG or whatever compressed image format you prefer. Best of luck.

I solved the problem of mirror inverted video recording through Front-Camera:

the one line that solved my problem is:

//here videoCapture is AudioVideoCaptureDevice object

videoCapture.SetProperty(KnownCameraGeneralProperties.EncodeWithOrientation, -90);

Full Code:

XAML code

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

BackEnd C# code

    // 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);

This piece of code helped me after tens of efforts..!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!