我正在我的应用程序中录制视频并将其上传到服务器。该应用程序适用于小视频,但如果视频超过 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