Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions samples/video-decode-display/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ function start({dataUri, rendererName, canvas}) {
break;
}

let lastTimestamp = -Infinity;

// Set up a VideoDecoder.
const decoder = new VideoDecoder({
output(frame) {
Expand All @@ -70,6 +72,14 @@ function start({dataUri, rendererName, canvas}) {
setStatus("render", `${fps.toFixed(0)} fps`);
}

if (frame.timestamp < lastTimestamp) {
console.error(`Decoded frame ${frame.timestamp} µs out of order, last frame was ${lastTimestamp} µs`);
} else {
console.log(`Decoded frame ${frame.timestamp} µs`);
}

lastTimestamp = frame.timestamp;

// Schedule the frame to be rendered.
renderFrame(frame);
},
Expand Down