Click Here to Install Silverlight*
United StatesChange|All Microsoft Sites
Windows Media Player 9 Series*
Search Microsoft.com for:
|Windows Media Worldwide

Automating the Encoding Process

Andrea Pruneda
Microsoft New Media Platforms Division
November 2002


Introduction

Microsoft Windows Media 9 Series includes Windows Media Encoder, a powerful production tool for converting audio and video into files and streams in Windows Media Format. End users can use the Windows Media Encoder user interface to configure an encoding session, which at a minimum includes specifying the audio and video input sources, the output, and the encoding profile to use. Additionally, end users can crop and resize video, add metadata attributes, and specify preprocessing settings.

Windows Media Encoder is based on the Windows Media Encoder SDK, which is available to developers who want to create custom encoding applications. This SDK supports C++, Microsoft Visual Basic®, Microsoft Visual Basic Scripting Edition (VBScript), Microsoft JScript®, and any of the programming languages supported by the Microsoft .NET Framework. In addition, developers can automate the encoding process in different ways, which is the focus of this article.

Feedback
E-mail us with your comments and feedback about this article.
 
Abstract
Using Microsoft® Windows Media® Encoder 9 Series and the Microsoft Windows Media Encoder 9 Series SDK, you can convert audio and video into Windows Media-based content. This article describes different ways that you can automate this process by using the Windows Media Encoder SDK and its sample applications.
This article describes how to automate the encoding process in the following topics:
Back to the top of this page Back to the top


Using the Windows Media Batch Encoder Sample

The Windows Media Batch Encoder is a sample application written in Microsoft Visual Basic .NET. It is intended to be a starting point for automating your process. You can modify the source code to suit your needs.

The sample shows how to encode a list of files without having to configure the encoding session for each file. Each file you add to the list can have different settings as needed; for example, you can use a different profile for each file. This sample includes other important features, allowing you to enable two-pass encoding, specify video preprocessing, and add digital rights management (DRM) protection using an existing DRM profile.

When you start encoding, the sample application displays status information, such as the percentage completed and the encoding status. You can also preview the video output while encoding. After you set up a batch encoding list, you can save your encoding session and use it again; this feature is useful when you encode the same files on a regular basis.

Windows Media Batch Encoder sample
Figure 1. The Windows Media Batch Encoder sample


This sample can be found in the \WMSDK\WMEncSDK9\Samples\vb\batcher folder where you installed the Windows Media Encoder SDK. For more information, see the Batch Encoding topic in the Windows Media Encoder SDK Help.

Back to the top of this page Back to the top



Using the Command Line Encoder Sample

The Command Line Encoder sample is written in VBScript, and allows you to run an encoding session from the command line. Many command-line parameters are available, allowing you to take advantage of most encoding features. You can specify CBR or VBR encoding and create custom profiles. To automate the encoding process, you can also write as many commands as needed to a batch (.bat) file. For example, you could save the following text to a batch file:

cscript.exe wmcmd.vbs -input C:\My-clips\Mymovie.avi -output C:\My-clips-coded\Mymovie-640x480-vbr095.wmv -v_mode 2 -v_quality 95 -v_keydist 30 -v_preproc 5

cscript.exe wmcmd.vbs -input C:\My-clips\Mymovie.avi -output C:\My-clips-coded\Mymovie-320x240-vbr097.wmv -v_mode 2 -v_quality 97 -v_keydist 30 -v_preproc 5 -v_width 320 -v_height 240

cscript.exe wmcmd.vbs -input C:\My-clips\Mymovie.avi -output C:\My-clips-coded\Mymovie-640x480-cbr2.wmv -v_mode 1 -v_bitrate 1000000 -v_keydist 30 -v_buffer 10000 -v_quality 100 -v_preproc 5

cscript.exe wmcmd.vbs -input C:\My-clips\Mymovie.avi -output C:\My-clips-coded\Mymovie-320x240-cbr2.wmv -v_mode 1 -v_bitrate 500000 -v_keydist 30 -v_buffer 10000 -v_quality 100 -v_preproc 5 -v_width 320 -v_height 240

