Search code examples
javascriptxmlhttprequestblobfilereaderarraybuffer

Read data from blob url


I've preload a mp4 video with xhr and save it to a blob url

xhr.responseType = 'blob'
// xhr send and get response
var url = URL.createObjectURL(xhr.response);
player.src(url);
// It's worked, it's playable and seekable.
//url = blob url string

Now I need to process that video so I need to get data back as arrayBuffer, how to get data (blob object) back when you have blob url blob:http://domain/9d0d26c3-b7ba-4302-9186-d23c6ad53bd5


Solution

  • I've done some research because I'm also interessted in this question and I think the only possibility is do to a XHR request. I think it was already disscussed here: How to get a file or blob from an object URL?

    If you have a blob you can convert it with FileReader to a ArrayBuffer. But maybe also the following could work:

    xhr.responseType = 'arraybuffer';