Ivan Bacher
Ivan Bacher

Reputation: 6154

Specifying the name of a video when src is dataURL

Using JS I creating a video from a series of screen grabs from a canvas element. E.g.

let encoder = new Whammy.Video(25); //25 is fps

for(...) {
  //do stuff on canvas every x ms
  ....

  //get a dataURL from the canvas
  let dataURL = canvas.toDataURL('image/webp');

  //add the dataURL to the encoder
  encoder.add(dataURL);
}

// Now we want to create a video from the array of data urls

encoder.compile(false, (webm_output) => {

  //webm_output is a blob

  //create dataURL from blob
  let url = URL.createObjectURL(webm_output);

  let vid = documentGetElementById('myVid');

  vid.src = url;   

 })




This all works, however, if the user would like to download the video (using in built controls), the name of the video is a random string.

Is it possible to manually specify the name?

Upvotes: 3

Views: 177

Answers (1)

silentw
silentw

Reputation: 4885

On this demo:

<a style="" id="download" download="clock.webm" href="blob:[blob-url]">Download WebM</a>

The video name and extension is provided using the download= attribute.

Upvotes: 1

Related Questions