Creating DVD Images Example for Visual Basic
' The following code demonstrates how to create DVD images using the
LEAD Multimedia toolkit:
Option Explicit
Dim LTDVDWriter As LTDVDWriter
Dim Index As Integer
Dim State As Long
Private Declare Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
' set up the converter:
ltmmConvertCtrl1.TargetFormat = ltmmConvert_TargetFormat_DVD
Index = ltmmConvertCtrl1.VideoCompressors.Find("@device:sw:{33D9A760-90C8-11D0-BD43-00A0C911CE86}\LEAD
MPEG2 Encoder Also known as compressor Also known as an encoder, this is a module or algorithm to compress data. Playing that data back requires a decompressor, or decoder., this is a module or algorithm to compress data. Playing that data back requires a decompressor, or decoder Also known as a decompressor, this is a module or algorithm to decompress data.. (2.0)")
ltmmConvertCtrl1.VideoCompressors.Selection = Index
Index = ltmmConvertCtrl1.AudioCompressors.Find("@device:sw:{33D9A761-90C8-11D0-BD43-00A0C911CE86}\LEAD
MPEG Audio Encoder (2.0)")
ltmmConvertCtrl1.AudioCompressors.Selection = Index
Form1.MousePointer = 11 ' busy
' 1- Create a DVD image with 1 title that contains 1 chapter:
ltmmConvertCtrl1.sourcefile = "c:\MyVideos\DaDa_CMP.avi"
ltmmConvertCtrl1.TargetFile = "c:\MyVideos\DVDImage1"
ltmmConvertCtrl1.StartConvert
' Wait for the conversion to finish. You can use a window to receive notifications
While ltmmConvertCtrl1.State <> ltmmConvert_State_Stopped
DoEvents
Wend
' Done
ltmmConvertCtrl1.ResetTarget
ltmmConvertCtrl1.ResetSource
' 2- Create a DVD image with 1 title that contains 2 chapters:
ltmmConvertCtrl1.sourcefile = "c:\MyVideos\DaDa_CMP.avi"
ltmmConvertCtrl1.TargetFile = "c:\MyVideos\DVDImage2"
' Retrieve the DVD Writer object
Set LTDVDWriter = ltmmConvertCtrl1.GetSubObject(ltmmConvert_Object_Sink)
' Set the DVD temporary files folder
LTDVDWriter.TempPath = "C:\Temp"
' Set the TitleBreak property to FALSE.
' This will prevent the title from being written immediately after the conversion
LTDVDWriter.RemoveAllMenuTitles
LTDVDWriter.TitleBreak = False
' Get the menu title The name for a group of related video files (called "Chapters") on your DVD. For example, for a DVD called "My Summer Vacation," you might have the titles "Water Skiing," "New Friends," and "Hiking." For each of those titles, you might have one or more different video files. count
If DVDWriter.MenuTitleCount
> 0 Then
For i = 1 To DVDWriter.MenuTitleCount
strMenuName = DVDWriter.GetMenuTitle(i)
Next i
' Remove all menu titles
VDWriter.RemoveAllMenuTitles
End If
DVDWriter.AddMenuTitle
"Title1", -1
' Create the first chapter
ltmmConvertCtrl1.StartConvert
' Wait for the conversion to finish. You can use a window to receive notifications
While ltmmConvertCtrl1.State <> ltmmConvert_State_Running
DoEvents
Wend
' You can change the source file before this step.
' This demonstration code uses the same file for all chapters.
' Create chapter 2.
ltmmConvertCtrl1.StartConvert
' Wait for the conversion to finish. You can use a window to receive notifications
While ltmmConvertCtrl1.State <> ltmmConvert_State_Stopped
DoEvents
Wend
' Find the total number of bytes written to disk
lBytes = DVDWriter.GetBytesWritten(lHigh)
' Close the title
LTDVDWriter.TitleBreak = True
' Done
ltmmConvertCtrl1.ResetTarget
ltmmConvertCtrl1.ResetSource
Set LTDVDWriter = Nothing
' 3- Create a DVD image with 2 titles, each contains 2 chapters:
ltmmConvertCtrl1.sourcefile = "c:\MyVideos\DaDa_CMP.avi"
ltmmConvertCtrl1.TargetFile = "c:\MyVideos\DVDImage3"
' Retrieve the DVD Writer object
Set LTDVDWriter = ltmmConvertCtrl1.GetSubObject(ltmmConvert_Object_Sink)
' Set the DVD temporary files folder
LTDVDWriter.TempPath = "C:\Temp"
' Set menulesstitleplay
LTDVDWriter.MenulessTitlePlay
= gbMenuLessTitlePlay
' Set the TitleBreak property to FALSE.
' This will prevent the title from being written immediately after the conversion
LTDVDWriter.TitleBreak = False
'Write the first chapter in the first title
ltmmConvertCtrl1.StartConvert
' Wait for the conversion to finish. You can use a window to receive notifications
While ltmmConvertCtrl1.State <> ltmmConvert_State_Stopped
DoEvents
Wend
' Write the second chapter in the first title
' You can change the source file before this step:
this demonstration code uses the same file for all chapters.
ltmmConvertCtrl1.StartConvert
While ltmmConvertCtrl1.State <> ltmmConvert_State_Stopped
DoEvents
Wend
' Prepare for the second title
' Set the TitleBreak property to TRUE, so the the current title can be flushed
LTDVDWriter.TitleBreak = True
' Set the TitleBreak property to FALSE.
' This will prevent the title from being written immediately after the conversion
LTDVDWriter.TitleBreak = False
' Disable Overwrite so the title will be appended to an existing dvd image
LTDVDWriter.Overwrite = False
' Write the first chapter in the second title
ltmmConvertCtrl1.StartConvert
' Wait for the conversion to finish. You can use a window to receive notifications
While ltmmConvertCtrl1.State <> ltmmConvert_State_Stopped
DoEvents
Wend
' Write the second chapter in the second title
ltmmConvertCtrl1.StartConvert
' Wait for the conversion to finish. You can use a window to receive notifications
While ltmmConvertCtrl1.State <> ltmmConvert_State_Stopped
DoEvents
Wend
' Close the second title
LTDVDWriter.TitleBreak = True
' Check whether a menu is to be created and whether to
add a background menu
' Get Number of menu titles
lMenuTitleCount = LTDVDWriter.MenuTitleCount
If (gbWriteMenu And (gStrMenuBackground <> ""))
Then
' write menu
' this will make the next conversion
a menu conversion
DVDWriter.TitleMenu
= True
' Enable or Disable Loop Menu
DVDWriter.MenuLoop
= Main.gbLoopMenu
' Add the resize filter:
If AddProcessor("@device:sw:{E526D606-22E7-494C-B81E-AC0A94BFE603}\{E2B7DCA5-38C5-11D5-91F6-00104BDB8FF9}")
= False Then
MsgBox "Can't
find the LEAD Video Resize Filter"
Else
If gVideoFormat =
MPEG2_VF_NTSC Then '
NTSC
lWidth
= gNTSCSizes(Main.glSelNTSCSize).lWidth
lHeight
= gNTSCSizes(Main.glSelNTSCSize).lHeight
Else ' PAL
lWidth
= gPALSizes(Main.glSelPALSize).lWidth
lHeight
= gPALSizes(Main.glSelPALSize).lHeight
End If
ConfigureResizeFilter
lWidth, lHeight, Main.glResizeMethod
End If
ltmmConvertCtrl1.sourcefile
= Main.gStrMenuBackground
' write the menu
ltmmConvertCtrl1.StartConvert
While ltmmConvertCtrl1.State
<> ltmmConvert_State_Stopped
If gbStop = True Then
txtStatus.Text =
"Image authoring stopped..."
Exit Sub
End If
DoEvents
Wend
If gbStop = True Then
txtStatus.Text =
"Image authoring stopped..."
End If
DVDWriter.TitleMenu = False
End If
' Remove the menu title
DVDWriter.RemoveMenuTitle
0
' restore the overwrite property
LTDVDWriter.Overwrite = True
' Done
Set LTDVDWriter = Nothing
ltmmConvertCtrl1.ResetTarget
ltmmConvertCtrl1.ResetSource
Form1.MousePointer = 0
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
If ltmmConvertCtrl1.State <> ltmmConvert_State_Stopped Then
ltmmConvertCtrl1.StopConvert
If Not LTDVDWriter Is Nothing Then
LTDVDWriter.TitleBreak = True
LTDVDWriter.Overwrite = True
Set LTDVDWriter = Nothing
End If
End If
End Sub