Skip to content

node-av / lib / dtsPredict

Function: dtsPredict()

dtsPredict(packet, stream, state): DtsPredictState

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

Predict and update DTS timestamps for demuxed packets.

This is a native implementation of FFmpeg's ist_dts_update(). It predicts the next DTS based on codec type and stream metadata, handling both audio (sample-based) and video (frame-rate-based) timing.

Parameters

packet

NativeWrapper<NativePacket>

Native Packet

stream

NativeWrapper<NativeStream>

Native Stream

state

DtsPredictState

Current DTS prediction state

Returns

DtsPredictState

Updated state with new DTS values

Example

typescript
const newState = dtsPredict(packet, stream, {
  sawFirstTs: false,
  dts: AV_NOPTS_VALUE,
  nextDts: AV_NOPTS_VALUE,
  firstDts: AV_NOPTS_VALUE,
});