Public Sub UseFilterCache()
On Error
GoTo ErrorHandle
Dim
devices As
ltmmDevices
Dim
compressors As ltmmCompressors
Dim
pformats As
ltmmTargetFormats
Dim
pformat As
ltmmTargetFormat
Dim
pMpgMux As
LMMpg2MxTLib.LMMpg2MxT
Dim
lIndex As
Long
'
get the video devices collection
Set
devices = LTMMCapture.VideoDevices
'
select the capture device
devices.Selection
= 1 ' Use a different video device if you want
'
get the video compressors collection
Set
compressors = LTMMCapture.VideoCompressors
'
find mpeg2 compressor
lIndex
= compressors.Find("@device:sw:{33D9A760-90C8-11D0-BD43-00A0C911CE86}\LEAD
MPEG2 Encoder (3.0)")
If
(lIndex = -1) Then
'
failed. exit sub
Exit
Sub
End
If
'
set the video compressor (only if the capture device is not already capturing
compressed video)
compressors.Selection
= lIndex
'
set the target output file
LTMMCapture.TargetFile
= "c:\CaptureKLV.avi"
'
just 10 seconds of capture time
LTMMCapture.UseTimeLimit
= True
LTMMCapture.TimeLimit
= 10
'
get the target formats collection
Set
pformats = LTMMCapture.TargetFormats
'
get the MPEG2Transport target format object
Set
pformat = pformats.Item(ltmmCapture_TargetFormat_MPEG2_TRANSPORT)
'
IN a capture situation
'
in order to get the mux in a capture situation, set the UseFilterCache
property for the target format to TRUE
'
This tells the toolkit to create a Mux object and keep it around when
building or rebuilding graphs
'
enable filter cache
pformat.UseFilterCache
= True
'
select MPEG2Transport target format
LTMMCapture.TargetFormat
= ltmmCapture_TargetFormat_MPEG2_TRANSPORT
'
get the multiplexer object for this format
Set
pMpgMux = pformat.GetCacheObject(ltmmTargetFormat_Object_Mux)
If
(Not pMpgMux Is Nothing) Then
pMpgMux.PrivateDataPID
= &H70
pMpgMux.PrivateDataFormatID
= &H41564C4B
pMpgMux.EnablePrivateData
= True
End
If
'
start capture
LTMMCapture.StartCapture
(ltmmCapture_Mode_Video)
ErrorHandle:
MsgBox
Err.Description
End Sub