Playing Video Part 2 Complexities of Video is

  • Slides: 9
Download presentation
Playing Video (Part 2)

Playing Video (Part 2)

Complexities of Video is a complicated topic and even some seasoned web designers do

Complexities of Video is a complicated topic and even some seasoned web designers do not fully understand many of the details. Contributing to the confusion is that there always multiple formats that go into a single video file, including: n File Format (also known as Container Format) – This is indicated by the file extension. Examples include. mp 4, . avi, . flv, . ogv, . webm, and. mov. n Video Compression Format (also known as Video Codec) – This is the method by which the visual portion of the video is encoded digitally. Examples include MPEG-4, H. 264, Sorenson, Theora, and VP 8. n Audio Codec – The method used to digitally encode the audio portion of the video. Examples include MP 3, PCM, AAC, and Vorbis. Luckily, there is no need for us to experiment with and learn all of these platforms. Instead, we will focus on just those necessary to deliver videos to our web audience.

Common Video Formats These are the video format combinations most commonly used to provideo

Common Video Formats These are the video format combinations most commonly used to provideo in HTML 5 web pages: Video Codec: H. 264 Theora VP 8 Container Format: . mp 4 . ogv . webm The closest thing we have to an "industry standard". You. Tube uses this format, as do many electronic devices, such as Blu-ray players. Patented and might require licensing fees. An open format that requires no licensing fees. Created by the same group that made the Ogg Vorbis audio format. Often referred to as "Ogg" format. Sponsored by Google, this newest format is thought to be the preferred standard in the future. Many sites are switching to this platform, though the patent status is still unclear.

Browser Support for Video Types Just as with audio, each major browser has its

Browser Support for Video Types Just as with audio, each major browser has its own level of support for the different video formats: Video File Format Support. mp 4 . ogv . webm 9. 0+ No No Firefox 21. 0+* 3. 5+ 4. 0+ Chrome 4. 0+** 4. 0+ 6. 0+ Safari 3. 2+ No No Opera No 10. 5+ 10. 6+ IE *Firefox supports MP 4 only for some operating systems. **Chrome announced plans to remove MP 4 support in future versions. No single video format is supported by all major browsers. If we use just one format on our site, a significant portion of our audience will not be able to play the video.

Example Browser Support Problem Our previous video example worked fine in IE and Chrome

Example Browser Support Problem Our previous video example worked fine in IE and Chrome (which support the MP 4 format) but now let's see how the same page looks in Firefox: <video src="video/rmnp. mp 4" width="480" height="321" controls></video> Hardly what we want our web visitors to see. We'll use the same strategy to deal with the video issue as we did with audio: a fallback system to accommodate multiple formats. Firefox 19. 0

Setting Up the Fallback System Let's offer video to the browser in multiple formats.

Setting Up the Fallback System Let's offer video to the browser in multiple formats. If a user's browser doesn't support the first format offered, it will continue through the list until it discovers a format it can play: <video width="480" height="321" controls> <source src="video/rmnp. mp 4"> <source src="video/rmnp. ogv"> <source src="video/rmnp. webm"> </video> We removed the src attribute from the <video> element and used the new HTML 5 <source> element. Firefox skips over the MP 4 file and loads the OGV format instead. Note that we could have omitted the WEBM file format and still had nearly 100% coverage for browsers currently in use. Since WEBM is gaining momentum very quickly on the web, we are including it to prepare for the future. Firefox 19. 0

Adding MIME Type Definitions Again, it's good practice to define the MIME type for

Adding MIME Type Definitions Again, it's good practice to define the MIME type for all video files: Video Format MIME-type MP 4 OGV WEBM type="video/mp 4" type="video/ogg" type="video/webm" <video width="480" height="321" controls> <source src="video/rmnp. mp 4" type="video/mp 4"> <source src="video/rmnp. ogv" type="video/ogg"> <source src="video/rmnp. webm" type="video/webm"> </video> Once more, don't get these confused. The "video/rmnp. webm" in the src attribute refers to an actual file on the web server, while the "video/webm" in the type attribute is the string of text that tells the browser which file format to expect but doesn't refer to an actual location.

Creating the Fallback Video Files Assuming our original video file is in H. 264/MP

Creating the Fallback Video Files Assuming our original video file is in H. 264/MP 4 format, we'll need to create Ogg and Web. M formats for each of our videos. Special software is available to convert a large batch of video files, but for our purposes, we can use one of the online tools to convert individual files. Let's use the same site as we did with the audio conversion: Notice that the site can convert video files to and from a large number of formats. Let's use the. mp 4 video on our local drive to create a version in the. ogv and. webm formats.

Final Fallback We still need to address those users with older browsers that don't

Final Fallback We still need to address those users with older browsers that don't support the <video> element. Using the same method as we did with <audio>, we can "trick" these older browsers into playing our videos, either by using Flash or embedding a You. Tube window: <video width="480" height="321" controls> <source src="video/rmnp. mp 4" type="video/mp 4"> <source src="video/rmnp. ogv" type="video/ogg"> <source src="video/rmnp. webm" type="video/webm"> <embed width="480" height="321" src="http: //www. youtube. com/v/njj. AYlx. Gzz. Q" type="application/x-shockwave-flash"></embed> </video> Visitors still using IE 8. 0 will be able to play the video in a You. Tube window. To offer this final fallback, we'll need to upload our video to You. Tube and get the individual embed code. IE 8. 0