A How to Guide: Microsoft Windows Media Video 8, and DivX

A How to Guide: Microsoft Windows Media Video 8, and DivX

By Brandon Wirtz

bwirtz@griffin-digital.com

This document has now been expanded in to a full fledged book and multimedia presentation.  To find out more visit my Digerat.com page here

An Introduction: 1

Choosing the Right Codec: 2

Best Codec by Bit Rate: 3

Implementation: 4

Live Video Stream to 30 simultaneous users (Windows Media Only) 4

Live Audio Stream to 300 simultaneous users (Windows Media Only) 4

Live Video Stream to 300 simultaneous users (Windows Media Only) 4

Live Video Stream to 3000 simultaneous users (Windows Media Only) 4

Pre-Recorded Stream to 30 simultaneous users (Windows Media Only) 5

Multiple Pre-Recorded Stream to 30 simultaneous users (Windows Media Only) 5

Archival of Training Videos (DivX or Windows Media) 5

Embedding Video in a Web Page (DivX or Windows Media) 6

Conversion of Mpeg2/DVD to CD (DivX Only) 6

Conversion of Mpeg2/DVD to CD (Windows Media Only) 7

Capture of Live Video for play back later (DivX or Windows Media or Uncompressed AVI) 7

Simulated Live Streaming (Windows Media Only) 8

Pay-Per-View (PPV) Streaming (Windows Media Only) 8

Web Space Hosting vs. Media Server Hosting. 9

Live Streams for the Masses. 9

Intelligent Streaming. 9

Other advantages of a Media Server 10

Windows Media Specific Implementation: 10

Introduction: 10

Protocols: 11

Creating an ASX File: 12

Elements Defined: 12

Creating Scripts: 13

Creating a Windows Media Juke Box: 13

An Introduction:

The goal of this document is to outline what format and tools will work best in any encoding scenario.  This is a daunting task, but hopefully with the help of the WMTalk List serve I will at least be able to provide a reasonable reference guide.  This document will be updated as new information is acquired so check back often.

About the Codecs:

Both WM8 and DivX are based on Mpeg4 video.  In both cases the audio codec is either Mp3 or WMA.  This is because at current the Mpeg4 audio codec is very unreliable and produces extremely low quality.  However DivX can be encoded using Mp3pro (different from, but similar to Mpeg4).

In My Words

In Theirs

Windows Media 7 and 8 are based on the compression techniques used in Mpeg4.  However changes were made in these formats to accommodate real-time encoding and to lower the bandwidth requirements. 

Microsoft Windows Media Video 8 delivers unmatched video quality for streaming as well as downloads. The new Windows Media Video 8 improves compression efficiency an additional 30% over the technically acclaimed Windows Media Format 7.

More

DivX is a variation of the Mobile Multimedia Systems (MoMuSys) source code for Mpeg4 that offers reasonably fast compression, low play back requirements and high quality compression.

DivX is the brand name for high quality video compression technology. It allows the user to achieve high quality video at a low file size, making it possible to move these files over the internet.

More

Choosing the Right Codec:

You can have it fast, cheap or good – pick two

                                                -Henry Ford

Each codec has strengths and weaknesses.  Choosing the appropriate codec for each situation depends on a lot of factors.  Uncompressed AVI is obviously the highest quality video codec available, but it is far too large to be practical, as such any thing else is a compromise.

Features of each:

Feature

WM8

DivX

Stream / Progressive download

X

X

Windows Support

X

X

Mac Support

X

X

Linux Support

X

Dos Support

X

Multicast Support

X

Automatic Install of Codec via Media Player

X

Digital Rights Management

X

AVI Compliant (important for many Video Editors)

X

Real Time Encoding for Live Streams

X

Variable Bit Rate support

X

X

Multiple Bit Rate support

X

Best Codec by Bit Rate:

Both Codecs have strong and weak point for bandwidth utilization also.  WM8 seems to be far more efficient in the 700k and below arena while DivX makes better use of bandwidth beyond 700k.  For bandwidths between 500k and 900k I recommend choosing the codec you are more comfortable with or that better suits your audience.

Bit Rate

WM8

DivX

28.8

Not worth doing video.

Poor stereo at best, but ok Mono Audio.

N/A

56k

CD Quality Mono audio, or poor audio and poor video

N/A

112k

CD Quality Stereo with poor video, or CD quality Mono with mediocre video

CD Quality Mono with Poor Video

300k

