CGJU
CGJU
June 10, 2026 · 5 min read

HTML5 Video Tag Basics

Before HTML5, web video playback relied mainly on third-party plugins like Flash and QuickTime. HTML5 introduced the native <video> tag, making native browser video support possible. This was an important milestone in the history of web video development.

Basic Video Tag Usage

Playing video with the video tag is very simple, requiring just a few lines of code:

<video src="video.mp4" controls width="640" height="360">
    Your browser does not support video playback
</video>

Common Attributes

  • src: Video file URL
  • controls: Show playback control bar
  • autoplay: Auto-play (usually requires muted)
  • loop: Loop playback
  • muted: Mute audio
  • poster: Video cover image
  • preload: Preload strategy

Supported Video Formats

Different browsers support different video formats, which was the biggest challenge for early HTML5 video:

  • MP4 (H.264 + AAC): Best compatibility, supported by all modern browsers
  • WebM (VP8/VP9 + Vorbis/Opus): Supported by Chrome, Firefox
  • OGG (Theora + Vorbis): Supported by Firefox, Chrome

To be compatible with all browsers, you can use the source tag to provide multiple formats:

<video controls>
    <source src="video.mp4" type="video/mp4">
    <source src="video.webm" type="video/webm">
    Your browser does not support video playback
</video>

Limitations of Native Video Tag

Although the native video tag is simple and easy to use, it has significant limitations:

  • No streaming support: Can only play complete files, doesn't support HLS/DASH streaming protocols
  • No adaptive bitrate: Cannot switch quality based on network conditions
  • No DRM support: Cannot play encrypted protected content
  • Limited format support: Can only play formats natively supported by the browser

Media Source Extensions (MSE) Principles

Media Source Extensions (MSE) is an API standard developed by the W3C that allows JavaScript to dynamically inject media data into the video tag, enabling streaming support. MSE is the core technology for modern web video playback — players like HLS.js and dash.js are built on MSE.

Core MSE Concepts

  • MediaSource: Represents a media data source that can be attached to a video element
  • SourceBuffer: Buffer for storing media data
  • SourceBufferList: List of SourceBuffers

MSE Workflow

The basic MSE workflow is as follows:

  1. Create a MediaSource object
  2. Attach the MediaSource to the video element
  3. Wait for the MediaSource to open
  4. Create a SourceBuffer
  5. Fetch media segments via fetch or XHR
  6. Append data to the SourceBuffer
  7. The video tag reads data from the SourceBuffer and plays

Basic MSE Code Example

const video = document.querySelector('video');
const mediaSource = new MediaSource();
video.src = URL.createObjectURL(mediaSource);

mediaSource.addEventListener('sourceopen', function() {
    const sourceBuffer = mediaSource.addSourceBuffer('video/mp4; codecs="avc1.42E01E, mp4a.40.2"');
    
    fetch('video-chunk.mp4')
        .then(response => response.arrayBuffer())
        .then(data => {
            sourceBuffer.appendBuffer(data);
        });
});

Advantages of MSE

  • Streaming support: Enables HLS, DASH, and other streaming playback
  • Adaptive bitrate: Can dynamically switch quality based on network conditions
  • Flexible control: JavaScript has full control over buffering strategy
  • Multi-format support: Can play any format that can be demuxed

Encrypted Media Extensions (EME)

Encrypted Media Extensions (EME) is another important set of APIs for playing media content protected by DRM (Digital Rights Management). Video sites like Netflix, YouTube Premium, and Disney+ all use EME to protect their video content from piracy.

Core EME Components

  • MediaKeys: Represents a set of decryption keys
  • MediaKeySession: Decryption session for key negotiation
  • MediaKeySystemAccess: Used to access specific DRM systems
  • CDM: Content Decryption Module

Common DRM Systems

Different browsers and devices support different DRM systems:

  • Widevine: Developed by Google, supported by Chrome, Firefox, Android
  • PlayReady: Developed by Microsoft, supported by Edge, Xbox
  • FairPlay: Developed by Apple, supported by Safari, iOS
  • PrimeTime: Developed by Adobe, gradually being replaced

EME Workflow

  1. Detect DRM systems supported by the browser
  2. Create MediaKeys and attach to the video element
  3. Create a decryption session
  4. Generate a license request
  5. Send request to license server to obtain keys
  6. Update session keys
  7. Video decryption and playback

Basic EME Code Example

const video = document.querySelector('video');

