Reducing Broadcast Delay
|Reduce the delay experienced during a broadcast by minimizing the size of buffers in Windows Media components. This article describes broadcast delay and shows you how to configure the components.
By Bill Birney
Microsoft CorporationJune, 2006
IntroductionMost computer programs use temporary storage areas in memory called buffers. Typically, a program buffers data before sending it on to a device, such as a hard drive or printer. Microsoft® Windows Media® components use buffers for a number of reasons. Typically, components buffer small chunks of digital media so the data can be processed before rendering it, or sending it to a hard disk drive or computer over a network.
In a broadcast scenario, buffers play a significant role in assuring the quality of digital media as computers and network devices compress, encode, distribute, decompress, and render large amounts of data, very quickly, in real time. In general, the larger the buffer, the better is the end-user experience. However, there is one main disadvantage of large buffers in a live or broadcast-streaming scenario. Buffers cause delays or latencies.
A broadcast delay is the difference in time between the point when live audio and video is encoded and when it is played back, and it is created primarily by the buffers that store digital media data. For example, if the buffers store a total of ten seconds of data, Windows Media Player will show an event occurring ten seconds late. Often a delay of less than twenty seconds is not a problem. However, when timing is important, Windows Media components provide a number of ways that you can minimize broadcast delay without causing a significant loss of image and sound quality.
This article describes the buffers and how to adjust them for minimal delay, and the difference between broadcast delay and startup delay. This information is provided in the following topics:
Back to Top
Buffering Streaming Media DataIn general when describing the size of a buffer, we usually think in terms of storage space. For example, a word processing program might use 50 kilobytes (KB) to temporarily store a document. When describing a Windows Media buffer, on the other hand, we usually think in terms of time, because audio and video are temporal media. For example, we say a typical buffer holds five seconds of data.
When streaming and playing content, the buffers are constantly changing; new data is continuously being added to the buffer in real time, as older, processed data is sent on and deleted from the buffer. The following figure illustrates how data, in a sense, moves through a five-second buffer.
Data enters the top of the buffer at zero seconds and leaves the bottom of the buffer five seconds later. During the five seconds that the data is in the buffer, a program or algorithm can change, copy, delete, rearrange, or store the data. For example, the encoder buffers data so that the codec can analyze and compress it.
Windows Media stores digital media in buffers for three basic reasons:
ProcessingBy default, Windows Media Encoder adds a five-second buffer to a session in order to provide the Windows Media Video codec with the optimum amount of data to compress a stream. When playing on-demand content, the buffer is not noticed. However, when encoding a live stream the buffer increases the broadcast delay.
The codec needs a buffer because it analyzes video content over a period of time. For example, it analyzes movement or change from one video frame to the next in order to reduce the bit rate of the content as much as possible and produce high-quality images. To compress data at one point, it might use the analysis of data that occurs two seconds later. Therefore, the more data it can analyze, the better it can compress the stream. Reducing the buffer shortens the delay, but can result in lower quality images.
Fast StartFast Start is a new function of the Windows Media 9 Series platform that reduces start-up delay. Start-up delay is different from the type of delay we are talking about in this article. It is the period of time the user must wait for the Player buffer to fill with data when first connecting to a stream. If the buffer is set to hold five seconds of data, the wait is at least that length of time, possibly longer depending on network conditions and the bit rate of the stream.
Fast Start causes data to be sent faster than the actual bit rate of a stream when a user first connects in order to quickly fill the buffer. If the user has high-speed network access, buffering time is reduced and the Player begins playing the stream sooner. After the buffer is filled, the bit rate returns to normal.
In order for Fast Start to work on a broadcast publishing point, which streams data in real time, the server must add broadcast delay to the stream and maintain a buffer. When a user first connects, the buffer is used to send data faster than real time. With Fast Start, the user experience is more like that of watching television, in which he can change channels and instantly view content without start-up delays. The downside is that a few seconds of broadcast delay must be added for the buffer.
Though the two types of delay are different, in this one sense they are related. In order to reduce start-up delay, Fast Start creates a buffer, which in doing so increases the broadcast delay.
Error CorrectionIn order for audio and video to play back properly, the digital media must be received in a continuous, unbroken stream. The Internet is an especially challenging network environment. Because of the tremendous size of the Internet, the large amount of data that must be routed and carried, the unpredictable load and bandwidth, and the great distances the data must travel, network conditions are less than favorable for the delivery of streaming content. Though conditions are improving with higher speeds and faster devices, it would not be possible to stream audio and video on the Internet or any congested or slow network without a system of error correction.
Windows Media is designed to deliver the best quality stream possible to users over a wide range of network qualities and connection speeds. To mitigate errors caused by data being lost, delayed, and received incomplete, Windows Media Services and Windows Media Player maintain buffers. Streaming media data is sent in numbered packets that include the addresses of the sender and receiver. The Player uses a buffer to arrange the packets that arrive according to their numbers. If a packet is broken or does not arrive in time, the Player requests a new packet from the Windows Media server. The server can then resend the packet from its buffer.
The following figure illustrates that even when incoming data stops, playback can continue because it uses the data left in the buffer. When incoming data continues it is added to the buffer and presentation continues smoothly even though packets might have been received in the wrong order and at different times.
If packets do not arrive in time, the Player edits out the missing data from the buffer. There is a small jump in the presentation where the missing data is, but without the buffer there would be a hole in the presentation.
Back to Top
Minimizing DelayBuffers are an essential part of creating, delivering, and rendering streaming media content, enabling Windows Media components to provide a high-quality end-user experience. However, there are trade-offs. The larger the buffer size, the longer the broadcast delay. The default buffer time values in Windows Media components balance quality and delay for most situations. However, there are three buffer settings you can modify to minimize broadcast delay. The following figure shows the buffers in the encoder, server, and player computers, and how each adds to the delay.
The encoder buffers content to enable the codec to optimize compression; the server buffers content to enable Fast Start; and the Player buffer provides smooth playback for the user. Assuming each buffer stores five seconds of data, and taking into account delays that might be added by network devices, the total broadcast delay can be between 15 and 20 seconds. You cannot eliminate the buffers completely; Windows Media components could not work without any buffers. However, by minimizing the buffer sizes using the procedures in the next three sections, you can reduce broadcast delay to approximately six to nine seconds, depending on network conditions.
As you reconfigure settings, test playback and watch for problems. For example, when you reduce the encoder buffer, make sure you are comfortable with the quality of the images. The codec has less motion data to work with, so you might notice more video artifacts, and movement might not appear as smooth. If your content does not include fast motion scenes, you may not even notice any degradation of quality. With a small Player buffer size, playback is more likely to be interrupted by buffering, which is caused by the Player running out of data. Buffering might not be a problem for users with stable, high-speed Internet access. However, users with slow connections may actually need to increase their buffer size. Remember you are balancing quality with broadcast delay, and by reducing delay you may have to make compromises. If you do not have to minimize delay, use the buffers.
To reduce overall broadcast delay, you can reduce the size of the encoder and Player buffers, and disable the Fast Start buffer on your Windows Media server.
Reducing the Encoder BufferStart Windows Media Encoder 9 Series and create or open a broadcast session with Windows Media server (streaming) as the destination. In this procedure, we will assume Multiple bit rates (CBR) is selected for both Audio and Video. However, other settings can be used. Do the following:
In Session Properties on the Compression tab, click Edit. Custom Encoding Settings opens.
Click the bit rate tab.
In Buffer size, type 1, which is the minimum buffer size. The following figure shows the setting on the bit rate tab.For applications needing audio, the end-to-end latency can be reduced by using one of the encoder “low delay” encoding modes available in versions 9.1 of Windows Media Audio and Windows Media Audio Professional and later. These low delay modes cut down on the audio buffering needed both at the encoder and the decoder (player), thereby improving the end-to-end latency. These modes are available when Windows Media Format 9.5 SDK or later is installed on the encoding machine. The WMA/WMA Pro bitstreams encoded with this configuration (WME9 + FSDK9.5 or later) are fully compliant with older WM players, and no codec download by the players is needed. Once FSDK9.5 or later is installed, in the Compression tab of WME9, hit the Edit and select for audio the “CBR” mode and Windows Media Audio 9.1 codec. In the bitrate tab, in the drop-down list for Audio Format, select one of the few selections marked as “Low Delay CBR".
The Low Delay CBR modes enabled in “Windows Media Audio 9.1 Professional or later” could also be used. Note that the Windows Media Format SDK 11, which is installed when you install Windows Media Player 11 Beta, will also upgrade the WMA Professional codec to WMA 10 Professional. Note Codecs can require different minimum buffer sizes. Therefore, the broadcast delay in most cases is longer than one second. For example, the Windows Media 9 Audio Voice codec introduces a longer delay than the standard Windows Media Audio 9 codec. If you do not require audio, you can further minimize delay by setting Audio Format to 0 kbps, 8 kHz, mono CBR.
Disabling the Server Buffer and Fast StartOpen the Windows Media Services snap-in for Microsoft Management Console (MMC) or Windows Media Services Administrator for the Web, and connect to your Windows Media 9 Series server. Open or create a new broadcast publishing point. Then do the following:
Click the broadcast publishing point, and then in the details pane on the right, click the Properties tab.
In Category, click General.
In Property, click Enable Fast Cache, and then click the Disable button.
In Category, click Networking.
In Property, click Enable buffering and then click the Properties button.
On Enable Buffering Properties, click Disable buffering. The following figure shows the Windows Media Services snap-in with Enable Buffering Properties open and buffering disabled. Note Fast Start is disabled at the publishing point level, so keep the Fast Start buffer on publishing points that do not require minimum broadcast delay.
Reducing the Player BufferOpen Windows Media Player 9 Series, and do the following:
On the Tools menu, click Options.
On the Performance tab, click Buffer, and type 1, which is the minimum buffer size value. The following figure shows the Performance tab with the new setting.
Back to Top
For More Information
Back to Top