New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

Start learning with our library of video tutorials taught by experts. Get started

HTML5: Video and Audio in Depth
Illustration by
Watching:

Understanding HTML5 video formats


From:

HTML5: Video and Audio in Depth

with Steve Heffernan

Video: Understanding HTML5 video formats

Working with video and audio formats can be a little tricky. There are a number of different formats to choose from and there are multiple parts involved, including audio and video codecs and container formats. A video format is made up of three pieces. You have your container format, which is where you get your file extension from. Then inside the container you have your video data which is compressed or encoded using a video codec and you also have your audio data which is encoded using an audio codec. So the video and audio data are stored separately, which is why a container format is needed. For HTML5 we have three video formats: the MP4 H.264 format, Ogg Theora and WebM.
Expand all | Collapse all
  1. 1m 24s
    1. Welcome
      42s
    2. Using the exercise files
      42s
  2. 15m 18s
    1. Understanding HTML5 video and audio
      4m 46s
    2. The state of HTML5 video and audio
      4m 29s
    3. Understanding the format war
      3m 53s
    4. Configuring your server to deliver HTML5 media formats
      2m 10s
  3. 32m 36s
    1. Using the video and audio tags
      5m 34s
    2. Using multiple sources for browser compatibility
      5m 53s
    3. Preloading
      4m 16s
    4. Autoplaying
      2m 2s
    5. Looping
      5m 11s
    6. Setting a poster frame
      3m 43s
    7. Setting the video width and height
      3m 40s
    8. Displaying subtitles and captions
      2m 17s
  4. 12m 40s
    1. Falling back to Flash
      4m 4s
    2. Falling back to download links
      6m 21s
    3. Using an embed code builder
      2m 15s
  5. 22m 17s
    1. Understanding HTML5 video formats
      5m 10s
    2. Understanding HTML5 audio formats
      2m 57s
    3. Encoding MP4/H.264 video with HandBrake
      3m 13s
    4. Encoding Ogg, Theora, and WebM with Firefogg
      3m 18s
    5. Encoding audio formats with VLC
      5m 54s
    6. Automating video and audio encoding
      1m 45s
  6. 34m 59s
    1. Setting up the JavaScript
      4m 39s
    2. Creating Play and Pause buttons
      7m 52s
    3. Creating a Play Progress bar
      5m 49s
    4. Creating a Load Progress bar
      9m 29s
    5. Creating a Current Time and Duration display
      7m 10s
  7. 4m 37s
    1. Overview of known issues
      35s
    2. Autobuffer or preload?
      56s
    3. Load progress in Firefox 3.6
      41s
    4. Android 2.0 issues
      1m 5s
    5. iOS 3 issues
      1m 20s
  8. 2m 8s
    1. Flight of the Navigator
      50s
    2. ZEN Audio Player by simurai
      34s
    3. The Wilderness Downtown by Google and Arcade Fire
      44s
  9. 1m 40s
    1. Further exploration
      1m 40s

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
please wait ...
HTML5: Video and Audio in Depth
2h 7m Intermediate Jun 02, 2011

Viewers: in countries Watching now:

In this course, author Steve Heffernan contextualizes the state of HTML5 audio and video and shows how to embed media into a web page using HTML5. The course sheds light on configuring the new HTML5 audio and video tags, ensuring backwards compatibility by setting alternative playback methods, encoding the needed file formats, and building custom controls with JavaScript. Also included are tutorials on troubleshooting known issues and reviewing real-world examples of HTML5 audio and video.

Topics include:
  • Understanding the differences in media formats
  • Preloading, autoplaying, and looping in HTML5
  • Setting a video's width and height attributes
  • Displaying subtitles and captions
  • Generating embed code with an embed code builder
  • Encoding files using HandBrake, Firefogg, and VLC
  • Creating a load progress bar
  • Recognizing Android and iOS issues
Subjects:
Video Web Web Video Web Development
Software:
HTML
Author:
Steve Heffernan

Understanding HTML5 video formats

Working with video and audio formats can be a little tricky. There are a number of different formats to choose from and there are multiple parts involved, including audio and video codecs and container formats. A video format is made up of three pieces. You have your container format, which is where you get your file extension from. Then inside the container you have your video data which is compressed or encoded using a video codec and you also have your audio data which is encoded using an audio codec. So the video and audio data are stored separately, which is why a container format is needed. For HTML5 we have three video formats: the MP4 H.264 format, Ogg Theora and WebM.