CD Quality Stereo with clear video at 256×192

CD Quality Stereo with Clear video at 240×180

500k

CD Quality Stereo with clear video at 320×240

CD Quality Stereo with clear video at 256×192

700k

CD Quality Stereo with clear video at 384×288

CD Quality Stereo with clear video at 384×288

900k

CD Quality Stereo with clear video at 512×384

CD Quality Stereo with clear video at 640×480

1.2m

Codec will not use available bandwidth and quality is therefore equal to that of 900k

CD Quality Stereo with near master quality video at 640×480

Implementation:

Live Video Stream to 30 simultaneous users (Windows Media Only)

Bit Rate:           Single Bit Rate (choose one) 56k, 112k, 300k

For small broad casts like this it is possible to broadcast directly from the Windows Media encoder that can be run on any post Windows 9x platform.  The general rule is that you need 64 Megs of ram for the encoder and 8 Megs of ram for each user.  The processor requirement will vary with the type of content you are streaming but generally anything beyond a 600 MHz will serve up to 30 people.  Beyond about 300k the CPU requirements and memory requirements increase drastically.

Live Audio Stream to 300 simultaneous users (Windows Media Only)

Bit Rate:           64k (near CD Quality stereo)

Audio requires very few processor cycles for compression and so a 400 MHz with 64 Megs of ram and .5 Megs per user should suffice running WME 7.1.

Live Video Stream to 300 simultaneous users (Windows Media Only)

Bit Rate:           Multiple Bit Rate (56k, 128k, 300k)

For medium broad casts like this it is impossible to broadcast directly from the Windows Media encoder.  Instead the users will connect to the media server.  The windows Media Server should be setup to use the Ip address of the encoder as a source.  If the server and encoder are in the same domain than name resolution can be used in place of the Ip address.

Live Video Stream to 3000 simultaneous users (Windows Media Only)

Bit Rate:           Multiple Bit Rate (56k, 128k, 300k)

For large broad casts like this use the same setup as above but with multiple servers and a load balancer.  Each media server will have to have the Ip of the encoder set as a source.

Pre-Recorded Stream to 30 simultaneous users (Windows Media Only)

Bit Rate:           Multiple Bit Rate (56k, 128k, 300k)

The Windows Media Resource Kit includes a command line utility called WMVNETWRITE.  This utility is a great way to host a single stream for multiple clients.  It requires very few resources, and is simple to use.

Multiple Pre-Recorded Stream to 30 simultaneous users (Windows Media Only)

Bit Rate:           Multiple Bit Rate (56k, 128k, 300k)

While it is possible to use multiple instances of WMVNETWRITE, any time that multiple streams are to be broadcast a media Server should be used.

Archival of Training Videos (DivX or Windows Media)

Bit Rate:           700+ kbps

DivX Solution: 

Use Vdub or NanDub to create video files.  This format is preferred if the files will need to be edited later as most programs will recognize the DivX codec for importing video, but will not recognize the WM8 Codec.  About 2 hours of video should fit on a 700 Meg CD.

WM8 Solution:

Use the command line encoder (wm8eutil) and a Variable Bit Rate setting in VMODE 3 to create files at 100% quality with unlimited bandwidth.  The resulting files will work well if you are planning to stream them later. About 2 hours of video should fit on a 700 Meg CD.

Embedding Video in a Web Page (DivX or Windows Media)

Bit Rate:           Any

Solution: 

Assuming the client already has the codec installed use the Active X NetShow Plug-in found in Front page.  For WM8 the codec will auto install. For DivX you will have to provide a link to the codec.

You may alternately use the following code on a page.

<OBJECT
  ID="WinMedia"
classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
  CODEBASE= "http://activex.microsoft.com/activex/
  controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
  width=160 height=120 standby="Loading Microsoft
  Windows Media Player components…" type="application
  /x-oleobject">
<PARAM NAME="FileName"  VALUE="yourfile.asx">
<PARAM NAME="AutoStart" Value="true">
<PARAM NAME="ShowControls" Value="true">
<Embed type="application/x-mplayer2"
pluginspage=
    "http://www.microsoft.com/Windows/MediaPlayer/"
src="yourfile.asx"
    Name=MediaPlayer
AutoStart=0
    Width=160
    Height=120
autostart=1
ShowControls=1
  </embed>
</OBJECT>

Conversion of Mpeg2/DVD to CD (DivX Only)

Bit Rate:           Any (Generally 500+ kbps)

