минимизация размера видеофайла при захвате видео в Windows Phone 8

Я записываю видео в своем приложении и загружаю его на сервер. Приложение отлично работает с небольшими видео, но если видео длиннее 10 секунд, размер видео становится очень большим, и приложение вылетает.

Как уменьшить размер видео? Могу ли я установить разрешение? Могу ли я также сжать видео?

Что еще вы порекомендуете мне сделать, чтобы видео не было гигантским?

Вот мой код:

Public Sub InitializeVideoRecorder()
        If captureSource Is Nothing Then
            ' Create the VideoRecorder objects.
            captureSource = New CaptureSource()
            fileSink = New FileSink()

            videoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice()

            ' Add eventhandlers for captureSource.
            AddHandler captureSource.CaptureFailed, AddressOf OnCaptureFailed

            ' Initialize the camera if it exists on the device.
            If videoCaptureDevice IsNot Nothing Then
                ' Create the VideoBrush for the viewfinder.
                videoRecorderBrush = New VideoBrush()
                videoRecorderBrush.SetSource(captureSource)

                ' Display the viewfinder image on the rectangle.
                viewfinderRectangle.Fill = videoRecorderBrush

                ' Start video capture and display it on the viewfinder.
                captureSource.Start()

                ' Set the button state and the message.
                UpdateUI(ButtonState.Initialized, "")
            Else
                ' Disable buttons when the camera is not supported by the device.
                UpdateUI(ButtonState.CameraNotSupported, "A camera is not supported on this device.")
            End If
        End If
End Sub

person Suzan Balaa    schedule 05.07.2013    source источник


Ответы (1)


Чтобы уменьшить размер видео, мы можем сделать разрешение максимально низким. Код

VideoCaptureDevice webcam = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();

 int videoformatcount = webcam.SupportedFormats.Count(); //We will get the avilable video format

  if (videoformatcount > 0)
             {
                var Temp = webcam.SupportedFormats;

                VideoFormat objVideoFormat = Temp[videoformatcount - 1];

                webcam.DesiredFormat = new VideoFormat(PixelFormatType.Format8bppGrayscale, objVideoFormat.PixelWidth, objVideoFormat.PixelHeight, 1);
            }

captureSource.VideoCaptureDevice = webcam;

Это поможет вам. Видео должно быть в очень низком разрешении (в наличии).

person Vicky    schedule 19.07.2013