An Interest In:
Web News this Week
- March 27, 2024
- March 26, 2024
- March 25, 2024
- March 24, 2024
- March 23, 2024
- March 22, 2024
- March 21, 2024
The Dolby Audio and Microsoft Edge Experience
Streaming online audio and video has been given a massive injection of awesome. No longer is the online experience limited to two-channel stereo sound. Dolby Digital Plus, an advanced codec from Dolby, has been designed specifically to enhance the online experience by providing a high-fidelity, low-latency solution for streaming surround sound media, and the codec is built into Microsoft Windows 10 as standard.
No special tricks or dedicated plugins are required to experience surround sound through a web browser, because the Dolby Digital Plus codec is available to HTML5 audio and video elements just like any other codec. That means you can experience engaging Dolby surround sound media online today, assuming the web browser and operating system you are using supports the Dolby Digital Plus codec.
HTML5 Feature Detection
If you are a web developer, and you want to provide your users with surround sound media, you will need to make sure the Dolby Digital Plus codec is available. If the codec is unavailable, you will need to provide an alternative media stream.
Needless to say, users running Windows 10 and the Microsoft Edge browser will be able to enjoy Dolby surround sound media streams, but feature detection is required to provide content to the widest possible audience.
Modern web browsers can actually deal with feature detection on your behalf if you add media elements directly to the HTML document. The following HTML snippet will attempt to play a Dolby Digital Plus encoded video stream, and it will fall back to a standard stereo encoded video stream if the Dolby Digital Plus codec is unavailable.
<!-- A video player with standard playback controls -->
<video controls>
<!-- Dolby Digital Plus -->
<source src='movie_1.m4v'
type='video/mp4;codecs="avc1.42E01E,ec-3"'>
<!-- One or more alternative formats (fallbacks) -->
<source src='movie_2.m4v'
type='video/mp4;codecs="avc1.42E01E,mp4a.40.2"'>
<div class='no-video-support'>
<!-- The HTML5 <video> element is not supported -->
</div>
</video>
If you want to handle the feature detection with JavaScript, you can use the canPlayType
function that is exposed by media elements.
// Create a temporary video element.
let video = document.createElement('video');
// Make sure the canPlayType function is available.
if (video.canPlayType !== undefined) {
let ddp = 'video/mp4;codecs="avc1.42E01E,ec-3"';
// Check if Dolby Digital Plus is supported.
if (element.canPlayType(ddp) === 'probably') {
// Supported.
} else {
// Unsupported.
}
} else {
// HTML5 video elements are unsupported.
}
It is a simple as that. If you have worked with HTML5 media elements before, you are probably already comfortable with that type of feature detection in web browsers.
Note: Dolby Digital Plus is not limited to video streams. You can provide standalone surround sound audio streams to your audience if you wish to do so.
Surround Sound
So, what is surround sound exactly? In a nutshell, a surround sound audio stream typically consists of six or eight individual sound channels. It provides a way to immerse the listener in a dynamic, 3D soundscape, and is the de facto standard for movie theaters and home entertainment systems. In contrast, a stereo audio stream only consists of two individual sound channels, and a mono audio stream consists of a single sound channel.
5.1 Surround Sound
5.1 surround sound audio streams consist of six individual sound channels.
The first three sound channels (LCR) are positioned in front of the listener, to the left, center and right. They provide the majority of the sound and are, for the most part, compatible with the standard stereo left and right sound channels. The center sound channel is typically used for dialog, but it also helps to keep sound centered when subtle panning occurs in a movie.
The next two sound channels (LS and RS) are positioned behind the listener. They provide the "surround" in a surround sound audio stream, and are typically used to enhance ambient soundscapes. If you imagine a movie scene in which someone is walking through a forest, the LS and RS sound channels may be used to provide additional sounds for bird calls, rustling leaves, gusts of wind, and so on.
Finally, the sixth sound channel (LFE) in a 5.1 setup is for low frequency effects. The primary purpose of the LFE channel is to provide low frequency sound, typically any frequencies below 120Hz, to one or more subwoofers. This channel can provide a physical chest-thumping experience to accompany large on-screen explosions, etc.
7.1 Surround Sound
7.1 surround sound audio streams extend 5.1 with the addition of two extra sound channels (CL and CR) which are placed either side of the listener, providing a total of eight individual sound channels. These two extra channels are typically used in conjunction with the front channels (LCR) to provide a much wider angle of sound.
Speaker Locations
The ideal positioning of surround sound speakers, relative to the listener, have been standardized by the International Telecommunication Union. The following image shows the ideal, standardized speaker positions.
The angle between the left (L) and right (R) speakers is 60 degrees, with the center (C) speaker placed directly in front of the listener. The left-surround (LS) and right-surround (RS) speakers are positioned approximately 110 degrees from the center (C) speaker. The position of the low frequency effects speaker (LFE), i.e. the subwoofer, isn't too important due to the low frequency limitation, but it is usually placed close to the listener, sometimes directly beneath the listener.
Audio Production
The production of surround sound audio streams is beyond the scope of this article, but a lot of modern sound editing software packages, including Audacity and Adobe Audition, allow you to create surround sound audio files and export them as WAV or AIFF files. The exported files can then be pushed through an encoder, or a service such as Microsoft Azure Media Encoder (see below), to produce high-fidelity Dolby Digital Plus audio and/or video files that are ready to be streamed over the internet.
Encoding With Microsoft Azure Media Encoder
Microsoft Azure Media Services provides an elegant, task-based solution for encoding Dolby Digital Plus audio and video online, and Microsoft has been awesome enough to provide everyone with a free trial of Azure. Beyond the free trial, the cost of encoding (as of writing) starts at $1.99 per GB, which is great value for money; you will no longer need to use expensive desktop software to get your fantastic Dolby Digital Plus surround sound out to the masses.
The following code describes the procedure required to programmatically encode a video file using the Azure services and the Dolby Digital Plus encoder, but it assumes you have some prior experience using the Azure services and the Media Services SDK for NET.
//
// Create the service context.
//
var context = new CloudMediaContext(
new MediaServiceCredentials("accountName", "accountKey")
);
//
// Create the latest version of the processor.
//
var proc = context.MediaProcessors.
Where(p => p.Name == "Azure Media Encoder").
ToList().
OrderBy(p => new Version(p.Version)).
LastOrDefault();
//
// Load the configuration file.
//
var conf = File.ReadAllText("ddp720.xml");
//
// Create the job.
//
var job = context.Jobs.Create("identifier");
var task = job.Tasks.addNew("identifier", proc, conf, TaskOptions.None);
task.InputAssets.Add(asset); // Assumes 'asset' has been loaded elsewhere.
task.OutputAssets.AddNew("identifier", AssetCreationOptions.StorageEncrypted);
//
// Start the job.
//
job.StateChanged += new EventHandler<JobStateChangedEventArgs>(StateChanged);
job.Submit();
job.GetExecutionProgressTask(CancellationToken.None).Wait();
var encoded = job.OutputMediaAssets[0]; // The encoded asset.
//
// State change handler.
//
void StateChanged(object sender, JobStateChangedEventArgs e) {
switch (e.CurrentState) {
case JobState.Finished: {
Console.WriteLine("Done!");
break;
}
case JobState.Canceling:
case JobState.Processing:
case JobState.Queued:
case JobState.Scheduled: {
Console.WriteLine("Processing...");
break;
}
case JobState.Canceled:
case JobState.Error: {
// Handle the error or cancellation.
break;
}
default: {
break;
}
}
}
The configuration file, ddp720.xml
, that is loaded into the program is as follows.
<?xml version="1.0" encoding="utf-8"?>
<Preset Version="5.0">
<Job />
<MediaFile
DeinterlaceMode="AutoPixelAdaptive"
ResizeQuality="Super"
AudioGainLevel="1"
VideoResizeMode="Stretch">
<OutputFormat>
<MP4OutputFormat
StreamCompatibility="Standard">
<AudioProfile
Condition="SourceContainsAudio">
<DolbyDigitalPlusAudioProfile
Codec="DolbyDigitalPlus"
EncoderMode="DolbyDigitalPlus"
AudioCodingMode="Mode32"
LFEOn="True"
SamplesPerSecond="44000"
BandwidthLimitingLowpassFilter="True"
DialogNormalization="-31">
<Bitrate>
<ConstantBitrate
Bitrate="256"
IsTwoPass="False"
BufferWindow="00:00:00" />
</Bitrate>
</DolbyDigitalPlusAudioProfile>
</AudioProfile>
<VideoProfile
Condition="SourceContainsVideo">
<HighH264VideoProfile
BFrameCount="3"
EntropyMode="Cabac"
RDOptimizationMode="Speed"
HadamardTransform="False"
SubBlockMotionSearchMode="Speed"
MultiReferenceMotionSearchMode="Balanced"
ReferenceBFrames="False"
AdaptiveBFrames="True"
SceneChangeDetector="True"
FastIntraDecisions="False"
FastInterDecisions="False"
SubPixelMode="Quarter"
SliceCount="0"
KeyFrameDistance="00:00:05"
InLoopFilter="True"
MEPartitionLevel="EightByEight"
ReferenceFrames="4"
SearchRange="64"
AutoFit="True"
Force16Pixels="False"
FrameRate="0"
SeparateFilesPerStream="True"
SmoothStreaming="False"
NumberOfEncoderThreads="0">
<Streams
AutoSize="False"
FreezeSort="False">
<StreamInfo
Size="1280,720">
<Bitrate>
<ConstantBitrate
Bitrate="5200"
IsTwoPass="False"
BufferWindow="00:00:05" />
</Bitrate>
</StreamInfo>
</Streams>
</HighH264VideoProfile>
</VideoProfile>
</MP4OutputFormat>
</OutputFormat>
</MediaFile>
</Preset>
That configuration file produces a H.264 720p video with Dolby Digital Plus 5.1 surround sound. The EncoderMode
attribute, "DolbyDigitalPlus"
, tells the encoder to use Dolby Digital Plus, and the AudioCodingMode
, "Mode32"
, tells the encoder to use 5.1 surround sound. Also, the LFEOn
attribute must be set to "True"
to enable the low frequency effects (LFE) sound channel.
Additional information is provided in the Resources section at the end of this article.
Encoding With Adobe Premiere Pro
The latest versions of Adobe Premiere Pro provide support for Dolby Digital Plus, allowing you to mix 5.1 and 7.1 surround sound directly into your videos.
Additional information is provided in the Resources section at the end of this article.
Closing Thoughts
As an avid consumer of online audio and video, I'm excited by Dolby Digital Plus. We have now reached a point where true Dolby surround sound can be streamed over the internet, thanks to the impressive work by Dolby and the support of Microsoft.
Online games, oh yes, they can also benefit from Dolby surround sound, as demonstrated by the highly entertaining Lux Ahoy game, but remember, you will need to be running Windows 10 and Microsoft Edge for now!
Finally
There may be some controversy surrounding another proprietary web technology, but in all honesty, if proprietary technology allows companies like Dolby and Microsoft to provide us with codecs such as Dolby Digital Plus, you will not be hearing any complaints from me.
Resources
Original Link:
TutsPlus - Code
Tuts+ is a site aimed at web developers and designers offering tutorials and articles on technologies, skills and techniques to improve how you design and build websites.More About this Source Visit TutsPlus - Code