Optimizing HTML5 Video Streaming and HTML Video Tags [2022 Update]
Table of Contents
If you’re new to adaptive streaming, you may be wondering: what’s all the fuss about HTML5 video streaming?
Overall, HTML5 video streaming enables the manipulation of multimedia content using <audio> and <video> HTML tags. Using the <video> tag creates a native HTML5 video player, and allows additional options for customizing and displaying video content.
This may seem a bit technical and confusing, but luckily, live streaming video is now more accessible than ever for professionals who aren’t quite tech-savvy.
In this article, we’ll cover HTML5 video streaming and its key applications. Then, we’ll briefly review HTML5 video players and cover three ways to embed your video content on a website. These methods include direct embedding via an HTML5 video tag, developing your own player, and using an existing player.
To get started, let’s take a look at some background on the origins of HTML5 video streaming.
Table of Contents
- What is HTML5 Video Streaming and How Does it Work?
- What is an HTML5 Video Player?
- Benefits of HTML5 Video Streaming
- HLS Protocol for HTML5 Video Streaming
- How to Embed a Player for HTML5 Streaming
- How to Optimize an HTML5 Video Stream
- Additional HTML5 Tags for Improved Streaming
What is HTML5 Video Streaming and How Does it Work?
Since the 1990s, it’s been possible to access video media content from our internet browsers. The most modern way of accessing video content is through HTML5 video streaming.
As a refresher, streaming a video is playing the video online. This process is unique in the sense that viewers can begin watching the video before it is completely downloaded, and the rest of the file downloads in real-time.
This process affords the viewer a steady stream of content, without making them wait for the entire file to download locally before viewing.
Over the years, the software technology behind this process has evolved to make the experience better for users. This has helped to better the video quality, reduce buffering, and improve the overall functionality of the video player.
That said, there are three methods for online video streaming:
- Proprietary format
- Intermediate player
- HTML5 video streaming
Let’s check them out.
1. Using a Proprietary Format
The first method for video streaming is using a proprietary format streamed from a particular website that is exclusive to that site.
This method refers to files like .mov, .rm, or .wmv. When broadcasters first presented videos via the internet, most browsers did not have built-in video players. In most cases, websites could choose the video format with which to work.
From there, they would just provide the player and the video on the web page itself. However, some formats required a dedicated player (such as Apple QuickTime for .mov formats). Even videos that worked without a dedicated player were not easy to share in those early streaming days.
2. Using an Intermediate Player
YouTube was first launched in 2005, and over the following decade, the company has helped make streaming video mainstream. Fifteen years later, YouTube is still quite popular.
When users upload a video to YouTube, viewers access the content through YouTube’s embedded player. Likewise, viewers can share the video content via a code that YouTube provides.
However, modern browsers now include embedded video players of their own. This means that it’s not always necessary for a website to provide the player.
Although YouTube is free, the platform poses significant challenges for serious broadcasters and businesses. Naming only a few, these drawbacks include third-party branding with your video, loss of ownership of your content, and lack of monetization features.
These limitations pose the need for an alternate solution for broadcasters who want to live stream on their own site.
3. Using HTML5 Video Streaming
The most modern method is HTML5 video streaming. This is the most innovative approach and it makes it possible to stream on just about any sort of device.
With HTML5 video streaming, the website hosting the content uses native HTTP to directly stream the media to viewers.
Content tags (e.g., <video> tag) are part of the HTML code. Thus, using the <video> tag creates a native HTML5 video player within your browser. These tags provide direction to the HTTP protocol as to what to do with this content. HTTP displays the text and an audio player plays audio content. This is how HTML5 video streaming works, and how you can embed a video with HTML5 using native HTTP.
Also, HTML tags have various attributes, or parameters, which provide further detail on how to present the content. For example, with the <img> tag, you can specify the size of the image.
More recently, HTML5 has expanded on the media capabilities of basic HTML. For example, enhancements to the <img> tag and the new <video> tag provide content creators more flexibility and ease in presenting media content. Understanding different HTML5 video tags allow for more customization with your presentation.
This flexibility of HTML video tags allows broadcasters to deliver media without worrying about which browser a given visitor uses.
What is an HTML5 Video Player?
Until relatively recently, the main method of delivering video via the internet was Adobe’s Flash video technology. However, in recent years, this protocol has been largely replaced by video delivery protocols like HLS streaming and played in HTML5 video players.
Today, Flash is considered an outdated streaming protocol. In fact, Chrome completely killed support for Flash at the end of 2020, and other major browsers are following suit, making the Flash player obsolete.
As described above, HTML5 video streaming provides more modern streaming solutions for streaming videos directly from a website. Before HTML5, sites relied on embedded flash players to display videos to users.
With the HTML5 video element, the streaming process has been streamlined and improved for viewers and broadcasters alike. Furthermore, HTML5 videos can stream on all types of devices. Many mobile streaming devices, on the other hand, cannot handle flash videos.
Overall, HTML5 video streaming provides a simpler way to use video on web pages. Before its publication as a markup language in 2014, videos could only play in a browser with plugins like Flash. By using HTML5, developers no longer worry about which browser or which extension their visitors use, allowing for greater video access.
Additionally, HTML5 simplifies video delivery by providing support for various attributes, elements, and tags to assist with the structure of your webpage. These support features include article and section and multimedia tags that support adding video and audio formats to your content.
Benefits of HTML5 Video Streaming
Streaming via an HTML5 video player is the preferred option for many reasons, and has a number of broadcasting benefits. For starters, HTML5 video is highly accessible. Most modern online video platforms are equipped with HTML5 video players. It is so common that it is practically the default option, which is why many people aren’t familiar with the term HTML5 video.
The reason that HTML5 is so widespread is that it is highly compatible. That alone is an important benefit. Past streaming methods were incompatible with streaming on a mobile device. Since the use of smartphones and tablets has become widespread, all-device compatibility is a must for any video streaming solution.
Another benefit of HTML5 video streaming is that it is highly customizable. This gives broadcasters more control over their end result.
HLS Protocol for HTML5 Video Streaming
In recent years, HLS has become a common protocol for streaming video over HTML5 players.
These technological advancements have been advantageous for both broadcasters and viewers. In particular, broadcasters can modify both HTML5 and HLS to their specifications. Additionally, these protocols are safer, more reliable, and faster than earlier technologies.
If you’re new to the term, HLS is an acronym for HTTP Live Streaming. HLS is a media streaming protocol used to deliver visual and audio media to viewers online.
First launched by Apple in 2009, HLS streaming is now often preferred by broadcasters for its wide support on multiple browsers and devices.
How to Embed a Player for HTML5 Streaming
Now that you understand the history and purpose of HTML5 video players, we’re going to dive into a few approaches to HTML5 streaming.
To begin let’s discuss the three main ways to embed videos on your website:
- Use the HTML5 <video> tag directly in your browser
- Create your own player
- Choose a ready-made HTML5 player
1. Embed a Video with HTML5
When you’re setting up HTML5 video streaming on your website, you must declare the following:
- A <video> tag
- The URL of the video
- Any stylistic requirements you might want to customize (for a more appealing video player than the standard player)
*Note: It’s important to note that the <video> tag is a simple piece of code you can add to your web pages.
The standard <video> tag provides the following functionality:
- Specify the width and height of the player
- Display or hide video controls, including play/pause, volume, full-screen toggle and seek slider
- Set a poster image to display while the video is downloading or not playing
- Provide a set of videos in different formats, so that each browser can play a format it supports
- Include closed-caption subtitles or captions in multiple languages
- Tell the browser whether to start downloading the video when the page loads or only when the user presses “Play”
- Control autoplay settings
- Decide whether to play content once or in a loop
- Indicate if you’d like to play the video without sound (muted). For example, automated videos on Facebook display the mute option overlaid on the video
Note: We’d like to point out that although the HTML5 <video> tag is considered the most widely supported video player element, not every version of every browser supports it.
If users visit your site using earlier versions than the following browsers, they won’t be able to watch any videos displayed using HTML5:
- Chrome: Version 4.0
- MicrosoftExplorer (predecessor to Edge): Version 9.0
- Mozilla Firefox: Version 3.5
- Safari: Version 4.0
- Opera: Version 10.5
It’s also important to note that HTML5 video streaming requires technical knowledge and dedicated resources. Therefore, it’s best to opt for an existing HTML5 player if you lack the knowledge to manipulate HTML5 code, but we will discuss this option further in this post.
2. Develop Your Own HTML5 Player
Another option for embedding video content on your website is via your own HTML5 video player. Building a custom HTML5 video player requires a combination of HTML and CSS coding. It also requires knowledge of the HTML5 Media API.
Without specifying any code that styles the HTML5 video player, the appearance of the player is quite basic. It also depends on the browser from which the video plays.
Providing a consistent interface for HTML5 video streaming on your site is also useful for branding purposes and visual presentation.
Again, it’s important to note that HTML5 video streaming is a fairly technical option best suitable for people with requisite coding knowledge. Otherwise, an existing HTML5 player built by a dedicated team through a live streaming API is a better option if you lack the technical know-how.
3. Use an Existing HTML5 Player
If you are new to broadcasting, we highly recommend using an existing HTML5 player.
As we mentioned above, many HTML5 players already exist and can be easily customized by broadcasters to best represent their brand without deep technical knowledge. This allows users who don’t have the technical knowledge for HTML5 video streaming to still broadcast their chosen video.
Here are some viable video players available today:
- Some HTML5 players use VideoJS as their base and add more functionality to the basic player. An example is the Dacast all-device video player, which offers functionality to stream live video and a customizable player skin.
- JW Player is a for-pay HTML5 video player that supports 4K video and adaptive bitrate streaming.
- Other solutions include Flow Player, jPlayer, and Mediaelement.js.
Native HTML5 video doesn’t support RTMP app streaming nor HDS protocols. However, JW does support these two protocols. So, as mentioned above, if you plan to use a solely HTML5 video player, HLS is probably the best protocol for you.
We’d also like to point out that some existing HTML5 video players, including the one from Dacast, are built for low latency streaming. Any video you stream with a Dacast video player automatically uses low latency streaming. So no matter your viewer’s internet connection, they will be able to watch your content.
How to Optimize an HTML5 Video Stream Tag
There are a few ways to get the most out of the HTML5 <video> tag.
The first thing to pay attention to is your format. Using standard formats allows users to easily play videos. MP4 (MPEG-4) is the most widely-used format. However, Ogg and WebM formats are becoming more widely known.
WebM is now supported by recent versions of Chrome, Firefox, Opera, Safari on OS/X, and Microsoft Internet Explorer 9 and up (requires WebM MF components). With this development, multiple formats mean easier viewing.
A major optimization hack in video delivery is to lower the lag time or latency. Today, video is the most popular form of content consumption. Users spend mere seconds waiting for videos to start playing.
Broadcasters will also want to optimize your control settings. Here’s a quick breakdown of a few common settings to pay attention to:
- Physical size: Set maximum physical size to provide control over uploads and lower lag time. Using a 1280×720 frame size, for example, is usually plenty for most videos.
- Length: Trim videos to capture the most compelling frames.
- Quality and Bitrate: Adjust these settings to decrease file size without a significant impact on perceived video quality.
- Video-Codec: Generally, you can use the default settings to normalize and optimize the video for the web. However, in some cases, you want to manually set the codec to further lower the file size.
- Compression: Always compress video files before using them on your site.
Additional HTML5 Tags for Improved Streaming
The <video> tag is not the only tool in your HTML5 toolbox for optimizing videos. For example, listing the <source> tags along with their corresponding <type> tags in an optimized order can improve your video performance.
This is demonstrated in this sample HTML5 code for live video streaming:
<video width=”480” controls>
<source scr=”https://myweb.org/webm/video1.webm” type=”video/webm”>
<source scr=”https://myweb.org/mp4/video1.mg4” type=”video/mp4”>
<source scr=”https://myweb.org/ogg/video1.ogv” type=”video/ogv”>
<track kind=”captions” src=”sampleCaption_he.vtt” scrlang=”he”>
Keep in mind that a browser will play the first supported format type. In other words, the first entry in the list is the default. Chrome and Firefox will play the WebM video, while predecessors to Microsoft Edge will skip to the MP4 video.
It is recommended that you list the most supported and smallest video first to ensure that the file plays by default.
Using some additional HTML5 tags will help you customize your video player. Here are a few options:
- <width> tag controls the width of the video that plays.
- <controls> tag is a Boolean attribute that allows users to access playback controls.
- <track> tag creates a transcript to increase content accessibility.
- <embed> tag creates a container for external media.
Lastly, if you want the video to start automatically, use the <autoplay> video element.
To recap, HTML5 video streaming enhances web pages and engages visitors better than text alone. To retain viewers, broadcasters must optimize HTTP live streaming to ensure quick, smooth, and compatible video delivery for viewers. Using HTML5 media tags properly ensures that your content is accessible and keeps visitors coming back.
In this article, we’ve defined HTML5 video streaming and video players. We also discussed different ways to stream live video on your website via embedding. Additionally, we’ve highlighted some common pros and cons of each method.
Not yet streaming with Dacast and ready to give our live streaming platform a try? We offer a range of new and advanced features, including China video hosting and monetization options, at affordable prices.
Sign up for our free 14-day trial to start streaming today. We’ll help you start streaming in a matter of minutes. No credit card is required.
After reading, what’s your take on embedding video using HTML5? Still have questions you’d like us to answer, here or in future articles? Let us know via the chat section!
For exclusive offers and regular tips on live streaming, you can also join our LinkedIn group.
Stay up to date with our latest features and product releases