Code Monkey home page Code Monkey logo

Comments (3)

matvp91 avatar matvp91 commented on September 17, 2024

There's no API that does blob yet, but it shouldn't be too hard to introduce a mediasource streamtype.

Just to be clear, are you talking about creating a MediaSource object and have the object URL be assigned to the video src property?

from indigo-player.

harisnaeemofficial avatar harisnaeemofficial commented on September 17, 2024

Yes exactly like MediaSource
I found this solution on Mozilla MediaSource web API

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

var assetURL = 'frag_bunny.mp4';
// Need to be specific for Blink regarding codecs
// ./mp4info frag_bunny.mp4 | grep Codec
var mimeCodec = 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"';

if ('MediaSource' in window && MediaSource.isTypeSupported(mimeCodec)) {
var mediaSource = new MediaSource();
//console.log(mediaSource.readyState); // closed
video.src = URL.createObjectURL(mediaSource);
mediaSource.addEventListener('sourceopen', sourceOpen);
} else {
console.error('Unsupported MIME type or codec: ', mimeCodec);
}

function sourceOpen () {
//console.log(this.readyState); // open
var mediaSource = this;
var sourceBuffer = mediaSource.addSourceBuffer(mimeCodec);
fetchAB(assetURL, function (buf) {
sourceBuffer.addEventListener('updateend', function (
) {
mediaSource.endOfStream();
video.play();
//console.log(mediaSource.readyState); // ended
});
sourceBuffer.appendBuffer(buf);
});
};

function fetchAB (url, cb) {
console.log(url);
var xhr = new XMLHttpRequest;
xhr.open('get', url);
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
cb(xhr.response);
};
xhr.send();
};

But it uses some specific codec formats which are not supported by some mp4 videos. Can you check this and add this in media player so that it automatically checks each codec format for the given video and then show the blob URL in the video src property? Or can we add this option without a specific codec format of the video?
Because if I used one mp4 video for my website maybe the other video format will be WebM which have a different codec format.

from indigo-player.

harisnaeemofficial avatar harisnaeemofficial commented on September 17, 2024

This MediaSource API works perfectly for this "frag_bunny.mp4" video. I have tried to use other videos but its getting error on every video. Means mostly downloaded videos don't have the same audio and video codec format like this one "avc1.42E01E, mp4a.40.2"

from indigo-player.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.