12 lines
357 B
TypeScript
12 lines
357 B
TypeScript
|
import { Duration } from '../generated/google/protobuf/duration';
|
||
|
|
||
|
function framesToDuration(frames: number, sampleRate: number): Duration {
|
||
|
const secs = Math.floor(frames / sampleRate);
|
||
|
const nanos = Math.floor(
|
||
|
((frames % sampleRate) / sampleRate) * 1_000_000_000
|
||
|
);
|
||
|
return { seconds: secs, nanos: nanos };
|
||
|
}
|
||
|
|
||
|
export default framesToDuration;
|