The following code demonstrates recompressing an AVI file to a DV device:
Private Sub cmdAbort_Click()
' if running then abort, else exit program
If ltmmConvertCtrl1.State = ltmmConvert_State_Running Then
ltmmConvertCtrl1.StopConvert
Else
' enable to dump current state
' MsgBox "State = " & CStr(ltmmConvertCtrl1.State) & ", Error = " & CStr(ltmmConvertCtrl1.ConvertError) & ", Progress = " & CStr(ltmmConvertCtrl1.PercentComplete) & "%"
Unload Me
End If
End Sub
Private Sub convert_Complete ()
If ltmmConvertCtrl1.TargetVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent Then
ltmmConvertCtrl1.TargetVCRControl.Stop
End If
' indicate that the conversion has completed
txtStatus = "Conversion completed."
cmdAbort.Caption = "Exit"
End Sub
Private Sub convert_ErrorAbort (ByVal ErrorCode As Long)
If ltmmConvertCtrl1.TargetVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent Then
ltmmConvertCtrl1.TargetVCRControl.Stop
End If
' indicate that a conversion error has occurred
txtStatus = "Error " & CStr(ErrorCode) & ". Conversion aborted."
cmdAbort.Caption = "Exit"
End Sub
Private Sub convert_Progress (ByVal Percent As Long)
' update the percentage text
txtProgress = CStr(Percent) & "%"
End Sub
Private Sub convert_Started ()
' indicate that the conversion has started
txtStatus = "Recompressing " & ltmmConvertCtrl1.SourceFile & " to " & ltmmConvertCtrl1.TargetDevices.Item (ltmmConvertCtrl1.TargetDevices.Selection).FriendlyName
End Sub
Private Sub convert_UserAbort ()
If ltmmConvertCtrl1.TargetVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent Then
ltmmConvertCtrl1.TargetVCRControl.Stop
End If
' indicate that the user aborted
txtStatus = "Conversion Aborted."
cmdAbort.Caption = "Exit"
End Sub
Private Sub Form_Load()
On Error GoTo StartConvertError
' assign the input file
ltmmConvertCtrl1.SourceFile = "c:\source.avi"
' set the format
ltmmConvertCtrl1.TargetFormat = ltmmConvert_TargetFormat_dvsd
' set the output device
ltmmConvertCtrl1.TargetDevices.Selection = 0
If ltmmConvertCtrl1.TargetVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent Then
ltmmConvertCtrl1.TargetVCRControl.Record
End If
cmdAbort.Caption = "Abort"
' uncomment the following line to view the graph with DirectShow GraphEdit
' ltmmConvertCtrl1.EditGraph
' start the conversion
ltmmConvertCtrl1.StartConvert
Exit Sub
StartConvertError:
txtStatus = Err.Description & "... Error " & CStr(Err.Number)
cmdAbort.Caption = "Exit"
End Sub