The HTML 5 <video> tag and H.264

The new HTML5 standard’s most prominently mentioned new feature is undoubtedly the video tag – this tag enables all compliant browsers to play video embedded in a site with no additional plugins

The only problem? The organizations responsible for choosing a video format are undecided. In one corner is H.264, used everywhere from Blu-Ray disc to military applications due to its tremendous efficiency, and in the other is Ogg Theora.

Ogg Theora is known to be less suitable for content delivery. It requires higher bandwidth to deliver quality similar to that of H.264, which will increase infrastructure costs noticeably if universally adopted.

So why Ogg?

A common argument is patent encumbrance. H.264, while an international standard, is a creation of the Motion Picture Experts Group (MPEG), an organization known for their propensity to charge royalty fees to makers of DVD playback hardware and software. If the MPEG folks were to start asking for royalties from the Mozilla organization, for example, the latter would find itself in quite a dire financial position. This fear is borne out by prior attempts of large patent-holders to begin profiting from a wide deployment of their intellectual property, such as the Compuserve GIF format.

However, these past encounters with patent law also illustrate the impracticality, and indeed futility of these money making attempts. Neither GIF nor any other patented format has succeeded in exacting fees from end users or distributors of the mechanisms used to display or output these formats. MP3, a standard of the MPEG group as old as the laserdisc, remains cheap to implement.

The Motion Picture Experts Group has shown itself to be a responsible steward of international standards, reducing the concerns and possible benefits surrounding the Ogg format or other open-source codecs like it. As soon as H.264 is universally adopted, people everywhere can begin taking advantage of video as ubiquitously as they can view web pages. No plugins, no addons, no special devices, no more concern around compatibility.

Will it play anywhere? Yes. That’s a big deal, and it’s why H.264 should be accepted by everyone.

Solving a QuickTime for Windows “annoyance”

One long-standing issue people have with QuickTime for Windows is its apparent insistence on becoming the default handler for video and images in IE and throughout the Windows environment, despite the setting of file associations to the contrary. Even if you set everything up to open in Windows Media, for some reason QuickTime is still invoked.

This bothers a lot of people and is probably one of the reasons QuickTime for Windows is disliked.

A recent discovery by an associate indicates this is a behavior of Windows’ ‘Set Program Access and Defaults’, which categorically associates web/mail/media with apps which know how to assume the default role. For some reason, Windows associates media playback to the default selection irrespective of any file associations you may have set. Screenshot included.

Program Defaults
Set the default media player back to Windows Media to disassociate QuickTime with multimedia formats. Tip and image credit: Tristan Schleining

HOWTO: Rip DVD’s in MacOS X (Updated)

This HOWTO has been updated and dramatically streamlined! It’s worth re-reviewing if you’ve read/implemented this method already. Keep in mind, this is for experts/enthusiasts and not those looking for a quick one-click solution.

The quality of video and sound is, for the average viewer, highly subjective. When it comes to viewing a DVD though, one can be certain that they’re watching the highest quality (until HD-DVD/Blu-Ray standardize) video they can get.

Another given is that when making archival copies of a DVD (DVD9 -> DVD9) there is no degradation in quality. Increasingly though, personal computers are taking the role of a media center hub, and one way they can effectively do this is to store a catalog of one’s movie collection for easy access (and no need to have a multi-disc-changer).

For the purposes of this we’re going to assume that while ripping a DVD to DiVX can be accomplished fairly easily with HandBrake in three steps, you want more ability to tweak and fine-tune the end-result to look far better.

Here I’ll provide an overview of the way I’ve found most effective in converting a DVD to a movie file with the highest possible quality. This method also has the benefit of using Apple’s QuickTime software for every stage of video conversion. QuickTime technology is used in the production of almost every movie Hollywood makes, so why use anything less to convert them?

I’m going to assume you have a basic familiarity with how to read manuals and familiarize yourself with the operation of a program too. 😉

The Tools:

The Steps:

I’m assuming here that you have a DVD with unencrypted content or the contents of a decrypted version already handy. If you’re within your usage rights to decrypt a movie (Fair Use laws apply!) you can use Mac the Ripper to do this.

Next we use Cinematize to convert the feature from VOB to MPEG-4. We’ll be using its Lossless setting to do this, so the conversion will lose as little detail as possible (there will be some, but it will be so slight as to only be measurable by professional equipment).

Cinematize Settings:

Drag the VIDEO_TS folder into the drop box in the main window. You’ll be presented with a list of items, one of which will be ‘Video Title Set 01’. Select it and click the ‘Select VTS’ button.
Segment tab: Title 1, Angle 1; Start Point: Chapter 1, End Point: Whatever the last chapter is.

Video Tab

  • Video Stream: Main Video Stream
  • Decoding menu: Decode To QuickTime
  • Decoding Mode: Automatic Selection
  • Output Codec: MPEG-4 Video
  • Output Quality: Lossless Quality
  • Aspect Ratio: No Size Adjustment

Audio Tab

  • Audio Stream menu: Audio 1
  • Decoding menu: Elementary Stream

Output Tab

  • Save Chapters: Together as One Segment
  • Output Format: Separate Stream Files

On a relatively new Mac it will take approximately 2 hours to perform this step (slightly faster than realtime). The output will consist of a .mov file containing the video, and a .ac3 file containing the Dolby audio.

Open the .mov file in MPEG Streamclip. Once you’re sure it’s in good shape, go to the File menu and choose ‘Export to MPEG-4…’.

