LEADTOOLS toolkits support adding subtitles to certain multiplexer output streams.
Currently, the LEAD MKV multiplexer is the only multiplexer supported.
In order to determine if a multiplexer supports subtitles, call the ILMMuxSubtitle interface from the multiplexer in the convert graph. See the following code examples.
// find the convert multiplexer
CComPtr<IUnknown> mux;
m_convert->GetSubObject(ltmmConvert_Object_TargetFilter, &mux);
if(mux)
{
// query IServiceProvider
CComQIPtr<IServiceProvider> sp = mux;
if(sp)
{
// check if the multiplexer subtitle service is available
sp->QueryService(__uuidof(LMMuxSubtitle), __uuidof(ILMMuxSubtitle), (void**) &m_subtitle);
if(m_subtitle)
{
// multiplexer supports subtitles
}
}
}
try
{
// find the convert multiplexer service provider
IServiceProvider sp = (IServiceProvider) convert.GetSubObject(ConvertObject.TargetFilter);
if (sp != null)
{
// check if the multiplexer subtitle service is available
subtitle = (LMSubtitleLib.LMMuxSubtitle)sp.GetService(typeof(LMSubtitleLib.LMMuxSubtitle));
if (subtitle != null)
{
// multiplexer supports subtitles
}
}
}
catch
{
}
Try
' find the convert multiplexer service provider
Dim sp As IServiceProvider = DirectCast(convert.GetSubObject(ConvertObject.TargetFilter), IServiceProvider)
If sp IsNot Nothing Then
' check if the multiplexer subtitle service is available
subtitle = DirectCast(sp.GetService(GetType(LMSubtitleLib.LMMuxSubtitle)), LMSubtitleLib.LMMuxSubtitle)
If subtitle IsNot Nothing Then
// multiplexer supports subtitles
End If
End If
Catch
End Try
Use the following methods and properties to edit subtitles programmatically:
First, enter the edit mode by calling the ILMMuxSubtitle.EnterEdit method.
(Optional) To add a subtitle track from a subtitle file, call the ILMMuxSubtitle.AddTextTrackFromFile method. Currently, LEADTOOLS toolkits only support SubRip (*.srt) formatted files.
(Optional) To remove a previously added track, call the ILMMuxSubtitle.RemoveTrack method.
(Optional) Enumerate the added tracks using the ILMMuxSubtitle.TextTracks list.
Finally, leave the edit mode by calling the ILMMuxSubtitle.LeaveEdit method.
In addition to programmatically editing the tracks directly in the application as described above, supported multiplexers have an additional property page for editing the subtitle track list. Any application that displays the multiplexer property pages can be used to edit the subtitle track list.