Using this utility, you can also enumerate the available source devices on your computer, as well as the available audio and video codecs.

This sample (wmcmd.vbs) can be found in the \WMSDK\WMEncSDK9\Samples\vb\wmcmd folder where you installed the Windows Media Encoder SDK, and you can modify it as needed. Run the sample with CScript.exe from a command window. To get a complete list of all the command line parameters and what they do, execute the script with this command line:

CScript.exe wmcmd.vbs /?

Back to the top of this page Back to the top



Using the Remote Administration Sample

The Remote Administration sample is written in C#, and shows how you can monitor encoding applications running on remote computers, over a local area network (LAN), or over the Internet.

For example, if you have multiple instances of an encoding application running, the sample application enumerates the encoding applications, and then allows you to monitor their status on one page. You can monitor the samples dropped, the current bit rate, the CPU usage, and so forth.

This sample uses a Web service that allows clients to monitor the status of a remote encoding application. Typically, you would use three computers to set up remote administration, including a computer to:
  • Run the encoding applications with the Web service installed.

  • Act as a Web server that contains an ASPX page to call the encoder Web service.

  • Serve as a client computer to connect to the Web server to monitor the encoding applications, for example, using Microsoft Internet Explorer.
Using such a Web service, you have greater flexibility since you can write code to run on the client computer in any of the programming languages supported by the .NET Framework to communicate with the Web service. Web services also work well on a LAN and across the Internet. Using the sample as a starting point, you could write code in order to automatically update the monitoring page, rather than refreshing it manually. Or, you could use the DHTML WebService behavior to call the encoder Web service directly. You could also add methods to configure and control the remote encoding application, and expose this functionality as part of your Web service.

The following illustration shows the sample ASPX page that is used to monitor encoding applications.

remote client page for monitoring encoding applications
Figure 2. The Remote Client page for monitoring encoding applications

This sample can be found in the \WMSDK\WMEncSDK9\Samples\c#\remadmin folder where you installed the Windows Media Encoder SDK. For more information about remote administration, see the Windows Media Encoder SDK Help. For more information about the DHTML WebService behavior, see the WebService Behavior page on MSDN® Online.

Back to the top of this page Back to the top



Useful Features

In addition to using the SDK sample applications, you can incorporate the following features to help automate your encoding process:
  • Statistics. Helps you monitor the status of the encoding process, which is useful when your encoding applications are running on remote computers.

  • Stream editing. Allows you to split and recombine streams. For example, you can produce one encoded file containing multiple bit rates, and then use stream editing afterwards to create a separate file for each bit rate.

  • Basic editing. Allows you to work with encoded files by trimming the beginning and end times, and by adding metadata, markers, and scripts. For example, you could add basic editing at the end of your encoding process to add additional metadata attributes.

Back to the top of this page Back to the top



For More Information

To learn more about the Windows Media Encoder SDK, see the Windows Media Encoder SDK Help. This SDK can be downloaded from MSDN® Online.

Back to the top of this page Back to the top


Legal Notice

The information contained in this document represents the current view of Microsoft Corporation on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication.

This White Paper is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE INFORMATION IN THIS DOCUMENT.

Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation.

Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property.

© 2002 Microsoft Corporation. All rights reserved.

Microsoft, MS-DOS, Windows, Windows Media, Windows NT, ActiveSync, ActiveX, Direct3D, DirectDraw, DirectInput, DirectMusic, DirectPlay, DirectShow, DirectSound, DirectX, FrontPage, JScript, Microsoft Press, MSN, NetShow, Outlook, PowerPoint, SQL Server, Visual Basic, Visual C++, Visual InterDev, Visual J++, Visual Studio, WebTV, Win32, and Win32s are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A. and/or other countries.

The names of actual companies and products mentioned herein may be the trademarks of their respective owners.


Back to the top of this page Back to the top



© 2008 Microsoft Corporation. All rights reserved. Contact Us |Terms of Use |Trademarks |Privacy Statement
Microsoft