Solution: 

Use Flask to transcode the video file or VOB s to a DivX stream.  Depending on the media type reverse telecline or deinterlace filters maybe required to improve the play back quality.

Conversion of Mpeg2/DVD to CD (Windows Media Only)

Bit Rate:           Any (Generally 500+ kbps)

Solution: 

Use Flask to transcode the video file or VOB s to a Raw or HUFFY AVI.  Depending on the media type reverse telecline or deinterlace filters maybe required to improve the play back quality.  Encode the AVI to WMV using the WM8EUTIL or Windows Media Encoder.

Capture of Live Video for play back later (DivX or Windows Media or Uncompressed AVI)

Bit Rate:           N/A

DivX Solution: 

Capture video to Uncompressed AVI and then compress captured video using Flask, VDub, or NanDub.

WM8 Solution: (Quick)

Capture video using the Windows Media Encoder.

WM8 Solution: (Good)

Capture video to Uncompressed AVI and then compress captured video using WM8EUTIL or Windows Media Encoder.

Uncompressed AVI Solution:

Use VIDCAP (bundled with the WMRK) to capture video.

Simulated Live Streaming (Windows Media Only)

Bit Rate:           ANY

MS Only Solution:  Create a Play list to be encoded but the Windows Media Encoder.  Point Windows Media Server at this publishing point.  The disadvantage of this solution is it requires a minimum of two PCs.

Griffin Solution:  Use Griffin s SLIME to create a dynamic playlist that can run from any Web or Media Server that supports ASP.  The advantage to this method is that it requires only one server.

Pay-Per-View (PPV) Streaming (Windows Media Only)

Bit Rate:           ANY

WM8 Solution:

PPV requires at least three servers:

Web Server:  This holds the web pages related to the content.  Is used for obtaining billing information and includes instructions for the audience.

Media Server: This holds the multimedia content to be streamed.

Database Server: This contains two databases the membership data base and the commerce data base.  It is accessed via the Web server to handle payment and authentication.

A user visits the site by connecting to the Web Server.  The user enters their billing information which is passed from the Web Server to the Commerce Database on the Database Server via SQL.  The user then choose content to view which is pulled off the Media Server after the user is authenticated via the Membership Database

Software required for PPV in the order it is to be installed:

1. Windows NT Server 4.0

2. Windows NT 4.0 SP3

3. Internet Explorer 5.0

4. Windows NT Option Pack 4.0

5. MDAC 2.0 with SP1

6. Windows NT 4.0 SP4

7. Microsoft Open Database Connectivity (ODBC) Setup

8. Microsoft Site Server version 3.0, Standard Edition

9. Microsoft Site Server version 3.0, Commerce Edition

10. Microsoft Site Server Service Pack 2 (SP2)

11. ADSI 2.5

12. CyberSource credit card software

Web Space Hosting vs. Media Server Hosting

Many times the advantages of a Media Server may not be apparent.  Depending on the number of streams, amount of bandwidth and the type of connection visitors have a Media server can make drastic improvements to the quality of video that is streamed.

Live Streams for the Masses

The most common reason to have a media server is so that a live stream can be broadcast to more clients than what the Windows Media Encoder is capable of.  It is not currently possible to broad cast a 100+ client stream with out a Media Server.

Intelligent Streaming

The biggest feature of a windows Media Server is Intelligent Streaming.  Intelligent Streaming detects network connection speeds, adjusts to changing network conditions, and automatically improves video stream quality on the fly.

First, the server decreases the video frame rate to maintain audio quality and keep buffering to a minimum.

If conditions worsen, the server stops sending video frames completely, but maintains audio quality.

Finally, if audio quality starts to degrade, the client intelligently reconstructs portions of the stream to preserve quality.

With a traditional web space host network congestion forced the client to stop playback and rebuffer in order to continue playing.

Other advantages of a Media Server

With a Media Server users with connections faster than the stream do not exceed the streams bandwidth.  Normally a user with a T1 connection could download a stream at 1.5m.  This robs the rest of the users of valuable bandwidth and can cause their experience to be degraded.

Content can be protected.  When a stream is placed in web space anyone can download it.  By placing it on a media server the stream can be viewed but not saved.

Windows Media Specific Implementation:

Introduction:

Windows Media has the advantage that the technology is very scalable, and the disadvantage that the solutions can be very complex. A given implementation can vary greatly in demands based on the type of streaming that needs to be done.  For example a single PC for 20 users may be appropriate for an event but four PCs are needed to handle those same 20 users in a pay per view situation.  Finding the appropriate balance of features, quality and bandwidth can be quite daunting.

