/**
* This test aims to check if the video is seamless looping by capturing the
* image when loop happens. We use a video contains only white frames, so the
* captured frame should always be a white frame. If looping is not seamless,
* the captured frame would become a black frame.
*/
const WIDTH = 10, HEIGHT = 10;
info(`load video which only contains white frames`);
let video = document.getElementById("v"); video.loop = true; video.src = "white-short.webm"; video.width = WIDTH; video.height = HEIGHT;
await video.play();
info(`test seamless looping multiples times`);
let MAX_LOOPING_COUNT = 10;
for (let count = 0; count < MAX_LOOPING_COUNT; count++) {
await once(video, "seeking");
assertPaintedFrameIsWhiteFrame();
await once(video, "seeked");
ok(true, `the round ${count} of the seamless looping succeeds`);
}
});
function assertPaintedFrameIsWhiteFrame() {
info(`catpure image from video`);
const cvs = document.getElementById("canvas");
let context = cvs.getContext('2d');
if (!context) {
ok(false, "can't get 2d context");
}
context.drawImage(document.getElementById("v"), 0, 0, WIDTH, HEIGHT);
let imageData = context.getImageData(0, 0, WIDTH, HEIGHT);
for (let idx = 0; idx < WIDTH * HEIGHT; idx++) {
let pixelCount = 4 * idx; // RGBA
let data = imageData.data;
// White frame's RGB value should be [255,255,255]
is(data[pixelCount + 0], 255, `R should be 255`);
is(data[pixelCount + 1], 255, `G should be 255`);
is(data[pixelCount + 2], 255, `B should be 255`);
}
}
</script>
<body>
</body>
</html>
Messung V0.5
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.