Add script commands

With Microsoft Expression Encoder, you can add script commands to encoded media. You can import a script file in the formats .xml, .sami, .smi, or .dxfp and add script commands to the imported commands. Or, without importing a script file, you can manually add the script commands to the file. All your imported and added script commands appear in separate rows underneath the Timeline, and aligned with the time that they were implementedso that you can easily distinguish your script events from your other Timeline markers. When you are ready to encode, you can choose to either embed these commands in the header or insert them into the stream. Inserting them into the stream may reduce incompatibilities because if you have a large number of script commands, putting them in the header may exceed character limits. You can also export the modified script as an XML file.

Script commands are best suited for interactivity and responding to events in the playback script. These commands are pairs of Unicode strings synchronized with a particular time in the multimedia stream. The first string identifies the type of command being sent, and the second specifies the command to process. During playback, when the stream reaches the time associated with a command, the control sends a script command event to the Web page that contains it. An event-handling routine then responds to this event. You can also use script commands to specify locations in a digital media file where you want to insert an event trigger. For instance, when a digital media file reaches a specified script command location, you can call a method to run a function, such as to display a Web page or display captions and subtitles.

When you add script commands to your video, the Timeline expands to show you the locations of the commands. Each command type appears in its own row. For example, all captions will have markers in a single row. If you then enter a script command that instructs the video to launch a URL on playback, this command will appear in another row. This method of display is a good way to visually track, and adjust the location of, every command in your video. This overview of your interactive elements can be very effective in precisely organizing the message or effect of your video, and aids in sharply refining the timing and presentation of any number of elements.

Each script command that you create has its own row. Within that row, you can drag the command markers to new times.

The Script Commands category in the Metadata panel is perfectly suited for adding captions to your videos and is the most common use of this category. By following the procedure "To add script commands," you can add captions at any chosen frame in the Timeline, and then encode your video. Upon playback, when the specified frame appears, your caption is displayed. Alternatively, you can import pre-written captions, as described in the following procedure. Once you have imported the captions, you can add more, and modify the existing ones in the Script Commands category.

Both Windows Media Player and Microsoft Silverlight packages are compatible with the script type "caption". If you enter "caption" as a script command, either of these two playback modules will interpret the command and display your caption. In Silverlight, by default, your caption appears without your performing any additional action. In Windows Media Player, you will have to enable the Lyrics, Captions, and Subtitles feature. See Windows Media Player Help for more information.


Captioning is not currently supported in the Korean and Japanese languages.


Expression Encoder exports script commands as an XML file only. To create a .sami, .smi, or .dxfp file, you must use a third-party application.

The Script Commands category displaying added script commands.


To import a script

  1. In an open job, click the Metadata tab on the right side of the application. If you cannot see the Metadata tab, on the View menu, click Metadata.

  2. On the Metadata tab, click the arrow next to Script Commands to expand the options.

  3. Click Import. Browse to a script file, and then click Open.

To add script commands

  1. In an open job, click the Metadata tab on the right side of the application. If you cannot see the Metadata tab, on the View menu, click Metadata.

  2. On the Metadata tab, click the arrow next to Script Commands to expand the options.

  3. On the Timeline, drag the playhead to the point in the video where you want to add a script command.

  4. In the Script Commands category, click Add. The Timeline expands to reveal the marker in its own row at the playhead location.

  5. Do any of the following, and then press ENTER:

    • Double-click the words "Unknown Value" in the Type column to add a command type. If you want to create a caption, enter "caption." You can enter a maximum of 1,023 characters for this value. Each different type of script command that you create will appear in its own row below the Timeline.

    • Double-click the words "Unknown Value" in the Command column to type the command. If you are creating captions, type the caption that you want to display. During playback, the caption will display until playback reaches another marker, or the end of the video. You can type a maximum of 10,239 characters for this value.

  6. In the Save script commands in menu, click the location where you want Expression Encoder to save your commands.


    Captions will appear in your video only after you encode and view it. For more information about encoding, see Encode without templates and Encode using Silverlight templates.

To delete script commands

  • In the Script Commands category (Metadata panel), select the command that you want to delete, and then click Delete.

To export script commands

  • In the Script Commands category, click Export. Browse to a location to save the file, and then click Save.

To adjust script commands on the Timeline

  • Do any of the following:

    • To change the time that a command appears, drag the marker corresponding to that command.

    • In the Script Commands panel, locate the marker that you want to adjust and, in the Time column, double-click the value and type a new one.

Community Additions