Skip to content

node-av / lib / avRescaleDelta

Function: avRescaleDelta()

avRescaleDelta(inTb, inTs, fsTb, duration, lastRef, outTb): bigint

Defined in: src/lib/utilities.ts:891

Rescale a timestamp while preserving accuracy with coarse input timebases.

Used for audio streamcopy to maintain accuracy when input timebase is coarse. Direct mapping to av_rescale_delta().

Parameters

inTb

IRational

Input timebase

inTs

Input timestamp

number | bigint

fsTb

IRational

Duration timebase (e.g., {1, sampleRate})

duration

number

Duration in fsTb units

lastRef

Reference object with value property (modified by function)

value

bigint

Last output timestamp (bigint)

outTb

IRational

Output timebase

Returns

bigint

Rescaled timestamp

Example

typescript
const inTb = { num: 1, den: 48000 };
const inTs = 1000000n;
const fsTb = { num: 1, den: 44100 };
const duration = 1024;
const lastRef = { value: 0n };
const outTb = { num: 1, den: 96000 };

const rescaled = avRescaleDelta(inTb, inTs, fsTb, duration, lastRef, outTb);

See

av_rescale_delta - FFmpeg Doxygen