The MP4 format is made up of the MPEG-4 container format, the H.264 video codec, and the AAC audio codec. The MP4 format is the format supported by Safari including the iPhone and iPad which use Mobile Safari, and also Internet Explorer 9. Flash supports the MP4 format as well in versions 9 and above, which most users that have Flash will also have at least version 9. It's a great high-quality format and outside of web browsers it's a very popular format on hand-held devices. So if you have a camera or phone that can capture digital video, there is a good chance of storing it in the MP4 format.

It's a closed format and there are potential licensing fees around it. If you plan on charging to view the videos you're encoding, you probably owe MPEGLA some royalties. Otherwise, if you're providing the video for free on the Internet, you should be in the clear. If you have any questions around this, you can check out the royalty summary here on the MPEGLA's site. The Ogg Theora format is made up of the Ogg container format, the Theora video codec, and the Vorbis IO codec. The Ogg Theora format is free and open source and is supported by Firefox, Opera and Chrome.

It was the format used when Opera created the very first implementation of the video tag. The Theora codec is based on the VP3 codec that was open-sourced by On2 Technologies. On2 is the same company that was purchased by Google to create the WebM format. Ogg is a decent format but it requires bigger file sizes to achieve the same quality as the other two formats. The WebM format is made up of the WebM container format, the VP8 video codec, and Vorbis audio codec. Like Ogg, the WebM format is also free and open source and is also supported by Firefox, Opera and Chrome, but later versions of those browsers because it only became available on 2010.

It can be supported by IE 9 through an additional installation of WebM, but I won't expect most of you users to go and do that. WebM is of comparable quality to the MP4 format, but it's also completely free. So it has the best chance of becoming the official format of HTML5 video, if there ever is one. As I mentioned, WebM was created after Google bought On2 Technologies for their VP8 codec. You've never heard of On2, they've actually had a pretty significant impact on Web video. Their VP3 codec was used to create Ogg Theora. Their VP6 codec was the popular codec for Flash FLV files for many years and their VP8 codec is now the basis of the WebM format.

So just a little interesting bit of web video history for you. So anyway, with all these format choices, how do we decide which formats to create and provide for our users? I am going to run through some potential strategies for you. First of all, if you're doing something interesting with JavaScript in HTML5 and you want as many of your users as possible to see it, you probably want to create all three formats. With WebM you don't actually gain any extra user support over having an Ogg format, but it is a higher-quality format. So the user experience will be better. I also want to point out that you can use the same MP4 file for your Flash fallback that you use for Safari IE and the iOS devices.

As long as it's using the baseline profile for H.264, which I'll talk more about in the movie on encoding MP4s. If three formats is just too much work or even too expensive if you're doing a lot of videos, you have to go with the MP4 and Ogg formats. I would love to recommend just skipping to using WebM since it's a better format than Ogg, but there is an issue with how HTML5 browsers detects sources. We know that when older browsers don't support HTML5 video, they'll fall back to our fallback content. But when we're talking about browsers that do support HTML5, if you embed HTML5 video and don't provide a source that the browser supports, it won't fallback.

So if we provided a WebM source and no Ogg source, all those slightly older browser versions that support Ogg but not WebM will show a broken video image instead of falling back to Flash. So until none of those browser versions are in use anymore, you'll have to stick with Ogg. Finally, if all you care about right now is using HTML5 to support the iPhone and iPad since they don't support Flash, there is an option to just use the MP4 format, but again it runs into this issue of HTML5 browsers not falling back when there isn't a source they support.

To make this work you'll need to detect when the user's device is an iOS device and when it is, deliver HTML5; otherwise deliver Flash. This detection can be done on the server side of your site in PHP or whatever back-end language you're using or you can use JavaScript which can be a little trickier. So if that's your goal, I recommend looking into a JavaScript library like VideoJS to handle that part. So hopefully you now have a better understanding of video formats and how to use them. Next, we'll look at HTML5 audio formats.

There are currently no FAQs about HTML5: Video and Audio in Depth.

 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

join now Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed HTML5: Video and Audio in Depth.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.