By: Emiley J in HTML5 Tutorials on 2013-02-17
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"'> </video>
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.
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
- Your name, rating, website address, town, country, state and comment will be publicly displayed if entered.
- Aside from the data entered into these form fields, other stored data about your comment will include:
- Your IP address (not displayed)
- The time/date of your submission (displayed)
- Your email address will not be shared. It is collected for only two reasons:
- Administrative purposes, should a need to contact you arise.
- To inform you of new comments, should you subscribe to receive notifications.
- A cookie may be set on your computer. This is used to remember your inputs. It will expire by itself.
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
- Although the administrator will attempt to moderate comments, it is impossible for every comment to have been moderated at any given time.
- You acknowledge that all comments express the views and opinions of the original author and not those of the administrator.
- You agree not to post any material which is knowingly false, obscene, hateful, threatening, harassing or invasive of a person's privacy.
- The administrator has the right to edit, move or remove any comment for any reason and without notice.
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Most Viewed Articles (in HTML5 )
Latest Articles (in HTML5)