CaptionsConverter sample

Microsoft Expression Encoder works natively with TTML (DFXP) files, but also has the ability to import a variety of other formatted caption files (SAMI, LRC, SRT, SUB, TXT, ISMT). In order to support these types, Expression Encoder converts them to DFXP at encode time. However, you are not limited to the caption formats listed above. Expression Encoder will also import a custom file format that you have created. However, in order for Expression Encoder to perform that import, you will also need to create a custom caption converter that Expression Encoder can use to convert the custom caption type. This topic illustrates how to create that custom caption converter.

In addition to creating a converter for a new format, you can override the caption converters included with Expression Encoder. For example, if you create a better or more complete implementation of a SAMI to DFXP converter, then Expression Encoder will use your converter instead of the one included with Expression Encoder.

Expression Encoder does not create a directory in which to store caption converter assemblies, so you will need to create it, using the path "%Program Files%\Expression\Encoder\CaptionConverters". You will need to be an administrator to create this directory and to copy your converter into it.

This sample is a converter for a very simple Common Separated Value (CSV) file where, as in the below example, the first entry is the presentation time of the caption, in milliseconds, and the second entry is end time, in milliseconds, and the third entry is the caption text that will display (you cannot use commas in the text).

1000,1500,This shows at 1-1.5 seconds

2000,3000,This shows at 2-3 seconds

3000,4500,This shows at 3-4.5 seconds

Please note that error checking has been minimized in this sample for clarity, so you should check the input file format for errors. Exceptions that can appear when running the sample include: OverflowException, FormatException, TimedTextException, ArgumentException, FileNotFoundException, IOException, and UnauthorizedAccessException.

   © 2011 Microsoft Corporation. All rights reserved.