Captioning for Windows Media
Creating a SAMI File

How SAMI Files Work

SAMI files are text files that typically have the .smi or .sami file extension. They can be created using a text editor, MAGpie, or Hi-Caption. If you're a MAGpie user, be sure to read our MAGpie tips. Here's a sample SAMI file:

<SAMI>
<HEAD>
<TITLE>Wizard of Oz Example</TITLE>
<STYLE TYPE="text/css">
<!--
P { font-size:1.2em; font-family: Arial; font-weight: normal; color: #FFFFFF; background-color: #000000; text-align: center; }
.ENUSCC { name: English; lang: EN-US-CC; }
-->
</STYLE>
</HEAD>
<BODY>
<SYNC Start=0>
<P Class=ENUSCC>Dorothy: Toto, I don't think we're in Kansas anymore.</P>
</SYNC>
<SYNC Start=2600>
<P Class=ENUSCC><table align=left><i>[barking]</i></table></P>
</SYNC>
<SYNC Start=4250><P>&nbsp;</P></SYNC>
</BODY>
</SAMI>

There are probably a few things that you may have noticed from this code.

  • SAMI is structured very similarly to HTML. In fact, many HTML tags are allowed in SAMI. HTML tags that must be closed in HTML must also be closed in SAMI documents.
  • SAMI is not case sensitive.
  • SAMI supports CSS. Most text formatting features of CSS can be used in SAMI files. You can use styles and id's, although their use is somewhat restricted.
  • Most text formatting HTML tags are allowed in SAMI. View a list of acceptable HTML formatting tags.

Let's take a look at this SAMI file a little more closely.

<SAMI>

The SAMI tag means that this is a SAMI file. This tag is required and must be closed at the end.

<TITLE>

The title tag contains the descriptive title for the captions. It is NOT required and is informational only. It does not display anywhere within the player.

<STYLE TYPE="text/css">

The style section is where you define what you want your captions to look like. Be sure to add the TYPE="text/css" section. The HTML comments (<!-- and -->) are also required. Most captions within your SAMI file will be contained within paragraph <p> tags, so in our example, styles were added to the <p> tag. You can customize individual sections of your captioning, but this allows you to define properties for all paragraphs within the caption file, such as font size, face, weight, color, background color, and alignment. Font face (font-family) is typically a sans serif font, such as Arial or Helvetica. Most captions use white text on a black background and are center aligned. Standard font size is from 12 to 16 point, but it is suggested that you use em, which are a relative font size with 1em being equal to the user's normal font size (usually 12 point). 2em is twice that big. If a user with a visual disability has changed his or her default font size to 18 point, the 2em will be twice that big, or 36 point.

If the media is played within Windows Media Player and not embedded in the web page, the size of the caption area is defined by the size of the Windows Media Player window. If the captions are larger than the media player window, the user only needs to make the media player larger by dragging or maximizing the player window.

Be sure to close the style section with </STYLE>. The use of CSS classes (i.e. ENUSCC) is reserved for defining language specific caption tracks. Your SAMI file can contain multiple versions of captions that will be displayed based on the user's computer language settings. Learn more about multiple language tracks.

<BODY>

Surrounds the captions themselves. Must be closed.

<SYNC Start=0>

The SYNC tag defines the beginning of an individual caption. The value of the start attribute is equal to the elapsed time from the beginning of the file, measured in milliseconds (there are 1000 milliseconds per second). Your first caption should start at 0, which is the beginning of the movie. A value of 1500 would begin the caption one and half seconds into the movie. A value of 56250 would be 56.25 seconds into the movie. This is fairly easy to figure, unless your movie is over one minute, at which point you have to convert each minute into 60000 milliseconds. 3 minutes, 12 and 3/4 seconds would be 192750 milliseconds. You can see why using a program such as MAGpie makes creating captions for Windows Media much easier, because it automatically creates the correct start values.

<P Class=ENUSCC>

Each of your captions should be part of some HTML tag, typically paragraphs <P>. The Class attribute defines the language of each caption. The value of the class attribute (i.e., ENUSCC) should be a class that is defined in the <STYLE> section. Learn more about language tracks. You can also include several HTML formatting tags. Use the table tag to align to left, right, or center. The default alignment is left, though you can specify in the style section an alignment for all paragraphs. Most developers display captions center aligned. Background noise and off screen dialog is sometimes left or right aligned and italicized. Each SYNC tag must be closed.

Remember that the amount of space allowed for each caption display is limited. If you allow the movie to open in the standalone Windows Media Player, the user can resize the window somewhat to accommodate captions. If the movie is embedded in the web page (which we do not recommend for accessibility reasons), then you will need to be sure to allow plenty of room within the caption window to display the longest caption. We suggest no more than a sentence or two per caption. If you don't want to display captions for a length of time, enter a paragraph which contains a non-breaking space character, <P>&nbsp;</P>.

When we are done creating our captions, we are going to put them together with our media file. The length of our captions should be the length of our media clip. Remember that the SYNC value defines the time the captions appear on the screen, so your last caption will probably be an empty paragraph with a sync start that coincides with the total length of the media clip (in milliseconds).

Creating a Standard SAMI File

Because of the complexity of SAMI files, it is usually best to use a captioning program like MAGpie to enter caption times. (If you are a MAGpie user, be sure to read our MAGpie suggestions.) You can, however, create the SAMI file in any text editor. It's a standard text file with the .smi or .sami file extension. The following will help you create a standard SAMI file without any special formatting.

  1. Open a text editor on your computer. Notepad or SimpleText is probably the best. The simpler the better.
  2. It is easiest to start with a standard template, so copy and paste our example from above or download our sample (Right-click > Save Target As). If you double click a SAMI file, it will probably open in Windows Media Player. To edit the SAMI file, open it in your text editor.
  3. Now that you have a template, make any formatting changes you would like to the STYLE section of the page. You must use correct CSS styles and formatting. Our template contains the most common formatting for web captions.
  4. Save your file as something.smi. Be sure it is saved as a text file type with the .smi extension.
  5. Add several empty SYNC tags before beginning. This makes it so you don't have to retype the code that repeats for each caption. Use copy and paste to make this easier. Copy this:
    <SYNC Start=0><P Class=ENUSCC>
    </SYNC>

    and paste it multiple times inside of the <BODY> and </BODY> tags.
  6. Open the media file you want to caption in Windows Media Player (WMP).
  7. Press play and review it until there is a logical breaking point in the dialog, generally after a sentence or so, and press pause. You may have to press forward or rewind, or use the time slider to be more accurate.
  8. Enter the text in the first SYNC tag, after the paragraph tag. Your line should look like this:
    <SYNC Start=0><P Class=ENUSCC>I am the first section of captions.
    </SYNC>
  9. Before you review the next section in WMP, enter the start value for the next SYNC tag. The next section of text will begin where the first caption ends, so enter the start value for the next caption now, before reviewing what it's text will be. Remember that each SYNC tag specifies the beginning of a new caption and that the value is elapsed time in milliseconds. Each second is 1000 milliseconds and each minute is 60000 milliseconds. Making the conversion is easier if you remember that the last three numbers are fractions of seconds. Just convert the time into number of seconds, then add three zeros. Windows Media Player does not display fractions of a second only minutes and seconds. You will have to guess where the breaking point is in milliseconds or ignore fractions of a second all together and just round to the nearest second. Use the slider to give you a better idea. If the break is about half way between two seconds, enter 500 (for half a second) for the last three numbers. If it is nearer to the next second, enter something like 800. You do not have to be totally accurate. Sometimes you will adjust times up or down slightly based on the length of the caption.
  10. Press play in WMP and find the next breaking point.
  11. Enter the text for the audio you just reviewed into the SYNC tag for which you just added the start value. Add the time for the next caption and repeat this process for the entire media clip.
  12. Your last time code should have a value that is the same as the total length of the movie and it should contain an empty paragraph so that nothing displays. Windows Media Player will never cut off your captions or media clip if one is shorter than the other. It will play until the longest one is over. Making both of them the same length will ensure that everything works correctly.
  13. Make sure that you have the proper formatting, text, and there are no mistakes in the SAMI code.
  14. Save your SAMI file, then open it in WMP by double clicking the file or selecting File > Open in WMP. Make sure that you have captions turned on and make sure that the captions look right. If you get an error when opening the file in WMP, it probably means that there is an error in the SAMI code.

    Note

    If you are using Windows Media Player version 10 or newer, the captions may not display when you open the SAMI file. You can remedy this by saving your SAMI file in the same directory as your video file and giving the SAMI file the same file name as your video file. For instance, if your video file is named MyMovie.wmv, you would name the SAMI file MyMovie.smi. If you open the video file, the captions will now display.
    What to do if the SAMI file opens in RealPlayer or Quicktime

  15. If your SAMI file is open in Windows Media Player, you will have to close WMP before saving any changes in your text editor. WMP tends to lock the file when it is open so you cannot modify it.

Advice for SAMI files

  • The .smi file extension is also used by SMIL files. If you are captioning Windows Media AND RealPlayer and/or Quicktime, be careful with filenames so you don't get confused or make changes to the wrong file. This can be remedied by always saving SMIL files with the .smil extension and SAMI files with the .smi extension.
  • Cleanup your SAMI files if you create them with MAGpie. (Read instructions for cleaning up SAMI files.)
  • Use em for font sizes. This will make captions more accessible to those with visual disabilities that may use larger font sizes or screen enlarging software.
  • Avoid embedding WMP content in your web page, because it is inaccessible to many disability types.
  • Be careful when opening SAMI files with programs like Dreamweaver, FrontPage, or word processors. These programs tend to reformat code, but often are not set to understand how XML type languages work. The minor changes it makes may render your SAMI file unusable. This is especially true if your SAMI file was incorrectly formatted with MAGpie (Learn the fix)

Multiple Language Tracks

The CSS class name for language tracks (for example, .ENUSCC) is determined based upon ISO standard language and country codes. The first two characters in the class name identify the language. The next two optional characters identify the country, and the last two characters are always CC (Closed Captions). ENUSCC indicates that the caption language is United States (US) English (EN). You don't have to identify the country, so ENCC would work as well. The country code differentiates between versions of languages. For instance, FRFRCC (French France) would be different that FRCACC (French Canadian). If you do not identify a language for your language track, or if the language you specify does not match the user's language settings, then WMP will play the first track it encounters.

Each language class should have parameters (within the { and }) of

name: language; lang: language-country-CC

In the example above, the language class is formatted in the <STYLE> section as:

.ENUSCC { name: English; lang: EN-US-CC; }

Japanese might be:

.JACC { name: Japanese; lang: JA-CC; }

Each individual caption must be identified by the language class:

<SYNC Start="1500">
<P Class="ENUSCC">I am an English caption</P>
<P Class="JACC">I am a Japanese caption</P>
</SYNC>

Only one of the caption languages can display at a time. The user can select a different language track in the Windows Media Player menus.

Screenshot of Windows Media Player showing French language option selected.

If a caption track is available in the language set as the default for the client computer, then that track will display. If not, the first (or only) caption track WMP finds will be displayed.

Acceptable HTML tags

You can use any of the following HTML tags. Because of limited space in the caption display window, you will want to be careful when using complex HTML tags. Remember that you can also use CSS to do much of the formatting.

Name Description Name Description
B Bold text style IMG Embedded image
BASEFONT Base font size LI List item
BIG Large text style OL Ordered list
BLOCKQUOTE Long quotation P Paragraph
BR Forced line break PRE Preformatted text
CAPTION Table caption Q Short inline quotation
CENTER Shorthand for DIV align=center S Strike-through text style
COL Table column SMALL Small text style
COLGROUP Table column group SPAN Generic language/style container
DD Definition description STRIKE Strike-through text
DIV Generic language/style container SUB Subscript
DL Definition list SUP Superscript
DT Definition term TABLE N/A
FONT Local change to font TBODY Table body
H1 Heading TD Table data cell
H2 Heading TFOOT Table footer
H3 Heading TH Table header cell
H4 Heading THEAD Table header
H5 Heading TR Table row
H6 Heading TT Teletype or monospaced text style
HR Horizontal rule U Underlined text style
I Italic text style UL Unordered list

Quicktime or RealPlayer Opens My SAMI File

Because the .smi extension is also used by SMIL files, it is common for SAMI extension to be associated with another program. If you double click a file, the program that the .smi file extension is associated with will open, and then try to open the .smi file. A SAMI file will not open in RealPlayer and Quicktime. SAMI files will only display in WMP. To fix this, you can manually open the file from Windows Media Player by selecting File > Open. You can also Right-click on the file and select Open with > Windows Media Player from the list. If you want the .smi file to always open with WMP, you can check the Always open with this program check box. Windows 95 and 98 users may need to select the file, hold down the Shift key, and then Right-click on the file.

To permanently change the file association, open My Computer or Windows Explorer. Select Tools > Folder Options > File types tab. Scroll until you find .smi in the list and select the Change button. Select Windows Media Player from the list and press OK, until all dialog boxes are closed. The SAMI file should now open correctly in Windows Media Player when you select it.

Suggestions for MAGpie Users

If you use MAGpie to create your SAMI files (which is what we suggest doing), you will save a lot of time over creating the file manually, but there are a few things you will want to know.

  • We suggest NOT using the speaker box in MAGpie. It wastes a lot of space and is not needed on many movies, especially if there is only one speaker. Instead, we recommend adding the speaker name to the caption box - Dorothy: Toto, I don't.... Regardless of whether you use it or not, MAGpie will create a style definition in the HEAD section and create a line for the speaker on every caption in our SAMI file. MAGpie adds the SOURCE CSS ID to the STYLE section of the SAMI file. If you take our advice and do not use the speaker box in MAGpie, then this CSS ID should be removed - it's the section that starts with #Source. If you use MAGpie, a typical caption where the speaker box is NOT used would be formatted in the SAMI file as:
    <SYNC Start=7233>
    <P Class=ENUSCC ID=Source>&nbsp;</P>
    <P Class=ENUSCC><table align=center> Dorothy: Toto too?</table></P>
    </SYNC>
    Notice the empty paragraph after the SYNC tag. This entire paragraph can be deleted. This would make every one of your captions start on the second line of the caption area - a waste of valuable captioning space. Use find and replace to quickly replace <P Class=ENUSCC ID=Source>&nbsp;</P> with nothing. MAGpie also uses the table tag to align each caption, even if the <P> style will align it anyway. If the <P> CSS is set up to align each caption to the center, then you don't need the <table align=center> tag for each caption. The opening and closing <table> tags can be removed. The only time you need the aligned table is if you want an individual caption aligned differently than the rest.
  • MAGpie 1.0 adds an empty <Copyright=""> tag. Not only is this improper formatting because the tag is not closed, but there is no Copyright tag in SAMI. The copyright can be added in the <SAMIParam> section, but the formatting would be
    Copyright {(c)2005, WebAIM}
    Always delete the <Copyright=""> tag.
    Besides, all content in the SAMIParam section is ignored by WMP anyway, and would only be informational to someone that bothered to save and open your SAMI file.
  • MAGpie 1.0 also adds the <TITLE> tag. While this is proper SAMI, the title is ignored by WMP and is informational only to those reading the SAMI file, so it can be safely removed.
  • Make sure that your first caption in MAGpie coincides with the beginning of your media (this will be SYNC Start=0 in SAMI) or the timing may be off for your captions in Windows Media Player.
  • MAGpie 2 tends to add formatting to each and every caption, even if all they all should look the same. For instance:
    <SYNC Start="82">
    <P ID="Source" Class="Captions">&nbsp;</P>
    <P Class="Captions"><span style="font-family: Arial;"><span style="font-size: 12pt;"><span style="color:#FFFFFF;"><span style="background:#000000;">Caption text</span></span></span></span></P> </SYNC>
    as generated by MAGpie can be reduced to
    <SYNC Start="82">
    <P Class="Captions">Caption text</P>
    </SYNC>
    Use Find and Replace in a text editor to get rid of all of the extra, unnecessary code.

Sample SAMI File

Here is the shell for the SAMI files we use:

<SAMI>
<HEAD>
<STYLE TYPE="text/css">
<!--
P {
font-size: 1em;
font-family: Arial;
font-weight: normal;
color: #FFFFFF;
background: #000000;
text-align: center;
padding-left: 5px;
padding-right: 5px;
padding-bottom: 2px;
}
.ENUSCC { Name: English; lang: EN-US-CC; }
-->
</STYLE>
</HEAD>
<BODY>
<SYNC Start="0">
<P Class="ENUSCC">First caption</P>
</SYNC>
<SYNC Start="1000">
<P Class="ENUSCC">Last caption</P>
</SYNC>
<SYNC Start="2000">
<P Class="ENUSCC">&nbsp;</P>
</SYNC>
</BODY>
</SAMI>

Make sure your first caption has a Start value of 0. The last caption should be empty with Start set to the duration of you media clip in milliseconds.

WebAIM is an initiative of:
Center for Persons with Disabilities (CPD) Utah State University