clipper/frontend/src/helpers/framesToDuration.ts

12 lines
357 B
TypeScript
Raw Normal View History

2022-01-15 08:34:56 +00:00
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;