navigator.requestMediaKeySystemAccess('com.widevine.alpha', [
  {
    videoCapabilities: [{ contentType: 'video/mp4; codecs="avc1.42E01E"' }]
  }
]).then(access => {
  return access.createMediaKeys();
}).then(mediaKeys => {
  return video.setMediaKeys(mediaKeys);
}).then(() => {
  video.src = 'encrypted-video.mp4';
  video.play();
});

WebCodecs API

WebCodecs is a low-level API provided by browsers that gives web developers direct access to the browser's built-in media codecs. Compared to MSE, WebCodecs is more low-level, more flexible, and offers better performance — it's the future direction of web video technology.

WebCodecs Interfaces

  • VideoDecoder: Video decoder
  • VideoEncoder: Video encoder
  • AudioDecoder: Audio decoder
  • AudioEncoder: Audio encoder
  • VideoFrame: Video frame
  • EncodedVideoChunk: Encoded video data chunk

Advantages of WebCodecs

  • Higher performance: Direct access to codecs, fewer intermediate steps
  • More flexible: Full control over the encoding/decoding process
  • Encoding support: Can encode as well as decode video
  • Lower latency: Suitable for low-latency scenarios like real-time communication
  • WebAssembly integration: Can work with WASM to support more formats

WebCodecs Use Cases

  • Video editors: Professional video editing in the browser
  • Real-time communication: Low-latency video beyond WebRTC
  • Cloud gaming: Game screen rendering
  • Video processing: Real-time processing like filters and effects
  • Video recording: Recording camera or screen content

WebCodecs Decoding Example

const decoder = new VideoDecoder({
  output: frame => {
    const canvas = document.querySelector('canvas');
    const ctx = canvas.getContext('2d');
    ctx.drawImage(frame, 0, 0);
    frame.close();
  },
  error: e => console.error(e)
});

decoder.configure({
  codec: 'vp09.00.10.08',
  codedWidth: 1280,
  codedHeight: 720
});

fetch('encoded-chunk.vp9')
  .then(res => res.arrayBuffer())
  .then(data => {
    const chunk = new EncodedVideoChunk({
      type: 'key',
      timestamp: 0,
      data: data
    });
    decoder.decode(chunk);
  });

Browser Support Status

HTML5 Video Tag Support

  • Chrome: Full support
  • Firefox: Full support
  • Safari: Full support, with native HLS support
  • Edge: Full support
  • Mobile browsers: Basically all support

MSE Support Status

  • Chrome: Supported, both desktop and mobile versions
  • Firefox: Supported
  • Safari: Desktop supported, limited mobile support
  • Edge: Supported

EME Support Status

  • Chrome: Supports Widevine
  • Firefox: Supports Widevine
  • Safari: Supports FairPlay
  • Edge: Supports PlayReady and Widevine

WebCodecs Support Status

  • Chrome: Full support (Chrome 94+)
  • Firefox: Partial support, still in development
  • Safari: Partial support, still in development
  • Edge: Full support

Playback Technology Evolution

Generation 1: Plugin Era (2005-2010)

Represented by Flash Player, browsers didn't natively support video and required third-party plugins. Advantages: unified format, powerful features. Disadvantages: poor security, low performance, no mobile device support.

Generation 2: Native Playback (2010-2015)

The HTML5 video tag emerged, bringing native browser video playback support. Advantages: no plugins needed, good performance. Disadvantages: no streaming or DRM support, format fragmentation.

Generation 3: MSE/EME Era (2015-2020)

MSE and EME standardization made streaming and DRM possible. MSE-based players like HLS.js and dash.js proliferated, greatly improving web video experience. Adaptive bitrate and encrypted playback became standard.

Generation 4: WebCodecs Era (2020-Present)

The WebCodecs API provides low-level codec access, and WebAssembly performance has improved dramatically. Browsers can now handle more complex video processing, with applications like cloud gaming, video editing, and real-time communication flourishing.

Future Outlook

  • WebGPU acceleration: GPU-accelerated video processing
  • AI video processing: AI super-resolution, denoising, and more in the browser
  • More codec support: Support for new codecs like AV1, H.266
  • Immersive media: VR/AR video playback

Summary

Browser video playback technology has evolved from plugins to native, from simple playback to streaming, from fixed formats to flexible control. The HTML5 video tag is the foundation, MSE enables streaming playback, EME provides content protection, and WebCodecs opens up even broader possibilities.

Understanding these technical principles helps us better comprehend how web video players work. If you want to experience these technologies in action, try our M3U8 Online Player, which is built on HLS.js and MSE technology to play HLS streams directly in the browser.

Related Recommendations

More great articles and useful tools

Want to Experience Web Video Playback?

Use our free M3U8 online player — no software installation needed, play HLS video streams directly in your browser

Try It Now ➡