Get started with jsmpeg CDN

MIT licensed

JSMPEG is a library for decoding H.264 video streams in the browser.

Tags:
  • MPEG1
  • decode
  • player
  • java

Stable version

Copied!

How to start using jsmpeg CDN


<!DOCTYPE html>
<html>
<head>
    <title>Get started with jsmpeg CDN - cdnhub.io</title>
    <script src="https://cdn.cdnhub.io/jsmpeg/0.2/jsmpg.min.js"></script>
</head>
<body>
    <video id="video" width="320" height="240" controls></video>
    <script>
        const video = document.getElementById('video');
        const decoder = new mpeg.MediaPlayer();

        decoder.onload = function() {
            const buffer = new Uint8Array(this.buffer);
            const blob = new Blob([buffer.buffer], { type: 'video/mp4' });
            const urlCreator = window.URL || window.webkitURL;
            const objectUrl = urlCreator.createObjectURL(blob);

            video.src = objectUrl;
            video.play();
        };

        decoder.load('path/to/your/mp4/file.mp4');
    </script>
</body>
</html>
Copied!
Copied!
Copied!

All versions