VB.NET Developer Getting Started
|
VB.NET Developer Getting Started |
1. Launch Visual Studio 2010 or another version of Visual Studio. Select Visual Basic, Select Windows Form Application.
|
2. In the Solution Explorer, right-click References, and then click Add Reference.
3. Select Browse tab, Navigate to the extracted Video Capture .Net SDK for REDIST folder, select x86 or x64 folder (depending on the target platform of your application ) , open it, and then double-click Viscomsoft.VideoCapture.dll
4. In the Solution Explorer, right-click on your project, and then click Add - Existing Item ....
5. In Add Existing Item dialog, Select All Files (*.*) in combo box. Navigate to the extracted Video Capture .Net SDK for REDIST folder, select x86 or x64 folder (depending on the target platform of your application ), open it, and then double-click Viscomsoft.VideoCapture.Foundation.dll
6. You will see Viscomsoft.VideoCapture.dll and Viscomsoft.VideoCapture.Foundation.dll in Solution Explorer.
7. Select Viscomsoft.VideoCapture.Foundation.dll , In the Properties window, Change the Copy to Output Directory property to Copy if newer.
8. At the top of the Form1.vb file, add the following to the using directives
already in the class:
Imports Viscomsoft.VideoCapture
9. The following code bit presents the video capture sdk initialization:
Public Class Form1
Public _capture As VideoCapture
Public _devices As Devices
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
_capture = New VideoCapture()
_capture.Initialize()
_devices = New Devices()
_devices.Refresh()
10. double click Form1.vb in the Solution Explorer and Drag the PictureBox to form.
11. After _devices.Refresh() add the following code use PictureBox for preview window, set the Preview Mode, selected first video device and audio device and use first video resolution. If the Start() return 1 , it mean successful for preview video.
_capture.Window = PictureBox1.Handle
_capture.Mode = VideoCapture.CaptureMode.Preview
_capture.VideoDevice = _devices.VideoDevices.Item(0)
_capture.VideoDevice.SelectedResolution = _capture.VideoDevice.VideoResolutions.Item(0)
_capture.AudioDevice = _devices.AudioDevices.Item(0)
Dim iResult As Integer = _capture.Start()
12. double click Form1.vb in the Solution Explorer and Drag the two button to form . For button1, In the Properties window, change the Text to "Capture to MP4"
For button2, In the Properties window, change the Text to "Stop"
13. In button1 click event, add the following code, set the Capture Mode, selected first video device and audio device and use first audio bitrate and video resolution. If the Start() return 1 , it mean successful for capture to video. make sure temp folder is existing.
_capture.Stop()
_capture.Window = PictureBox1.Handle
_capture.Mode = VideoCapture.CaptureMode.Capture
_capture.Encoder.OutputType = OutputType.MP4
_capture.Encoder.H264Profile = H264Profile.Base
_capture.OutputFile = "c:\temp\test1.mp4"
Dim audiodevice As AudioDevice = _devices.AudioDevices.Item(0)
_capture.AudioDevice = audiodevice
Dim lstbitrates As New Generic.List(Of Integer)
lstbitrates = _capture.Encoder.getSupportedAudioBitrates(audiodevice.AudioSamplingRates.Item(0).SampleRate, audiodevice.AudioSamplingRates.Item(0).Channels)
_capture.Encoder.AudioBitrate = lstbitrates.Item(0)
_capture.VideoDevice = _devices.VideoDevices.Item(0)
_capture.Encoder.VideoBitrate = 1000000
_capture.VideoDevice.SelectedResolution = _capture.VideoDevice.VideoResolutions.Item(0)
Dim iResult As Integer = _capture.Start()
14. In button2 click event, add the following code.
_capture.Stop()
15. Press F5 to Run the project, click Capture to MP4 video, then click Stop button to stop the capturing.