MCPcopy Index your code
hub / github.com/midrender/revideo / getWorkerFirstAndLastFrame

Function getWorkerFirstAndLastFrame

packages/renderer/client/render.ts:108–126  ·  view source on GitHub ↗
(
  firstGlobalFrame: number,
  lastGlobalFrame: number,
  workerId: number,
  totalNumOfWorkers: number,
)

Source from the content-addressed store, hash-verified

106}
107
108async function getWorkerFirstAndLastFrame(
109 firstGlobalFrame: number,
110 lastGlobalFrame: number,
111 workerId: number,
112 totalNumOfWorkers: number,
113) {
114 const videoDurationInFrames = lastGlobalFrame - firstGlobalFrame;
115 const framesPerWorker = Math.ceil(videoDurationInFrames / totalNumOfWorkers);
116
117 const offset = workerId === 0 ? 0 : 1;
118 const firstWorkerFrame =
119 firstGlobalFrame + framesPerWorker * workerId + offset;
120 const lastWorkerFrame = Math.min(
121 firstWorkerFrame + framesPerWorker - offset,
122 lastGlobalFrame,
123 );
124
125 return {firstWorkerFrame, lastWorkerFrame};
126}

Callers 1

renderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected