Sams Teach Yourself HTML, CSS & JavaScript Web Publishing in One Hour a Day

(singke) #1
ptg16476052

392 LESSON 14: Integrating Multimedia: Video and Sound


Before diving into the tags used to publish video on the Web, it’s important to first
explain how to create video files that can be played in a browser. Understanding how to
create video files for the Web is the first step in getting video from your camcorder or
mobile phone onto web pages.

Video and Container Formats


Before discussing how to embed video within a web page, it’s important to discuss video
formats. All video files are compressed using what’s known as a codec, short for coder/
decoder. After a video has been encoded, it must be saved within a container file, and just
as there are a number of codecs, there are a number of container file formats, too. To play
a video, an application must understand how to deal with its container file and be able to
decode whatever codec was used to compress the video. For example, H.264 is one of the
most popular video codecs and is supported by a number of container formats, including
FLV (Flash Video) and MP4.
It’s not uncommon to run into situations in which a video player can open the container
file used to package the video but does not support the codec used to encode the video.
Likewise, if a video player doesn’t recognize the container file used to package the video,
it won’t be able to play it back, regardless of the codec used. Whereas many, many video
codes and container formats exist, only a few are relevant in terms of video on the Web.
The extension for a video file indicates its container format, not the codec of the video in
it. For example, the extension for Apple’s QuickTime container format is .mov, regard-
less of which codec is used to encode the video.
H.264 is a commercial format that is supported natively by Microsoft Internet Explorer 9,
Apple Safari, and Google Chrome. It’s also supported by Flash. The problem with H.264
is that it is patented, and there are license fees associated with the patents. Companies
that implement the codec must pay for a license, as must companies that use the codec to
deliver H.264 video to users. Mozilla held out for a long time and did not support H.264
in Firefox because of the patent licenses required, but as of around version 20 it began
supporting it. H.264 is the most popular format for delivering video content over the Web
by far. It’s also used for satellite and cable television and to encode the video on Blu-Ray
discs.
Most commonly, H.264 video is associated with MP4 (.mp4) containers, or occasionally
Flash Video (.flv) containers. MP4 files are supported by the Flash player and by all the
browsers that support H.264 video, making it the most widely supported container for
distributing video on the Web.
Free download pdf