Skip to content

node-av / lib / avRescaleQRnd

Function: avRescaleQRnd() ​

avRescaleQRnd(a, bq, cq, rnd): bigint

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

Rescale timestamp with specified rounding mode.

Rescales a timestamp from one time base to another with specific rounding behavior. More control than avRescaleQ() which uses default rounding.

Direct mapping to av_rescale_q_rnd().

Parameters ​

a ​

number | bigint | null

Timestamp to rescale

bq ​

IRational

Source time base

cq ​

IRational

Destination time base

rnd ​

number

Rounding mode (AV_ROUND_ZERO, AV_ROUND_INF, AV_ROUND_DOWN, AV_ROUND_UP, AV_ROUND_NEAR_INF)

Returns ​

bigint

Rescaled timestamp

Example ​

typescript
import { AV_ROUND_UP, AV_ROUND_DOWN } from 'node-av/constants';

const pts = 1000n;
const srcTb = { num: 1, den: 48000 };
const dstTb = { num: 1, den: 90000 };

// Round up for safer comparisons
const ptsUp = avRescaleQRnd(pts, srcTb, dstTb, AV_ROUND_UP);

// Round down for conservative timestamps
const ptsDown = avRescaleQRnd(pts, srcTb, dstTb, AV_ROUND_DOWN);

See ​

av_rescale_q_rnd - FFmpeg Doxygen