-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
48 lines (45 loc) · 1.43 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Images To Video</title>
<link rel="stylesheet" href="index.css"/>
</head>
<body>
<section>
<canvas id="myCanvas" class="myCanvas"></canvas>
<button>
<label for="file">选择图片</label>
<input type="file" name="file" id="file" accept="image/*" multiple onchange="fileChange(this)">
</button>
<button onclick="download()">下载视频</button>
<video id="myVideo" controls="controls" class="myVideo" style="display: none;"></video>
</section>
<script src="images-to-video.js"></script>
<script src="index.js"></script>
<script>
let video
const fileChange = async (input) => {
const files = input.files
if(!files || files.length === 0) return
const fileList = Object.keys(files).map(key => {
const file = files[key]
return {
file,
name: file?.name,
src: URL.createObjectURL(file)
}
})
video = await startRecord(document.getElementById('myCanvas'), fileList)
console.log('video', video)
document.getElementById('myVideo').src = video?.src
document.getElementById('myVideo').style.display = `block`
}
const download = () => {
if (!video) return
downloadVideo({ name: video.name, blob: video.blob })
}
</script>
</body>
</html>