直接通过这个html代码实现base64编码转视频二进制下载
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Base64 数据输入与下载</title>
</head>
<body>
<!-- textarea 用于输入 Base64 数据 -->
<textarea id="base64Input" rows="10" cols="50" placeholder="请输入 Base64 编码的数据"></textarea>
<br>
<!-- 按钮用于触发下载操作 -->
<button id="downloadButton">下载文件</button>
<script>
const base64Input = document.getElementById('base64Input');
const downloadButton = document.getElementById('downloadButton');
downloadButton.addEventListener('click', () => {
const base64Data = base64Input.value;
if (!base64Data) {
alert('请输入有效的 Base64 数据');
return;
}
try {
// 提取 Base64 数据部分,去除前缀
// 将 Base64 转换为二进制数据
const binaryString = window.atob(base64Data);
const binaryLength = binaryString.length;
const bytes = new Uint8Array(binaryLength);
for (let i = 0; i < binaryLength; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
// 创建 Blob 对象
const blob = new Blob([bytes], { });
// 创建下载链接
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
// 根据 MIME 类型生成默认文件名
fileName = 'downloaded_file.mp4';
a.download = fileName;
a.style.display = 'none';
document.body.appendChild(a);
// 触发下载
a.click();
// 释放临时 URL
URL.revokeObjectURL(url);
document.body.removeChild(a);
} catch (error) {
alert('输入的 Base64 数据无效,请检查后重试。');
}
});
</script>
</body>
</html> 网友回复
阿里云ESA、cloudflare worker、腾讯云EdgeOne网站代理托管哪家更好?
剪映能打开.fcpxml格式的文件吗?
增量式编码器与绝对式编码器的区别是啥?
有没有开源的单张照片或者序列帧图片或视频就能重建4d场景动画项目?
chrome网页突然报错:错误代码:RESULT_CODE_KILLED_BAD_MESSAGE
openai的codex如何全程无需手动确认自动修改文件?
阿里云oss前端上传文件直传如何限制文件类型?
阿里云oss前端获取policy签名直传oss上传文件回调如何传?
如何将根据三维物体通过提示词变成可交互的4d场景动画?
浏览器中实时摄像头离线视觉ai模型有吗?


