Gets or sets a value that determines whether the toolkit is currently caching filters.
public bool UseFilterCache { get; set; }
Public Property UseFilterCache As Boolean
true to enable caching filters; otherwise, it is false to disable caching filters. The default value is false.
Setting this property to true will enable caching for the current target format object. The target format object is the format that will be used for the converted file. This includes the file format, any special settings used by the format, which audio/video codec is used for the conversion and any special settings used by the codec. Additionally, setting this property to true will force the toolkit to preload and reuse the filters specified for the particular format. If an object isn't currently created, one will be created. Setting the value of this property to false will disable the caching for the current target format object. If an object currently exists, it will destroy it.
Use the TargetFormat.GetCacheObject method to retrieve the caching filter object. Use the TargetFormat.ShowCacheDialog method to display a specific property dialog for the caching filter.
Use the TargetFormat.HasCacheDialog method to query whether the specified property dialog for the caching filter is available.
using Leadtools;
using Leadtools.Multimedia;
using LeadtoolsMultimediaExamples.Fixtures;
public bool _result = false;
public CaptureCtrlForm _form = new CaptureCtrlForm();
public LMMpg2MxTLib.LMMpg2MxT _pMpgMux;
// This example will show you the correct way to set up a muxer's properties during capture
// Normally, the muxer is added only after the capture graph has been build with ReadyCapture or StartCapture
// But at this point, the graph is in running mode, so some muxer operations might fail
// If you need to make changes to the muxer in stopped state (like adding KLV data stream, for example),
// then you need to change the muxer before the graph is fully built. You can do so by instructing the toolkit
// to cache the target filters by setting the TargetFormat.UseFilterCache property to true
// In this situation, the filters used to implement a certain target format are created and used whenever
// you set that target format.
//
// This example will show you how to add KLV data to a MPEG-2 Transport Stream in a capture situation.
public void UseFilterCacheExample()
{
// reference the capture control
CaptureCtrl capturectrl = _form.CaptureCtrl;
string outFile = Path.Combine(LEAD_VARS.MediaDir, "CaptureKLV.mpg");
try
{
// select the capture device
capturectrl.VideoDevices.Selection = 0; /* Use a different video device if you want */
/* capturectrl.Preview = true; -- enable this if you want */
/* set the video compressor (only if the capture device is not already capturing compressed video) */
capturectrl.VideoCompressors.Mpeg2.Selected = true;
// set the target output file
capturectrl.TargetFile = outFile;
// subscribe to the started event
capturectrl.Started += new System.EventHandler(this.CaptureCtrl_Started);
// just 10 seconds of capture time
capturectrl.TimeLimit = 10;
capturectrl.UseTimeLimit = true;
// subscribe to the complete event
capturectrl.Complete += new EventHandler(CaptureCtrl_Complete);
// 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
capturectrl.TargetFormats[Leadtools.Multimedia.TargetFormatType.MPEG2Transport].UseFilterCache = true;
capturectrl.TargetFormat = Leadtools.Multimedia.TargetFormatType.MPEG2Transport;
_pMpgMux = (LMMpg2MxTLib.LMMpg2MxT)capturectrl.TargetFormats[Leadtools.Multimedia.TargetFormatType.MPEG2Transport].GetCacheObject(TargetFormatObject.Mux);
if (_pMpgMux != null)
{
_pMpgMux.PrivateDataPID = 0x70;
_pMpgMux.PrivateDataFormatID = 0x41564c4b;
_pMpgMux.EnablePrivateData = true;
}
// start capture
capturectrl.StartCapture(Leadtools.Multimedia.CaptureMode.Video);
_result = true;
}
catch (Exception)
{
_result = false;
}
}
private void WriteKLVData(LMMpg2MxTLib.LMMpg2MxT pMpgMux)
{
// get the current time since Jan 1, 1970
TimeSpan basetime = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0);
// get the number of microseconds since Jan 1, 1970
Int64 timestamp = (Int64)basetime.TotalSeconds * 1000000;
// do not really need to do this, since I am writing only one item
pMpgMux.KlvBuilder.Clear();
// write the UDS timestamp (number of microseconds since Jan 1, 1970)
pMpgMux.KlvBuilder.InsertUInt64(-1, "06 0E 2B 34 01 01 01 03 07 02 01 01 01 05 00 00", (ulong)timestamp);
// write one KLV data at the beginning
pMpgMux.WritePrivateData((int)LMMpg2MxTLib.Mpg2MxT_WriteFlags.Mpg2MxT_WriteFlag_PTSValid |
(int)LMMpg2MxTLib.Mpg2MxT_WriteFlags.Mpg2MxT_WriteFlag_PTSInSeconds,
0.0, pMpgMux.KlvBuilder.GetData(),
-1);
// close the stream
pMpgMux.ClosePrivateData();
}
private void CaptureCtrl_Started(object sender, EventArgs e)
{
WriteKLVData(_pMpgMux);
}
private void CaptureCtrl_Complete(object sender, EventArgs e)
{
// set result
_result = true;
}
static class LEAD_VARS
{
public const string MediaDir = @"C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 20\Media";
}
Imports Leadtools
Imports Leadtools.Multimedia
Imports LeadtoolsMultimediaExamples.Fixtures
Public _result As Boolean = False
Public _form As CaptureCtrlForm = New CaptureCtrlForm()
Public _pMpgMux As LMMpg2MxTLib.LMMpg2MxT
' This example will show you the correct way to set up a muxer's properties during capture
' Normally, the muxer is added only after the capture graph has been build with ReadyCapture or StartCapture
' But at this point, the graph is in running mode, so some muxer operations might fail
' If you need to make changes to the muxer in stopped state (like adding KLV data stream, for example),
' then you need to change the muxer before the graph is fully built. You can do so by instructing the toolkit
' to cache the target filters by setting the TargetFormat.UseFilterCache property to true
' In this situation, the filters used to implement a certain target format are created and used whenever
' you set that target format.
' This example will show you how to add KLV data to a MPEG-2 Transport Stream in a capture situation.
Public Sub UseFilterCacheExample()
' reference the capture control
Dim capturectrl As CaptureCtrl = _form.CaptureCtrl
Dim outFile As String = Path.Combine(LEAD_VARS.MediaDir, "CaptureKLV.mpg")
Try
' select the capture device
capturectrl.VideoDevices.Selection = 0 ' Use a different video device if you want
' capturectrl.Preview = true; -- enable this if you want
' set the video compressor (only if the capture device is not already capturing compressed video)
capturectrl.VideoCompressors.Mpeg2.Selected = True
' set the target output file
capturectrl.TargetFile = outFile
' subscribe to the compete event
AddHandler capturectrl.Started, AddressOf CaptureCtrl_Started
' just 10 seconds of capture time
capturectrl.TimeLimit = 10
capturectrl.UseTimeLimit = True
' subscribe to the compete event
AddHandler capturectrl.Complete, AddressOf CaptureCtrl_Complete
' 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
capturectrl.TargetFormats(Leadtools.Multimedia.TargetFormatType.MPEG2Transport).UseFilterCache = True
capturectrl.TargetFormat = Leadtools.Multimedia.TargetFormatType.MPEG2Transport
_pMpgMux = DirectCast(capturectrl.TargetFormats(Leadtools.Multimedia.TargetFormatType.MPEG2Transport).GetCacheObject(TargetFormatObject.Mux), LMMpg2MxTLib.LMMpg2MxT)
If _pMpgMux IsNot Nothing Then
_pMpgMux.PrivateDataPID = &H70
_pMpgMux.PrivateDataFormatID = &H41564C4B
_pMpgMux.EnablePrivateData = True
End If
' start capture
capturectrl.StartCapture(Leadtools.Multimedia.CaptureMode.Video)
_result = True
Catch generatedExceptionName As Exception
_result = False
End Try
End Sub
Private Sub WriteKLVData(ByVal pMpgMux As LMMpg2MxTLib.LMMpg2MxT)
' get the current time since Jan 1, 1970
Dim basetime As TimeSpan = DateTime.UtcNow - New DateTime(1970, 1, 1, 0, 0, 0)
' get the number of microseconds since Jan 1, 1970
Dim timestamp As Int64 = CLng(basetime.TotalSeconds) * 1000000
' don't really need to do this, since I am writing only one item
pMpgMux.KlvBuilder.Clear()
' write the UDS timestamp (number of microseconds since Jan 1, 1970)
pMpgMux.KlvBuilder.InsertUInt64(-1, "06 0E 2B 34 01 01 01 03 07 02 01 01 01 05 00 00", CULng(timestamp))
' write one KLV data at the beginning
pMpgMux.WritePrivateData(CInt(LMMpg2MxTLib.Mpg2MxT_WriteFlags.Mpg2MxT_WriteFlag_PTSValid) _
Or CInt(LMMpg2MxTLib.Mpg2MxT_WriteFlags.Mpg2MxT_WriteFlag_PTSInSeconds),
0.0, pMpgMux.KlvBuilder.GetData(), -1)
' close the stream
pMpgMux.ClosePrivateData()
End Sub
Public Sub CaptureCtrl_Started(ByVal sender As Object, ByVal e As EventArgs)
WriteKLVData(_pMpgMux)
End Sub
Public Sub CaptureCtrl_Complete(ByVal sender As Object, ByVal e As EventArgs)
' set result
_result = True
End Sub
Public NotInheritable Class LEAD_VARS
Public Const MediaDir As String = "C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 20\Media"
End Class
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document