A media format combines a container—the file’s archive-like wrapper—with codecs that encode, compress, decode, and decompress audio or video. Because no universal format exists, web media requires choosing among several supported combinations. section 6.14
Common web video formats include:
- WebM uses the WebM container with VP8 or VP9 video and Vorbis or Opus audio; its files use .webm. section 6.14
- Ogg uses Theora video with Vorbis or Opus audio; its files use .ogg or .ogv. section 6.14
- MPEG-4 uses H.264 video with AAC audio; its files use .mp4. section 6.14
HTML5 media elements can serve one format directly through src or offer alternatives with multiple source elements. Each source can declare its format and, for video, its codecs. section 6.15 section 6.16
One video, several format options
A video element can list MP4, WebM, and Ogg sources, each with a type and codec declaration, so the page offers multiple video formats. section 6.15
<video poster=”/images/movie-poster.jpg”
width=”625”
height=”480”
controls
autoplay
loop>
<source src=”/videos/movie.mp4”
type=’video/mp4; codecs=”avc1.4D401E, mp4a.40.2”’>
<source src=”/videos/movie.webm”
type=’video/webm; codecs=”vp8, vorbis”’>
<source src=”/videos/movie.ogv”
type=’video/ogg; codecs=”theora, vorbis”’>
</video>
Inspect a complete multi-format video element with poster, dimensions, playback controls, and three source declarations. section 6.15
