Convert blob URL to normal URL

another way to create a data url from blob url may be using canvas.

var canvas = document.createElement("canvas")
var context = canvas.getContext("2d")
context.drawImage(img, 0, 0) // i assume that img.src is your blob url
var dataurl = canvas.toDataURL("your prefer type", your prefer quality)

as what i saw in mdn, canvas.toDataURL is supported well by browsers. (except ie<9, always ie<9)


A URL that was created from a JavaScript Blob can not be converted to a "normal" URL.

A blob: URL does not refer to data the exists on the server, it refers to data that your browser currently has in memory, for the current page. It will not be available on other pages, it will not be available in other browsers, and it will not be available from other computers.

Therefore it does not make sense, in general, to convert a Blob URL to a "normal" URL. If you wanted an ordinary URL, you would have to send the data from the browser to a server and have the server make it available like an ordinary file.

It is possible convert a blob: URL into a data: URL, at least in Chrome. You can use an AJAX request to "fetch" the data from the blob: URL (even though it's really just pulling it out of your browser's memory, not making an HTTP request).

Here's an example:

var blob = new Blob(["Hello, world!"], { type: 'text/plain' });
var blobUrl = URL.createObjectURL(blob);

var xhr = new XMLHttpRequest;
xhr.responseType = 'blob';

xhr.onload = function() {
   var recoveredBlob = xhr.response;

   var reader = new FileReader;

   reader.onload = function() {
     var blobAsDataUrl = reader.result;
     window.location = blobAsDataUrl;
   };

   reader.readAsDataURL(recoveredBlob);
};

xhr.open('GET', blobUrl);
xhr.send();

data: URLs are probably not what you mean by "normal" and can be problematically large. However they do work like normal URLs in that they can be shared; they're not specific to the current browser or session.


For those who came here looking for a way to download a blob url video / audio, this answer worked for me. In short, you would need to find an *.m3u8 file on the desired web page through Chrome -> Network tab and paste it into a VLC player.

Another guide shows you how to save a stream with the VLC Player.


UPDATE:

An alternative way of downloading the videos from a blob url is by using the mass downloader and joining the files together.

Download Videos Part

  1. Open network tab in chrome dev tools

enter image description here

  1. Reload the webpage
  2. Filter .m3u8 files

enter image description here

  1. Look through all filtered files and find the playlist of the '.ts' files. It should look something like this:

enter image description here

  1. You need to extract those links somehow. Either download and edit the file manually OR use any other method you like. As you can see, those links are very similar, the only thing that differs is the serial number of the video: 's-0-v1-a1.ts', 's-1-v1-a1.ts' etc.

    https://some-website.net/del/8cf.m3u8/s-0-v1-a1.ts

    https://some-website.net/del/8cf.m3u8/s-1-v1-a1.ts 


    https://some-website.net/del/8cf.m3u8/s-2-v1-a1.ts


and so on up to the last link in the .m3u8 playlist file. These .ts files are actually your video. You need to download all of them.

  1. For bulk downloading I prefer using the Simple Mass Downloader extension for Chrome (https://chrome.google.com/webstore/detail/simple-mass-downloader/abdkkegmcbiomijcbdaodaflgehfffed)

  2. If you opt in for the Simple Mass Downloader, you need to:

    a. Select a Pattern URL

enter image description here

b. Enter your link in the address field with only one modification: that part of the link that is changing for each next video needs to be replaced with the pattern in square brackets [0:400] where 0 is the first file name and 400 is the last one. So your link should look something like this https://some-website.net/del/8cf.m3u8/s-[0:400]-v1-a1.ts.

Afterwards hit the Import button to add these links into the Download List of Mass Downloader.

enter image description here

c. The next action may ask you for the destination folder for EACH video you download. So it is highly recommended to specify the default download folder in Chrome Settings and disable the Select Destination option in Chrome Settings as well. This will save you a lot of time! Additionally you may want you specify the folder where these files will go to:

enter image description here

c1. Click on Select All checkbox to select all files from the Download List.

enter image description here

c2. Click on the Download button in the bottom right corner of the SMD extension window. It will take you to next tab to start downloading

enter image description here

c3. Hit Start selected. This will download all vids automatically into the download folder.

enter image description here

That is it! Simply wait till all files are downloaded and you can watch them via the VLC Player or any other player that supports the .ts format. However, if you want to have one video instead of those you have downloaded, you need to join all these mini-videos together

Joining Videos Part

Since I am working on Mac, I am not aware of how you would do this on Windows. If you are the Windows user and you want to merge the videos, feel free to google for the windows solution. The next steps are applicable for Mac only.

  1. Open Terminal in the folder you want the new video to be saved in
  2. Type: cat and hit space
  3. Open the folder where you downloaded your .ts video. Select all .ts videos that you want to join (use your mouse or cmd+A)
  4. Drag and drop them into the terminal
  5. Hit space
  6. Hit >
  7. Hit Space
  8. Type the name of the new video, e.g. my_new_video.ts. Please note that the format has to be the same as in the original videos, otherwise it will take long time to convert and even may fail!
  9. Hit Enter. Wait for the terminal to finish the joining process and enjoy watching your video!