SubtitleCreator Subtitle Filter Documentation
SubtitleCreator Subtitle Filter Documentation
Programmer’s Guide
Version 0.5
By Manusse (manusseATusers.sourceforge.net)
1 Introduction ____________________________________________________________ 3
2 Filter characteristics _____________________________________________________ 3
2.1 Filter name_______________________________________________________________ 3
2.2 Filter properties __________________________________________________________ 3
2.3 Filter interface____________________________________________________________ 3
2.3.1 Description of each method ____________________________________________________ 4
2.3.1.1 SetSubtitleInfo______________________________________________________________ 4
2.3.1.2 SCmalloc __________________________________________________________________ 5
2.3.1.3 GetVersion ________________________________________________________________ 5
2.3.1.4 DisplayOsd ________________________________________________________________ 5
2.3.1.5 GetVideoProps _____________________________________________________________ 5
2.3.1.6 ScreenCopy ________________________________________________________________ 5
2.3.2 Example of instanciation with a C# application ____________________________________ 5
2.4 Filter connection __________________________________________________________ 5
2.5 Typical filter graph________________________________________________________ 6
2.6 Known incompatibility _____________________________________________________ 6
3 Conclusion _____________________________________________________________ 6
I thought it would be interesting if SubtitleCreator would also allow to preview the subtitles on top of the DVD
video.
As subtitlecreator was already displaying the video, I would just have to look at how to overlay some bitmap on
top of it.
After some investigations, it appeared that a DirectShow filter could be one solution. As I was interested in
learning this technology, and as Erik Vullings, the author of SubtitleCreator was interested I started learning
about it.
2 Filter characteristics
// {98D7BAC8-96D6-427f-A73F-1B7364A59D7D}
DEFINE_GUID(CLSID_SCSubtitleFilter,
// {EB4D324F-2CF6-4dbb-A55F-FAB59CB0F7F2}
DEFINE_GUID(CLSID_SCSubtitleFilterPropertyPage,
0xeb4d324f, 0x2cf6, 0x4dbb, 0xa5, 0x5f, 0xfa, 0xb5, 0x9c, 0xb0, 0xf7,
0xf2);
// {AA11C9FC-FB79-4e28-A33F-69C0C8AEE061}
DEFINE_GUID(IID_SCSubtitleFilter,
0xaa11c9fc, 0xfb79, 0x4e28, 0xa3, 0x3f, 0x69, 0xc0, 0xc8, 0xae, 0xe0,
0x61);
public:
virtual HRESULT STDMETHODCALLTYPE SCmalloc(
int Nbbytes) = 0;
public:
virtual HRESULT STDMETHODCALLTYPE GetVersion(void) = 0;
public:
virtual HRESULT STDMETHODCALLTYPE DisplayOsd(
int ON_OFF) = 0;
public:
virtual HRESULT STDMETHODCALLTYPE GetVideoProps(void) = 0;
public:
virtual HRESULT STDMETHODCALLTYPE ScreenCopy(
char *pFileName) = 0;
2.3.1.1 SetSubtitleInfo
This method is used by the application to send a bitmap to the filter.
Xpos : The horizontal position of the filter relative to the video window
Ypos : The vertical position of the filter relative to the video window
XimgSize : The horizontal dimension of the bitmap in pixels. This dimension MUST be a multiple of 8.
YimgSize : The vertical dimension of the bitmap in pixels This dimension MUST be a multiple of 2.
pRGBABuffer : A byte pointer that addresses the first byte of the bitmap to be displayed. The data are arranged
as Blue, Green, Red1, Alpha (transparency). If Alpha is 0, then it is a transparent pixel, else whatever the value, it
is an opaque one.
Returns 0 if OK.
1
In version 0.4, pixel was expected as Red, Green, Blue, Alpha which was not compatible with C# default mode.
Was changed after a request from EV.
2.3.1.3 GetVersion
Returns as an integer the address of a string holding the version information of the filter. (This is an ANSI string,
not UNICODE)
Typically : 0.5
2.3.1.4 DisplayOsd
Not used for the moment.
2.3.1.5 GetVideoProps
Returns as an integer the address of a buffer holding the width, then the height (integers) of the actual used video
buffer. This information can be used to stretch the bitmap if needed.
2.3.1.6 ScreenCopy
This function will create a bitmap holding a screencopy of the video including the overlaid bitmap. The filename
must be passed as a parameter. This methods will produce a bmp file only with the debug version of the filter.
pFileName : A byte pointer that holds an ANSI string with the bmp filename. (Should end by .bmp)
[ComImport,
Guid("98D7BAC8-96D6-427f-A73F-1B7364A59D7D")]
public class SCSubtitleFilter
{
}
[ComVisible(true), ComImport,
Guid("AA11C9FC-FB79-4e28-A33F-69C0C8AEE061"),
InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
public interface ISCSubtitleFilter
{
[PreserveSig]
int SetSubtitleInfo(int Xpos, int Ypos, int XImgSize, int YImgSize, IntPtr pRGBABuffer);
[PreserveSig]
int SCmalloc( int Nbbytes );
[PreserveSig]
int GetVersion();
[PreserveSig]
int DisplayOsd( int ON_OFF );
[PreserveSig]
int GetVideoProps();
[PreserveSig]
int ScreenCopy(IntPtr pFileName);
}
It will refuse connections with inputs of other types. Its output will be of the same type as its input.
The Video Decoders that are supposed to work quite well with this filter are :
The Video Decoders that are (at present) not compatible with the filter :
3 Conclusion
Feel free to use this filter in your applications as it is open source freeware. You need my authorization only for
use in commercial products. In this case, please contact me at the email address given at the beginning of this
document.