Skip to content

node-av / lib / avGcd

Function: avGcd()

avGcd(a, b): bigint

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

Calculate greatest common divisor.

Computes the GCD of two integers using FFmpeg's av_gcd(). Uses the Euclidean algorithm for efficient computation.

Direct mapping to av_gcd().

Parameters

a

First integer

number | bigint

b

Second integer

number | bigint

Returns

bigint

Greatest common divisor of a and b

Example

typescript
const gcd = avGcd(48000, 44100);
console.log(gcd); // 300

// Used for calculating LCM
const lcm = (a * b) / avGcd(a, b);

See

av_gcd - FFmpeg Doxygen