Vb.net 在windows phone 8中捕获视频时最小化视频文件大小
我正在应用程序中录制视频并将其上载到服务器。对于小视频,该应用程序运行良好,但如果视频长度超过10秒,视频大小将变得非常大,应用程序将崩溃 如何最小化视频的大小?我可以设定决议吗?我也可以压缩视频吗 你还建议我做什么来确保视频不会太大 这是我的密码:Vb.net 在windows phone 8中捕获视频时最小化视频文件大小,vb.net,video,windows-phone-8,compression,resolution,Vb.net,Video,Windows Phone 8,Compression,Resolution,我正在应用程序中录制视频并将其上载到服务器。对于小视频,该应用程序运行良好,但如果视频长度超过10秒,视频大小将变得非常大,应用程序将崩溃 如何最小化视频的大小?我可以设定决议吗?我也可以压缩视频吗 你还建议我做什么来确保视频不会太大 这是我的密码: Public Sub InitializeVideoRecorder() If captureSource Is Nothing Then ' Create the VideoRecorder objects
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
为了减少视频大小,我们可以使分辨率尽可能低
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;
这会对你有所帮助。视频的分辨率必须非常低(可用)