By: Emiley J Viewed: 153240 times
The concept of storing a video and playing it on a webpage is really complicated. You may need to know a little bit of a background of playing videos on the web in order to appreciate what HTML5 does for playing video on a webpage.
Video files are of many types. You would have heard of AVI files and MPEG4 files which are really a container to store video files. I say container because they are equivalent to a zip file which consists of many files of different types. A video file also contains the actual video, the audio and some meta data about the video and saves it in a single file.
So just as you have many different zip file extractors, you also have many video players. Just as there are many type of video files, there are many type of video players and they may not understand all the different types of video files. That is why some of the video files are not playable from some video players.
So if you think of a video player’s job, it does three things:
- Understand the type of video file container and read its contents
- Decode the video and play the video stream
- Decode the audio and play the audio
To do steps 2 and 3 above, the player must understand the different codecs that the video/audio was encoded in and then use the same decoder to decode before playing. This is the reason why there is NO Single video player that can play all types of video files. In fact, what YouTube does is when you upload any video file, it converts the video and stores it in a format that the youtube understands which is a flash movie type.
So prior to HTML5 there was no common accepted method to represent and play video on a webpage without the need for a plugin such as silverlight or flash etc, due to the above complexities. So HTML5 introduces a new tag called <video> tag which lets you list all the different formats of the same video within the <video> tag and lets the browser decide which format to use and play the video.
The below code illustrates this.
<video width="560" height="340" controls>
<source src="bday.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
<source src="bday.ogv" type='video/ogg; codecs="theora, vorbis"'>
So with HTML5 you can make sure your video is playable in all browsers and devices, here’s what your video workflow will look like:
- Make one version that uses WebM (VP8 + Vorbis).
- Make another version that uses H.264 baseline video and AAC “low complexity” audio in an MP4 container.
- Make another version that uses Theora video and Vorbis audio in an Ogg container. *
- Link to all three video files from a single <video> element, and fall back to a Flash-based video player.
Most Viewed Articles (in HTML5 )
Latest Articles (in HTML5)
Comment on this tutorial
- Cloud Computing
- Java Beans
- Mac OS X
- Office 365
- Tech Reviews