eachFrame = async (src, framerate, limit = -1, start = 0, options = {}) => {
const debugLabel = `eachFrame on ${JSON.stringify({
src,
framerate,
limit,
start,
options
})}`;
if (options.debug) console.time(debugLabel);
const duration =
options.duration === undefined
? await vidvid.info(src, options).then(info => info.duration)
: options.duration;
const numFrames = limit == -1 ? duration * framerate - start : limit;
const framesArray = new Map();
for (let i = start; i < numFrames; i++) {
const t = i / framerate;
framesArray.set(i, await frameAt(src, t, options));
}
if (options.debug) console.timeEnd(debugLabel);
return framesArray;
}