HTML5 Video How-To [Instant] — Save 50%
Over 20 practical, hands-on recipes to encode and display videos in the HTML5 video standard with this book and ebook.
In this article by Alex Libby, the author of HTML5 Video How-To, you will learn to convert a video into any of the formats needed for HTML5 Video playback.
In this article, we will cover:
Transcoding video into new HTML5 format
Installing playback support
(For more resources related to this topic, see here.)
If you have issues with Playback support and probably thinking that you would play any video in Windows Media Player, it is not so as Windows Media Player doesn't support all formats. This article will show you how to fix this and get them playing.
Transcoding audio files (must know)
We start this section by getting ready the files we are going to use later on—it is likely you may well have some music tracks already, but not in the right format. We will fix that in this task by using a shareware program called Switch Audio File Converter, which is available from http://www.nch.com.au/switch for approximately USD40.
For this task, you need download a copy of the Switch Sound Converter application—it is available from http://www.nch.com.au/switch/index.html. You may like to note that a license is required for encoding AMR files or using MP3 files in certain instances—these can be purchased at the same time as purchasing the main license.
How to do it...
The first thing to do is install the software, so let's go ahead and run switchsetup.exe—note that for the purposes of this demo, you should not select any of the additional related programs when requested.
Double-click the application to open it, then click on Add File and browse to, and then select the file you want to convert:
Click on Output Format and change it to .ogg—it will automatically download the required converter as soon as you click on Convert. The file is saved by default into your Music folder underneath your profile.
How it works...
Switch Sound File Converter has been designed to make the conversion process as simple as possible—this includes downloading any extra components that are required for the purposes of encoding or decoding audio files. You can alter the encoding settings, although you should find that for general use this may not be necessary.
There are lots of converters available that you can try—I picked this one as it is quick and easy to use, and doesn't have a large footprint (unlike some others). If you prefer, you can also use online services to accomplish the same task—two examples include Fre:ac (http://www.freac.org) or Online-Convert.com (http://www.online-convert.com). Note though that some sites will take note of details such as your IP address or what it is you are converting as well as store copies for a period of time.
Installing playback support: codecs (Must know)
Now that we have converted our audio files ready for playback—it's time to ensure that we can actually play them back in our PCs as well as in our browsers. Most of the latest browsers will play at least one of the formats we've created in the previous task but it is likely that you won't be able to play them outside of the browser. Let's take a look at how we can fix this by updating the codecs installed in your PC.
For those of you not familiar with codecs, they are designed to help encode assets when the audio file is created and decode them as part of playback. Software and hardware makers will decide the makeup of each codec based on which containers and technologies they should support; a number of factors such as file size, quality, and bandwidth all play a part in their decisions.
Let's take a look at how we can update our PCs to allow for proper playback of HTML5 video.
There are lots of individuals or companies who have produced different codecs, with differing results. We will take a look at one package that seems to work very well for Windows, which is the K-Lite Codec Pack. You need to download a copy of the pack, which is available from http://fileforum.betanews.com/detail/KLite-Codec-Pack-Basic/1094057842/1 —use the blue Download link on the right side of the page. This will download the basic version, which is more than sufficient for our needs at this stage.
How to do it...
Download, then run K-Lite_Codec_Pack_860_Basic.exe. Click on Next.
On the Installation Mode screen, select the Simple option.
On the File Associations page, select Windows Media Player.
On the File associations screen for Windows Media Player screen, click on Select all audio:
On the Thumbnails screen, click on Next.
On the Speaker configuration screen, click on Next, then Install. The software will confirm when the codecs have been installed.
How it works...
In order to play back HTML5 format audio in Windows Media Player, you need to ensure you have the correct support in place; Windows Media Player doesn't understand the encoding format of HTML5 audio by default. We can overcome this by installing additional codecs that tell Windows how to encode or decode a particular file format; K-Lite's package aims to remove the pain of this process.
The package we've looked at in this task is only available for Windows, if you are a Mac user, you will need to use an alternative method. There are lots of options available online—one such option is X Lossless Decoder, available from http://www.macupdate.com/app/mac/23430/x-lossless-decoder, which includes support for both .ogg and .mp4 formats.
We've taken a look at the recipes that show you to transcode a video into HTML5 Format and install playback support. This is only just the start of what you can achieve using this article—there is a whole world out there to explore.
Resources for Article :
- Basic use of Local Storage [Article]
- Customize your LinkedIn profile headline [Article]
- Blocking versus Non blocking scripts [Article]
About the Author :
Alex Libby’s background is in IT support – he has been involved in supporting end users for the last 15 years in a variety of different environments. He currently works as a Technical Analyst, supporting a medium-sized SharePoint estate for an international parts distributor based in the UK. Although Alex gets to play with different technologies in his day job, his first true love has always been with the open source movement, and in particular experimenting with CSS/CSS3 and HTML5. To date, Alex has written 5 books based on jQuery, HTML5 Video and CSS for Packt, and has reviewed several more (including Learning jQuery) – jQuery UI 1.10: The User Interface Library for jQuery is Alex’s sixth book for Packt