視頻採集: 保存一個有時間限制的AVI文件

讲解如何使用IC Imaging control把一個圖像數據流保存為一個確定時間長度的AVI文件。
語言:Visual Basic 6
版本:3.0.3
发布于:2005年4月7日
作者:IC Imaging Control 技術支持部
需求:IC Imaging Control >2.1
由WDM數據流類驅動程序驅動的相機、視頻轉換器或圖像採集卡

下面的程序演示的是如何使用IC Imaging control創建一個確定時間長度的AVI文件。

示例程序如圖所示:

The Testdialog of IC Imaging Control,

程序首先調用一個內置對話框(.ShowDeviceSettingsDialog)用於選擇設備。 而後使用.LiveStart語句顯示設備傳來的實時畫面:

Private Sub Form_Load()

    ICImagingControl1.ShowDeviceSettingsDialog

    If Not ICImagingControl1.DeviceValid Then
        Unload Me
        Exit Sub
    End If

    ICImagingControl1.LiveStart

End Sub

用戶點擊"Start Capture"後,程序停止圖像數據流(.LiveStop),開始錄製 AVI文件(.AviStartCapture)、開啟計時器(Timer1.Enabled = True):

Private Sub cmdStartCapture_Click()

    ICImagingControl1.LiveStop
    ICImagingControl1.AviStartCapture "video.avi", "DV Video Encoder"

    recordedTime = 0
    Timer1.Enabled = True
    cmdStartCapture.Enabled = False

End Sub

AVI文件的錄製由一個計時器timer控制,通過循環調用Timer1,事件處理程序 Timer1_Timer()讀取用戶定義的錄製時間(txtStop.Text),顯示已錄製時間長度 (lblRecorded.Caption),在到達錄製時間後停止錄像 (.AviStopCapture),而後重新現場視頻畫面.LiveStart):

Dim recordedTime As Long

Private Sub Timer1_Timer()

    recordedTime = recordedTime + 1

    lblRecorded.Caption = "Recorded: " & recordedTime & " s"

    Dim stopTime As Long
    stopTime = txtStop.Text

    If recordedTime >= stopTime Then
        Timer1.Enabled = False

        ICImagingControl1.AviStopCapture
        ICImagingControl1.LiveStart

        cmdStartCapture.Enabled = True
    End If

End Sub

相關源代碼示例

責任聲明
IC Imaging Control源代碼庫中的所有代碼均只用於教學目的,The Imaging Source Europe GmbH作為IC Imaging Control的開發製造商,不對任何由於使用本文或其中源代碼所產生的後果承擔責任。

该网站为The Imaging Source网络的一部分。其它的站点包括 公司, Imaging, 天文相機, Astronomy Cameras Blog, Blog caméras d'astronomie, 天文相機有獎競答, TX Text Control, LiveDocx, phpLiveDocxForum.