This repository has been archived by the owner on Nov 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
index.html
68 lines (55 loc) · 2.14 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html>
<head>
<title>frame-grab.js development testing</title>
<script src="/client/lib/rsvp.js"></script>
<script src="/dist/frame-grab.min.js"></script>
</head>
<body>
<input type="file" id="videoFileInput">
<div id="videoContainer"></div>
<button id="grabCurrentFrame">Grab the current frame</button>
<button id="generateSummary">Create a summary, in images</button>
<div id="frameGrabs"></div>
</body>
<script>
document.getElementById("videoFileInput").onchange = function() {
var file = this.files[0];
FrameGrab.blob_to_video(file).then(
function videoRendered(videoEl) {
var frameGrabInstance = new FrameGrab({video: videoEl});
videoEl.setAttribute("controls", "");
document.getElementById("videoContainer").appendChild(videoEl);
document.getElementById("generateSummary").onclick = function() {
var numImages = parseInt(window.prompt("How many images?"));
if (numImages) {
frameGrabInstance.make_story("canvas", numImages).then(
function generated(storyEntries) {
storyEntries.forEach(function(storyEntry) {
document.getElementById("frameGrabs").appendChild(storyEntry.container);
});
},
function failureToGenerate(reason) {
// TODO Handle failure to generate a story from the video.
}
);
}
};
document.getElementById("grabCurrentFrame").onclick = function() {
frameGrabInstance.grab_now("canvas").then(
function grabbed(itemEntry) {
document.getElementById("frameGrabs").appendChild(itemEntry.container);
},
function failedToGrab(reason) {
// TODO Handle failure to turn the video frame into a `<canvas>`.
}
);
};
},
function videoFailedToRender(reason) {
// TODO handle failure to convert the file to a video element
}
);
};
</script>
</html>