[英]How to download mp4 video from HTML blob: URL?
How to download mp4 video using JavaScript from the <video src="blob:https//domain...>
tag. Is it even possible or it blocked within web browsers? I've tried every method I found on StackOverflow, nothing works.如何使用
<video src="blob:https//domain...>
标签中的 JavaScript 下载 mp4 视频。它甚至可能还是在 web 浏览器中被阻止?我已经尝试了我在 StackOverflow 上找到的所有方法,没有任何效果.
Sample HTML code from Gettr:来自 Gettr 的示例 HTML 代码:
<video preload="auto" controlslist="nodownload" playsinline="" webkit-playsinline="" x5-playsinline="" style="width: 100%; height: 100%;" src="blob:https://gettr.com/75e599c0-6616-4131-9d46-40c5b43d03c0"></video>
How to download this using JavaScript?如何使用 JavaScript 下载这个?
Try adding a download link like this.尝试添加这样的下载链接。 It will work if it's actually a blob mp4 file link:
如果它实际上是一个 blob mp4 文件链接,它将起作用:
<a href="blob:https://gettr.com/75e599c0-6616-4131-9d46-40c5b43d03c0" download>Download</a>
If the video url comes from a Blob
created by URL.createObjectURL(blob)
then it's posible to get the video by doing something like如果视频 url 来自由
URL.createObjectURL(blob)
创建的Blob
,则可以通过执行类似操作来获取视频
function downloadURL(url, name = null) {
const a = document.createElement('a')
a.href = url
a.download = name ?? ''
a.click()
}
const video = document.querySelector(<insert-selector-here>)
const blobURL = video.currentSrc
downloadURL(blorURL, 'video.mp4')
But if that url comes from the MediaSource
API then you won't be able to download it that easily since it is probably a video streaming.但是,如果 url 来自
MediaSource
API,那么您将无法轻松下载它,因为它可能是视频流。 Depending the way it works it could be really easy or really hard to get the video.根据它的工作方式,获取视频可能非常容易或非常困难。
https://developer.mozilla.org/en-US/docs/Web/API/MediaSourcehttps://developer.mozilla.org/en-US/docs/Web/API/MediaSource
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.