liveBook · Manning

Media format

As explained in Web Design Playground, Second Edition

A digital representation specification that combines a container with supported audio or video codecs and associated file conventions.

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

How Web Design Playground, Second Edition covers it

How deep it goes
Defines containers and codecs, lists video combinations, and demonstrates multi-source HTML while stopping short of conversion procedures.
Examples
Uses WebM, Ogg, MPEG-4, MP4, MP3, WAV, and multi-source HTML video and audio examples.
What it assumes
Assumes basic web-page markup while teaching containers, codecs, format choices, and media-element syntax from the beginning.
What you can do after
Apply it via HTML5 video and audio elements to embed one format or provide multiple media sources.
How it connects
Connects containers and codecs with HTML5 video elements, audio elements, source elements, and playback attributes.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Design Playground, Second Edition. The section links point to the parts of the book it draws on.