Protocols:

Windows Media Uses a protocol call MMS to send streams across the internet, or LAN.  The protocol uses the following URL format. 

mms://servername/filename.wmv

Because the MMS protocol is at the application level it can be handled by several transports.  MMS automatically looks for the optimal transport to stream media, in the following order:

UDP

TCP

HTTP

UDP is the optimal method of transport for a LAN environment as it is a pure push method.  Because packets are sent out with little or know flow control or error detection minimal load is put on the server and a very large number of streams can be pushed from a single server.  UDP is the worst method for Internet streams as users may not receive enough packets for the video to be watchable.  UDP is often unable to pass through firewalls.

UDP transport can be force by using:  mmsu://servername/filename.wmv

TCP is the optimal method of transport for an Internet environment, as it has marginal overhead, and is relatively firewall friendly.

TCP transport can be force by using:  mmst://servername/filename.wmv

HTTP is the most firewall friendly and as such is preferable in instances where the other two methods fail.  Anyone who can browse the web should be able to receive a media stream via HTTP

HTTP transport can be force by using: http://servername/filename.wmv

Creating an ASX File:

ASX is playlist file used to reference streams.  ASX is also used because Non-Internet Explorer browsers do not process MMS URL s.

A typical ASX file:

<ASX version="3.0">
<Entry>
<ref HREF=" mms://servernane/filename.wmv "/>
</Entry>
</ASX>

Elements Defined:

<TITLE> The title element shows up as Show: in the Windows Media Player when it is in "Classic Compact Mode". It should be noted that many of the elements do not display in "Classic Compact Mode".

<ABSTRACT> The abstract appears as a Tooltip when you leave the cursor over the Show: title for a few seconds. The abstract tag can be used to describe the TITLE or it can be used to describe a CLIP.

<AUTHOR> The author tag is reserved for the name of the person creating the file. It can also be used to contain additional information about the clip. It also appears under Properties.

<COPYRIGHT> The Copyright is a text string that shows up in the player window. It also appears under Properties.

<ENTRY> The Entry element is the basic element of the ASX metafile. The Entry element defines a single piece of content that will appear in the player. Multiple Entry elements can be used, multiple Entries are each a Clip.

Multiple Entries can be placed in order to create a Playlist. These elements will play sequentially.

<Entry><Ref href = "mms://Server/content/title1.asf" /></Entry>
<Entry><Ref href = "mms://Server/content/title2.asf" /></Entry>
<Entry><Ref href = "mms://Server/content/title3.asf" /></Entry>
<Entry><Ref href = "mms://Server/content/title4.asf" /></Entry>

<BANNER> With this element you can place an advertising banner (192 pixels x 34 pixels) image on the player at the bottom of the video display area in Full Mode. You can then add a hyperlink to the banner with a child element.

<MORE INFO HREF> The more info tag contains a URL link so that when the banner is clicked a browser window is launched and the user is taken to the URL. The MORE INFO tag can also be used in conjunction with the ENTRY tag so that when the video clip is clicked on it launches a browser.

<LOGO> This element can place a small (16 pixels x 16 pixels) GIF image next to the Title of the Show, or next to the Show status on Windows Media Player when in Full Mode. This graphic replaces the icon next to the Show title when placed in the main area of the metafile, and it replaces the graphic next to the Clip title when placed within an element.

Creating Scripts:

Scripts are used to sync browser events to markers in the streaming media.  Scripts are added to a video file after the file has been encoded.  To do this use the Advanced Script Indexer found in the WMRK.

Creating a Windows Media Juke Box:

By inserting the following code you can create a Windows Media Juke Box.  You can substitute Windows Media Files with ASX files if you want to have a by Genre Juke Box

<SCRIPT LANGUAGE = "JavaScript">

var streams = new Array();

streams[0] = new makeStream("http://msdn.microsoft.com/downloads/samples/Internet/imedia/netshow/smedia/NS3/JavaScript/Buttons/control.asx", "Microsoft Promo for Windows Media Player");

streams[1] = new makeStream("http://www.advintsol.com/webmaster030399/webmaster.asx", "Microsoft Training for Windows Media Player");

streams[2] = new makeStream("mms://netshow.microsoft.com/ms/sbnasfs/wmt/turtle28.asf"</