视频采集: 保存一个有时间限制的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.