MPEG Streamclip Settings:

  • Compression menu: H.264
  • Check the following boxes:
    • Multipass
    • B-Frames
    • Limit Data Rate
    • Pick a value for the data rate. Higher bitrate means higher quality, but also more disk space. Remember that H.264 is 3-7 times more efficient than MPEG-2, which was the source format. The DVD bitrate is 7500, so you should never set the date rate this high or higher. You can safely choose between 1100 and 2500 for bitrate without compromising on perceptual quality.

  • Quality Slider: 100%
  • Frame Size: Unscaled
  • Place a check in the ‘Cropping’ box.

In the previous revision of this HOWTO I gave you the choice of H.264 or DiVX. Now I’m not. H.264 is clearly superior. Everything from the iPod to the Xbox360 has adopted it for high-def playback, so it’s time to let DiVX go.

Removing Letterboxing

This step requires a bit of experimentation. In order to trim off the black bars above/below the picture you have to start by guessing at the values to place in the top/bottom fields in this dialog. You can preview the results by temporarily unchecking ‘multipass’ and pressing the ‘preview’ button on the bottom right. This will run through the movie until you press ‘stop’.

Cropping rules:

  • The values for top and bottom must add up to an even number
  • Preferably (not required) a multiple of 16

Repeat this until you don’t see black bars above and below. Don’t worry if you’ve removed a couple of pixels from the top/bottom. Overscan is a common practice in video, so movie makers don’t put anything important in the top row of pixels anyway. 😛

Remember to checkmark Multipass when done.

Click ‘Make Movie’. This will take a while. On a relatively new Mac about 7 to 9 hours will pass.

Once the movie is exported to H.264 format you’ll find a .mp4 file in the location you saved it to. Open this with QuickTime Player. Be sure you’ve registered for QuickTime Pro, since we’ll need these features. Also open the .ac3 file generated by Cinematize.

With the .ac3 file in focus, choose ‘Export’. In the Export file dialog box that opens, pick ‘Movie to QuickTime Movie’ from the drop-down and press the options button.

Movie Settings

There are two areas here, Video and Sound. Video will be grayed out, as obviously the .ac3 file contains no video track. This is fine.
Click Settings in the Sound area.

  • Format: AAC
  • Channels: 5.1 (C L R Ls Rs LFE)
  • Rate: 48.000 kHz
  • Check ‘Show Advanced Settings’
  • Render Settings – Quality: Best
  • AAC Encoder Settings – Bitrate Format: Constant Bit Rate
  • Target Bit Rate: 80 (this is per-channel)
  • Precedence: Bit Rate.

Save this. Approximately 30 minutes will pass. Open the resulting .mov file.

Choose ‘Select All’ from the Edit menu and then ‘Copy’. Switch focus to the .mov file containing the video and make sure the play position is right at the beginning. Choose ‘Add to Movie’ from the Edit menu.

Note: In some cases the audio can be slightly longer than the video, resulting in white frames at the end of the movie. You can use QuickTime’s graphical controls to trim this off (it’s usually only a few milliseconds worth anyway).

Play through a few sections of the movie to make sure audio and video are lined up. If so, Save As… and make a self-contained movie out of the result.

Anamorphic PAR

You’ve probably noticed by now that everything is too tall. This is because DVD’s typically store video in anamorphic form, meaning the pixels making up the video do not have a set shape. They’re stored vertically stretched on the DVD, and are to be stretched horizontally to fit the viewer’s preference for widescreen playback. This is known as ‘Anamorphic Pixel Aspect Ratio’ or Anamorphic PAR.

In this case we want to preserve the widescreen aspect of the movie. Fortunately this doesn’t require guesswork. The video you’re currently working with is 720 pixels wide. For NTSC movies the widescreen mode is 854 pixels wide, and for PAL movies the width is 1024. Height is variable and depends on the black bars we trimmed off.

To adjust this, show the ‘Movie Properties’ window from the Window menu, select the video track in the list, and click the ‘Visual Settings’ tab. Uncheck ‘Preserve Aspect Ratio’ and set the value of the first field to either 854 (if the source came from North America) or 1024 (if it didn’t). Close this window and save the changes.

Optional: Compatibility with other players

This is strongly recommended, as it will enable other players to display the correct aspect ratio. Open the newly created movie with ‘Dumpster’. Be careful with this app, as one wrong movie can corrupt the movie file and you’ll have to reassemble it in QuickTime from the source files.

Dumpster lists the internal structure of the .mov file. You’ll find:

‘moov’ – Movie
‘trak’ – Track

Expand the ‘trak’ item by clicking it. This will reveal a ‘tkhd’ subitem, expand it as well by clicking it.


Within the fields here you’ll find ‘trackWidth’, ‘trackHeight’ and ‘matrix’. Set the ‘trackWidth’ to the values prescribed above, and reset the ‘matrix’ value to 1.0 (the ‘matrix’ is what QuickTime uses to adjust the aspect ratio, but other players don’t understand it. Fortunately, QuickTime understands what we’re doing here). Carefully noting that nothing else has changed, save and quit Dumpster.

That’s it, we’re done. To recap:

We’ve extracted the MPEG-2 video and Dolby audio from a DVD and converted it to H.264 using QuickTime (via some applications that use QuickTime to do their heavy lifting while providing value-add features), preserving the surround sound and converting it from the older Dolby AC3 to the newer MPEG-4 Advanced Audio Coding method. Enjoy your new movie.