node-av 3.1.3 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -52
- package/binding.gyp +23 -11
- package/dist/api/audio-frame-buffer.d.ts +201 -0
- package/dist/api/audio-frame-buffer.js +275 -0
- package/dist/api/audio-frame-buffer.js.map +1 -0
- package/dist/api/bitstream-filter.d.ts +320 -78
- package/dist/api/bitstream-filter.js +684 -151
- package/dist/api/bitstream-filter.js.map +1 -1
- package/dist/api/constants.d.ts +44 -0
- package/dist/api/constants.js +45 -0
- package/dist/api/constants.js.map +1 -0
- package/dist/api/data/test_av1.ivf +0 -0
- package/dist/api/data/test_mjpeg.mjpeg +0 -0
- package/dist/api/data/test_vp8.ivf +0 -0
- package/dist/api/data/test_vp9.ivf +0 -0
- package/dist/api/decoder.d.ts +454 -77
- package/dist/api/decoder.js +1081 -271
- package/dist/api/decoder.js.map +1 -1
- package/dist/api/{media-input.d.ts → demuxer.d.ts} +295 -45
- package/dist/api/demuxer.js +1965 -0
- package/dist/api/demuxer.js.map +1 -0
- package/dist/api/encoder.d.ts +423 -132
- package/dist/api/encoder.js +1089 -240
- package/dist/api/encoder.js.map +1 -1
- package/dist/api/filter-complex.d.ts +769 -0
- package/dist/api/filter-complex.js +1596 -0
- package/dist/api/filter-complex.js.map +1 -0
- package/dist/api/filter-presets.d.ts +80 -5
- package/dist/api/filter-presets.js +117 -7
- package/dist/api/filter-presets.js.map +1 -1
- package/dist/api/filter.d.ts +561 -125
- package/dist/api/filter.js +1083 -274
- package/dist/api/filter.js.map +1 -1
- package/dist/api/{fmp4.d.ts → fmp4-stream.d.ts} +141 -140
- package/dist/api/fmp4-stream.js +539 -0
- package/dist/api/fmp4-stream.js.map +1 -0
- package/dist/api/hardware.d.ts +58 -6
- package/dist/api/hardware.js +127 -11
- package/dist/api/hardware.js.map +1 -1
- package/dist/api/index.d.ts +8 -4
- package/dist/api/index.js +17 -8
- package/dist/api/index.js.map +1 -1
- package/dist/api/io-stream.d.ts +6 -6
- package/dist/api/io-stream.js +5 -4
- package/dist/api/io-stream.js.map +1 -1
- package/dist/api/{media-output.d.ts → muxer.d.ts} +280 -66
- package/dist/api/muxer.js +1934 -0
- package/dist/api/muxer.js.map +1 -0
- package/dist/api/pipeline.d.ts +77 -29
- package/dist/api/pipeline.js +449 -439
- package/dist/api/pipeline.js.map +1 -1
- package/dist/api/rtp-stream.d.ts +312 -0
- package/dist/api/rtp-stream.js +630 -0
- package/dist/api/rtp-stream.js.map +1 -0
- package/dist/api/types.d.ts +533 -56
- package/dist/api/utilities/async-queue.d.ts +91 -0
- package/dist/api/utilities/async-queue.js +162 -0
- package/dist/api/utilities/async-queue.js.map +1 -0
- package/dist/api/utilities/audio-sample.d.ts +11 -1
- package/dist/api/utilities/audio-sample.js +10 -0
- package/dist/api/utilities/audio-sample.js.map +1 -1
- package/dist/api/utilities/channel-layout.d.ts +1 -0
- package/dist/api/utilities/channel-layout.js +1 -0
- package/dist/api/utilities/channel-layout.js.map +1 -1
- package/dist/api/utilities/image.d.ts +39 -1
- package/dist/api/utilities/image.js +38 -0
- package/dist/api/utilities/image.js.map +1 -1
- package/dist/api/utilities/index.d.ts +3 -0
- package/dist/api/utilities/index.js +6 -0
- package/dist/api/utilities/index.js.map +1 -1
- package/dist/api/utilities/media-type.d.ts +2 -1
- package/dist/api/utilities/media-type.js +1 -0
- package/dist/api/utilities/media-type.js.map +1 -1
- package/dist/api/utilities/pixel-format.d.ts +4 -1
- package/dist/api/utilities/pixel-format.js +3 -0
- package/dist/api/utilities/pixel-format.js.map +1 -1
- package/dist/api/utilities/sample-format.d.ts +6 -1
- package/dist/api/utilities/sample-format.js +5 -0
- package/dist/api/utilities/sample-format.js.map +1 -1
- package/dist/api/utilities/scheduler.d.ts +138 -0
- package/dist/api/utilities/scheduler.js +98 -0
- package/dist/api/utilities/scheduler.js.map +1 -0
- package/dist/api/utilities/streaming.d.ts +105 -15
- package/dist/api/utilities/streaming.js +201 -12
- package/dist/api/utilities/streaming.js.map +1 -1
- package/dist/api/utilities/timestamp.d.ts +15 -1
- package/dist/api/utilities/timestamp.js +14 -0
- package/dist/api/utilities/timestamp.js.map +1 -1
- package/dist/api/utilities/whisper-model.d.ts +310 -0
- package/dist/api/utilities/whisper-model.js +528 -0
- package/dist/api/utilities/whisper-model.js.map +1 -0
- package/dist/api/webrtc-stream.d.ts +288 -0
- package/dist/api/webrtc-stream.js +440 -0
- package/dist/api/webrtc-stream.js.map +1 -0
- package/dist/api/whisper.d.ts +324 -0
- package/dist/api/whisper.js +362 -0
- package/dist/api/whisper.js.map +1 -0
- package/dist/constants/constants.d.ts +54 -2
- package/dist/constants/constants.js +48 -1
- package/dist/constants/constants.js.map +1 -1
- package/dist/constants/encoders.d.ts +2 -1
- package/dist/constants/encoders.js +4 -3
- package/dist/constants/encoders.js.map +1 -1
- package/dist/constants/hardware.d.ts +26 -0
- package/dist/constants/hardware.js +27 -0
- package/dist/constants/hardware.js.map +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +1 -0
- package/dist/constants/index.js.map +1 -1
- package/dist/ffmpeg/index.d.ts +3 -3
- package/dist/ffmpeg/index.js +3 -3
- package/dist/ffmpeg/utils.d.ts +27 -0
- package/dist/ffmpeg/utils.js +28 -16
- package/dist/ffmpeg/utils.js.map +1 -1
- package/dist/lib/binding.d.ts +22 -11
- package/dist/lib/binding.js.map +1 -1
- package/dist/lib/codec-context.d.ts +87 -0
- package/dist/lib/codec-context.js +125 -4
- package/dist/lib/codec-context.js.map +1 -1
- package/dist/lib/codec-parameters.d.ts +229 -1
- package/dist/lib/codec-parameters.js +264 -0
- package/dist/lib/codec-parameters.js.map +1 -1
- package/dist/lib/codec-parser.d.ts +23 -0
- package/dist/lib/codec-parser.js +25 -0
- package/dist/lib/codec-parser.js.map +1 -1
- package/dist/lib/codec.d.ts +26 -4
- package/dist/lib/codec.js +35 -0
- package/dist/lib/codec.js.map +1 -1
- package/dist/lib/dictionary.js +1 -0
- package/dist/lib/dictionary.js.map +1 -1
- package/dist/lib/error.js +1 -1
- package/dist/lib/error.js.map +1 -1
- package/dist/lib/fifo.d.ts +416 -0
- package/dist/lib/fifo.js +453 -0
- package/dist/lib/fifo.js.map +1 -0
- package/dist/lib/filter-context.d.ts +52 -11
- package/dist/lib/filter-context.js +56 -12
- package/dist/lib/filter-context.js.map +1 -1
- package/dist/lib/filter-graph.d.ts +9 -0
- package/dist/lib/filter-graph.js +13 -0
- package/dist/lib/filter-graph.js.map +1 -1
- package/dist/lib/filter.d.ts +21 -0
- package/dist/lib/filter.js +28 -0
- package/dist/lib/filter.js.map +1 -1
- package/dist/lib/format-context.d.ts +48 -14
- package/dist/lib/format-context.js +76 -7
- package/dist/lib/format-context.js.map +1 -1
- package/dist/lib/frame.d.ts +264 -1
- package/dist/lib/frame.js +351 -1
- package/dist/lib/frame.js.map +1 -1
- package/dist/lib/hardware-device-context.d.ts +3 -2
- package/dist/lib/hardware-device-context.js.map +1 -1
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.js +4 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/input-format.d.ts +21 -0
- package/dist/lib/input-format.js +42 -2
- package/dist/lib/input-format.js.map +1 -1
- package/dist/lib/native-types.d.ts +76 -27
- package/dist/lib/option.d.ts +25 -13
- package/dist/lib/option.js +28 -0
- package/dist/lib/option.js.map +1 -1
- package/dist/lib/output-format.d.ts +22 -1
- package/dist/lib/output-format.js +28 -0
- package/dist/lib/output-format.js.map +1 -1
- package/dist/lib/packet.d.ts +35 -0
- package/dist/lib/packet.js +52 -2
- package/dist/lib/packet.js.map +1 -1
- package/dist/lib/rational.d.ts +18 -0
- package/dist/lib/rational.js +19 -0
- package/dist/lib/rational.js.map +1 -1
- package/dist/lib/stream.d.ts +126 -0
- package/dist/lib/stream.js +188 -5
- package/dist/lib/stream.js.map +1 -1
- package/dist/lib/sync-queue.d.ts +179 -0
- package/dist/lib/sync-queue.js +197 -0
- package/dist/lib/sync-queue.js.map +1 -0
- package/dist/lib/types.d.ts +49 -1
- package/dist/lib/utilities.d.ts +281 -53
- package/dist/lib/utilities.js +298 -55
- package/dist/lib/utilities.js.map +1 -1
- package/install/check.js +2 -2
- package/package.json +37 -26
- package/dist/api/fmp4.js +0 -710
- package/dist/api/fmp4.js.map +0 -1
- package/dist/api/media-input.js +0 -1075
- package/dist/api/media-input.js.map +0 -1
- package/dist/api/media-output.js +0 -1040
- package/dist/api/media-output.js.map +0 -1
- package/dist/api/webrtc.d.ts +0 -664
- package/dist/api/webrtc.js +0 -1132
- package/dist/api/webrtc.js.map +0 -1
package/dist/lib/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Types that are used across multiple modules but are not
|
|
5
5
|
* directly from FFmpeg constants.
|
|
6
6
|
*/
|
|
7
|
-
import type { AVLogLevel, AVMediaType } from '../constants/constants.ts';
|
|
7
|
+
import type { AVCodecID, AVLogLevel, AVMediaType, AVPixelFormat, AVSampleFormat } from '../constants/constants.ts';
|
|
8
8
|
/**
|
|
9
9
|
* Rational number (fraction) interface
|
|
10
10
|
* Maps to AVRational in FFmpeg
|
|
@@ -16,6 +16,15 @@ export interface IRational {
|
|
|
16
16
|
/** Denominator */
|
|
17
17
|
den: number;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Video dimension interface
|
|
21
|
+
*/
|
|
22
|
+
export interface IDimension {
|
|
23
|
+
/** Width in pixels */
|
|
24
|
+
width: number;
|
|
25
|
+
/** Height in pixels */
|
|
26
|
+
height: number;
|
|
27
|
+
}
|
|
19
28
|
/**
|
|
20
29
|
* Audio channel layout description
|
|
21
30
|
* Maps to AVChannelLayout in FFmpeg
|
|
@@ -91,3 +100,42 @@ export interface ImageOptions {
|
|
|
91
100
|
crop?: ImageCrop;
|
|
92
101
|
resize?: ImageResize;
|
|
93
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Video Frame
|
|
105
|
+
*/
|
|
106
|
+
export interface VideoFrame {
|
|
107
|
+
width: number;
|
|
108
|
+
height: number;
|
|
109
|
+
format: AVPixelFormat;
|
|
110
|
+
timeBase?: IRational;
|
|
111
|
+
sampleAspectRatio?: IRational;
|
|
112
|
+
pts?: bigint;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Audio Frame
|
|
116
|
+
*/
|
|
117
|
+
export interface AudioFrame {
|
|
118
|
+
nbSamples: number;
|
|
119
|
+
format: AVSampleFormat;
|
|
120
|
+
sampleRate: number;
|
|
121
|
+
channelLayout: ChannelLayout;
|
|
122
|
+
timeBase?: IRational;
|
|
123
|
+
pts?: bigint;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* RTSP stream information interface
|
|
127
|
+
* Maps to RTSPStreamInfo returned by FormatContext.getRTSPStreamInfo()
|
|
128
|
+
*/
|
|
129
|
+
export interface RTSPStreamInfo {
|
|
130
|
+
streamIndex: number;
|
|
131
|
+
controlUrl: string;
|
|
132
|
+
transport: 'tcp' | 'udp' | 'udp_multicast' | 'unknown';
|
|
133
|
+
payloadType: number;
|
|
134
|
+
codecId: AVCodecID;
|
|
135
|
+
mediaType: 'video' | 'audio' | 'data' | 'subtitle' | 'unknown';
|
|
136
|
+
mimeType: string;
|
|
137
|
+
sampleRate?: number;
|
|
138
|
+
channels?: number;
|
|
139
|
+
direction: 'sendonly' | 'recvonly' | 'sendrecv' | 'inactive';
|
|
140
|
+
fmtp?: string;
|
|
141
|
+
}
|
package/dist/lib/utilities.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { AVCodecID, AVMediaType, AVPixelFormat, AVSampleFormat } from '../constants/constants.js';
|
|
1
|
+
import type { AVCodecID, AVHWDeviceType, AVMediaType, AVPixelFormat, AVSampleFormat } from '../constants/constants.js';
|
|
2
|
+
import type { FFHWDeviceType } from '../constants/hardware.js';
|
|
2
3
|
import type { FormatContext } from './format-context.js';
|
|
3
4
|
import type { NativeCodecParameters, NativeWrapper } from './native-types.js';
|
|
4
5
|
import type { ChannelLayout, IRational } from './types.js';
|
|
@@ -197,78 +198,49 @@ export declare function avSampleFmtIsPlanar(sampleFmt: AVSampleFormat): boolean;
|
|
|
197
198
|
*/
|
|
198
199
|
export declare function avGetCodecName(codecId: AVCodecID): string | null;
|
|
199
200
|
/**
|
|
200
|
-
* Get
|
|
201
|
+
* Get RFC 6381 codec string from codec parameters.
|
|
201
202
|
*
|
|
202
|
-
* Generates codec strings for MPEG-DASH manifests following RFC 6381.
|
|
203
|
-
* Uses FFmpeg's
|
|
204
|
-
*
|
|
205
|
-
* Supported codecs:
|
|
206
|
-
* - **WebM codecs**: VP8, VP9 (detailed), Vorbis, Opus, FLAC
|
|
207
|
-
* - **H.264** (avc1): `avc1.PPCCLL` (profile, constraints, level)
|
|
208
|
-
* - **HEVC** (hvc1/hev1): Base tag only (`hvc1` or `hev1`) - no profile details
|
|
209
|
-
* - **AV1** (av01): `av01.P.LLT.BB...` (profile, level, tier, bitdepth, etc.)
|
|
210
|
-
* - **AAC** (mp4a): `mp4a.OT.AOT` (object type, audio object type)
|
|
211
|
-
*
|
|
212
|
-
* Note: For HLS with detailed HEVC codec strings, use {@link avGetCodecStringHls}.
|
|
213
|
-
*
|
|
214
|
-
* @param codecpar - Codec parameters
|
|
215
|
-
*
|
|
216
|
-
* @returns DASH codec string, or null if cannot be determined
|
|
217
|
-
*
|
|
218
|
-
* @example
|
|
219
|
-
* ```typescript
|
|
220
|
-
* import { avGetCodecStringDash } from 'node-av/lib';
|
|
221
|
-
*
|
|
222
|
-
* // Get codec string from DASH output stream
|
|
223
|
-
* const stream = dashOutput.video();
|
|
224
|
-
* const codecString = avGetCodecStringDash(stream.codecpar);
|
|
225
|
-
* console.log(codecString); // "hev1" for HEVC, "avc1.42c01e" for H.264
|
|
226
|
-
*
|
|
227
|
-
* // Use for DASH manifest
|
|
228
|
-
* const mimeType = `video/mp4; codecs="${codecString}"`;
|
|
229
|
-
* ```
|
|
230
|
-
*
|
|
231
|
-
* @see [RFC 6381](https://tools.ietf.org/html/rfc6381) - RFC 6381: Codecs Parameter Specification
|
|
232
|
-
* @see [dashenc](https://ffmpeg.org/doxygen/trunk/dashenc_8c_source.html#l00345) - FFmpeg dashenc.c implementation
|
|
233
|
-
*/
|
|
234
|
-
export declare function avGetCodecStringDash(codecpar: NativeWrapper<NativeCodecParameters>): string | null;
|
|
235
|
-
/**
|
|
236
|
-
* Get HLS codec string from codec parameters.
|
|
237
|
-
*
|
|
238
|
-
* Generates codec strings for HLS playlists. Uses FFmpeg's hlsenc.c implementation.
|
|
239
|
-
* Provides detailed HEVC codec strings with profile, tier, level, and constraints.
|
|
203
|
+
* Generates codec strings for MPEG-DASH and HLS manifests following RFC 6381.
|
|
204
|
+
* Uses FFmpeg's centralized ff_make_codec_str() implementation (libavformat/codecstring.c).
|
|
240
205
|
*
|
|
241
206
|
* Supported codecs:
|
|
207
|
+
* - **WebM codecs**: VP8, VP9 (with detailed profile/level), Vorbis, Opus, FLAC
|
|
242
208
|
* - **H.264** (avc1): `avc1.PPCCLL` (profile, constraints, level)
|
|
243
209
|
* - **HEVC** (hvc1): `hvc1.P.PC.TL.C` (profile, profile_compatibility, tier+level, constraints)
|
|
244
|
-
* - **
|
|
210
|
+
* - **AV1** (av01): `av01.P.LLT.BB...` (profile, level, tier, bitdepth, color info)
|
|
211
|
+
* - **AAC**: `mp4a.40.AOT` (audio object type)
|
|
245
212
|
* - **MP2**: `mp4a.40.33`
|
|
246
213
|
* - **MP3**: `mp4a.40.34`
|
|
247
214
|
* - **AC-3**: `ac-3`
|
|
248
215
|
* - **E-AC-3**: `ec-3`
|
|
249
|
-
*
|
|
250
|
-
* Note: For DASH manifests, use {@link avGetCodecStringDash} instead.
|
|
216
|
+
* - **MPEG-4 Visual**: `mp4v.20` (profile/level not implemented)
|
|
251
217
|
*
|
|
252
218
|
* @param codecpar - Codec parameters
|
|
253
219
|
*
|
|
254
|
-
* @
|
|
220
|
+
* @param frameRate - Optional frame rate for VP9 level calculation (only used for VP9)
|
|
221
|
+
*
|
|
222
|
+
* @returns RFC 6381 codec string, or null if codec not supported
|
|
255
223
|
*
|
|
256
224
|
* @example
|
|
257
225
|
* ```typescript
|
|
258
|
-
* import {
|
|
226
|
+
* import { avGetCodecString } from 'node-av/lib';
|
|
227
|
+
*
|
|
228
|
+
* // Get codec string for DASH/HLS manifest
|
|
229
|
+
* const stream = output.video();
|
|
230
|
+
* const codecString = avGetCodecString(stream.codecpar);
|
|
231
|
+
* console.log(codecString); // "hvc1.1.6.L93.B0" for HEVC, "avc1.42c01e" for H.264
|
|
259
232
|
*
|
|
260
|
-
* //
|
|
261
|
-
* const
|
|
262
|
-
*
|
|
263
|
-
* console.log(codecString); // "hvc1.1.6.L93.B0" - detailed HEVC profile info
|
|
233
|
+
* // VP9 with frame rate for accurate level
|
|
234
|
+
* const codecStringVP9 = avGetCodecString(stream.codecpar, { num: 30, den: 1 });
|
|
235
|
+
* console.log(codecStringVP9); // "vp09.00.30.08" - detailed VP9 string
|
|
264
236
|
*
|
|
265
|
-
* // Use for HLS
|
|
266
|
-
* const
|
|
237
|
+
* // Use for DASH/HLS manifest
|
|
238
|
+
* const mimeType = `video/mp4; codecs="${codecString}"`;
|
|
267
239
|
* ```
|
|
268
240
|
*
|
|
269
|
-
* @see [
|
|
241
|
+
* @see [codecstring.c](https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/codecstring.c) - FFmpeg implementation
|
|
270
242
|
*/
|
|
271
|
-
export declare function
|
|
243
|
+
export declare function avGetCodecString(codecpar: NativeWrapper<NativeCodecParameters>, frameRate?: IRational): string | null;
|
|
272
244
|
/**
|
|
273
245
|
* Get DASH MIME type for codec parameters.
|
|
274
246
|
*
|
|
@@ -363,6 +335,52 @@ export declare function avGetPixFmtFromName(name: string): AVPixelFormat;
|
|
|
363
335
|
* @see [av_pix_fmt_desc_get](https://ffmpeg.org/doxygen/7.1/pixdesc_8c.html#afe0c3e8aef5173de28bbdaea4298f5f0) - FFmpeg Doxygen
|
|
364
336
|
*/
|
|
365
337
|
export declare function avIsHardwarePixelFormat(pixFmt: AVPixelFormat): boolean;
|
|
338
|
+
/**
|
|
339
|
+
* Get hardware device type name.
|
|
340
|
+
*
|
|
341
|
+
* Returns the string name for a hardware device type enum value.
|
|
342
|
+
*
|
|
343
|
+
* Direct mapping to av_hwdevice_get_type_name().
|
|
344
|
+
*
|
|
345
|
+
* @param type - Hardware device type enum
|
|
346
|
+
*
|
|
347
|
+
* @returns Device type name (e.g. "videotoolbox", "cuda"), or null if unknown
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* ```typescript
|
|
351
|
+
* import { AV_HWDEVICE_TYPE_VIDEOTOOLBOX, AV_HWDEVICE_TYPE_CUDA } from 'node-av/constants';
|
|
352
|
+
*
|
|
353
|
+
* const name1 = avGetHardwareDeviceTypeName(AV_HWDEVICE_TYPE_VIDEOTOOLBOX); // Returns "videotoolbox"
|
|
354
|
+
* const name2 = avGetHardwareDeviceTypeName(AV_HWDEVICE_TYPE_CUDA); // Returns "cuda"
|
|
355
|
+
* ```
|
|
356
|
+
*
|
|
357
|
+
* @see [av_hwdevice_get_type_name](https://ffmpeg.org/doxygen/7.1/hwcontext_8h.html#afb2b99a15f3fdde25a2fd19353ac5a67) - FFmpeg Doxygen
|
|
358
|
+
*/
|
|
359
|
+
export declare function avGetHardwareDeviceTypeName(type: AVHWDeviceType): FFHWDeviceType;
|
|
360
|
+
/**
|
|
361
|
+
* Get hardware device type from name.
|
|
362
|
+
*
|
|
363
|
+
* Looks up the hardware device type enum from its string name.
|
|
364
|
+
* Returns AV_HWDEVICE_TYPE_NONE if the name is not recognized.
|
|
365
|
+
*
|
|
366
|
+
* Direct mapping to av_hwdevice_find_type_by_name().
|
|
367
|
+
*
|
|
368
|
+
* @param name - Hardware device type name (e.g. "videotoolbox", "cuda")
|
|
369
|
+
*
|
|
370
|
+
* @returns Hardware device type enum, or AV_HWDEVICE_TYPE_NONE if not found
|
|
371
|
+
*
|
|
372
|
+
* @example
|
|
373
|
+
* ```typescript
|
|
374
|
+
* import { avGetHardwareDeviceTypeFromName } from 'node-av/lib';
|
|
375
|
+
*
|
|
376
|
+
* const type1 = avGetHardwareDeviceTypeFromName("videotoolbox"); // Returns AV_HWDEVICE_TYPE_VIDEOTOOLBOX
|
|
377
|
+
* const type2 = avGetHardwareDeviceTypeFromName("cuda"); // Returns AV_HWDEVICE_TYPE_CUDA
|
|
378
|
+
* const none = avGetHardwareDeviceTypeFromName("invalid"); // Returns AV_HWDEVICE_TYPE_NONE
|
|
379
|
+
* ```
|
|
380
|
+
*
|
|
381
|
+
* @see [av_hwdevice_find_type_by_name](https://ffmpeg.org/doxygen/7.1/hwcontext_8h.html#a541943ddced791765349645a30adfa4d) - FFmpeg Doxygen
|
|
382
|
+
*/
|
|
383
|
+
export declare function avGetHardwareDeviceTypeFromName(name: FFHWDeviceType): AVHWDeviceType;
|
|
366
384
|
/**
|
|
367
385
|
* Get media type string.
|
|
368
386
|
*
|
|
@@ -698,6 +716,216 @@ export declare function avUsleep(usec: number): void;
|
|
|
698
716
|
* @see [av_rescale_rnd](https://ffmpeg.org/doxygen/7.1/group__lavu__math.html#ga82d40664213508918093822461cc597e) - FFmpeg Doxygen
|
|
699
717
|
*/
|
|
700
718
|
export declare function avRescaleRnd(a: bigint | number, b: bigint | number, c: bigint | number, rnd: number): bigint;
|
|
719
|
+
/**
|
|
720
|
+
* Rescale a timestamp while preserving accuracy with coarse input timebases.
|
|
721
|
+
*
|
|
722
|
+
* Used for audio streamcopy to maintain accuracy when input timebase is coarse.
|
|
723
|
+
* Direct mapping to av_rescale_delta().
|
|
724
|
+
*
|
|
725
|
+
* @param inTb - Input timebase
|
|
726
|
+
*
|
|
727
|
+
* @param inTs - Input timestamp
|
|
728
|
+
*
|
|
729
|
+
* @param fsTb - Duration timebase (e.g., {1, sampleRate})
|
|
730
|
+
*
|
|
731
|
+
* @param duration - Duration in fsTb units
|
|
732
|
+
*
|
|
733
|
+
* @param lastRef - Reference object with `value` property (modified by function)
|
|
734
|
+
*
|
|
735
|
+
* @param lastRef.value - Last output timestamp (bigint)
|
|
736
|
+
*
|
|
737
|
+
* @param outTb - Output timebase
|
|
738
|
+
*
|
|
739
|
+
* @returns Rescaled timestamp
|
|
740
|
+
*
|
|
741
|
+
* @example
|
|
742
|
+
* ```typescript
|
|
743
|
+
* const inTb = { num: 1, den: 48000 };
|
|
744
|
+
* const inTs = 1000000n;
|
|
745
|
+
* const fsTb = { num: 1, den: 44100 };
|
|
746
|
+
* const duration = 1024;
|
|
747
|
+
* const lastRef = { value: 0n };
|
|
748
|
+
* const outTb = { num: 1, den: 96000 };
|
|
749
|
+
*
|
|
750
|
+
* const rescaled = avRescaleDelta(inTb, inTs, fsTb, duration, lastRef, outTb);
|
|
751
|
+
* ```
|
|
752
|
+
*
|
|
753
|
+
* @see [av_rescale_delta](https://ffmpeg.org/doxygen/7.1/group__lavu__math.html) - FFmpeg Doxygen
|
|
754
|
+
*/
|
|
755
|
+
export declare function avRescaleDelta(inTb: IRational, inTs: bigint | number, fsTb: IRational, duration: number, lastRef: {
|
|
756
|
+
value: bigint;
|
|
757
|
+
}, outTb: IRational): bigint;
|
|
758
|
+
/**
|
|
759
|
+
* Multiply two rational numbers.
|
|
760
|
+
*
|
|
761
|
+
* Multiplies two rational numbers using FFmpeg's av_mul_q() which normalizes the result.
|
|
762
|
+
* This is more accurate than manual multiplication as it reduces the fraction.
|
|
763
|
+
*
|
|
764
|
+
* Direct mapping to av_mul_q().
|
|
765
|
+
*
|
|
766
|
+
* @param a - First rational number
|
|
767
|
+
*
|
|
768
|
+
* @param b - Second rational number
|
|
769
|
+
*
|
|
770
|
+
* @returns Product of a and b as a normalized rational
|
|
771
|
+
*
|
|
772
|
+
* @example
|
|
773
|
+
* ```typescript
|
|
774
|
+
* // Multiply framerate by 2
|
|
775
|
+
* const framerate = { num: 25, den: 1 };
|
|
776
|
+
* const doubled = avMulQ(framerate, { num: 2, den: 1 });
|
|
777
|
+
* // Returns { num: 50, den: 1 }
|
|
778
|
+
*
|
|
779
|
+
* // Calculate field rate for interlaced video
|
|
780
|
+
* const fieldRate = avMulQ(framerate, { num: 2, den: 1 });
|
|
781
|
+
* ```
|
|
782
|
+
*
|
|
783
|
+
* @see [av_mul_q](https://ffmpeg.org/doxygen/trunk/group__lavu__math__rational.html#ga89c0e84e30e2f90196e11fc254e4fc3f) - FFmpeg Doxygen
|
|
784
|
+
*/
|
|
785
|
+
export declare function avMulQ(a: IRational, b: IRational): IRational;
|
|
786
|
+
/**
|
|
787
|
+
* Invert a rational number.
|
|
788
|
+
*
|
|
789
|
+
* Returns the reciprocal of a rational number using FFmpeg's av_inv_q().
|
|
790
|
+
* Swaps numerator and denominator: (a/b) becomes (b/a).
|
|
791
|
+
*
|
|
792
|
+
* Direct mapping to av_inv_q().
|
|
793
|
+
*
|
|
794
|
+
* @param q - Rational number to invert
|
|
795
|
+
*
|
|
796
|
+
* @returns Inverted rational (reciprocal)
|
|
797
|
+
*
|
|
798
|
+
* @example
|
|
799
|
+
* ```typescript
|
|
800
|
+
* // Convert framerate to frame duration
|
|
801
|
+
* const framerate = { num: 25, den: 1 }; // 25 fps
|
|
802
|
+
* const frameDuration = avInvQ(framerate); // 1/25 seconds
|
|
803
|
+
* // Returns { num: 1, den: 25 }
|
|
804
|
+
*
|
|
805
|
+
* // Get timebase from framerate
|
|
806
|
+
* const timebase = avInvQ({ num: 30000, den: 1001 }); // NTSC
|
|
807
|
+
* // Returns { num: 1001, den: 30000 }
|
|
808
|
+
* ```
|
|
809
|
+
*
|
|
810
|
+
* @see [av_inv_q](https://ffmpeg.org/doxygen/trunk/group__lavu__math__rational.html#ga587a784cb48299feea51d7dbbc6cc38c) - FFmpeg Doxygen
|
|
811
|
+
*/
|
|
812
|
+
export declare function avInvQ(q: IRational): IRational;
|
|
813
|
+
/**
|
|
814
|
+
* Add two rational numbers.
|
|
815
|
+
*
|
|
816
|
+
* Adds two rational numbers using FFmpeg's av_add_q() which normalizes the result.
|
|
817
|
+
* This is more accurate than manual addition as it reduces the fraction.
|
|
818
|
+
*
|
|
819
|
+
* Direct mapping to av_add_q().
|
|
820
|
+
*
|
|
821
|
+
* @param a - First rational number
|
|
822
|
+
*
|
|
823
|
+
* @param b - Second rational number
|
|
824
|
+
*
|
|
825
|
+
* @returns Sum of a and b as a normalized rational
|
|
826
|
+
*
|
|
827
|
+
* @example
|
|
828
|
+
* ```typescript
|
|
829
|
+
* // Add two fractions
|
|
830
|
+
* const a = { num: 1, den: 2 }; // 1/2
|
|
831
|
+
* const b = { num: 1, den: 4 }; // 1/4
|
|
832
|
+
* const sum = avAddQ(a, b); // 3/4
|
|
833
|
+
* // Returns { num: 3, den: 4 }
|
|
834
|
+
*
|
|
835
|
+
* // Add timestamps with different timebases
|
|
836
|
+
* const ts1 = { num: 1000, den: 30000 };
|
|
837
|
+
* const ts2 = { num: 500, den: 30000 };
|
|
838
|
+
* const total = avAddQ(ts1, ts2);
|
|
839
|
+
* // Returns { num: 1, den: 20 } (normalized from 1500/30000)
|
|
840
|
+
* ```
|
|
841
|
+
*
|
|
842
|
+
* @see [av_add_q](https://ffmpeg.org/doxygen/trunk/group__lavu__math__rational.html#gac4af1feb227bd1095fc2cab42d933f52) - FFmpeg Doxygen
|
|
843
|
+
*/
|
|
844
|
+
export declare function avAddQ(a: IRational, b: IRational): IRational;
|
|
845
|
+
/**
|
|
846
|
+
* Calculate greatest common divisor.
|
|
847
|
+
*
|
|
848
|
+
* Computes the GCD of two integers using FFmpeg's av_gcd().
|
|
849
|
+
* Uses the Euclidean algorithm for efficient computation.
|
|
850
|
+
*
|
|
851
|
+
* Direct mapping to av_gcd().
|
|
852
|
+
*
|
|
853
|
+
* @param a - First integer
|
|
854
|
+
*
|
|
855
|
+
* @param b - Second integer
|
|
856
|
+
*
|
|
857
|
+
* @returns Greatest common divisor of a and b
|
|
858
|
+
*
|
|
859
|
+
* @example
|
|
860
|
+
* ```typescript
|
|
861
|
+
* const gcd = avGcd(48000, 44100);
|
|
862
|
+
* console.log(gcd); // 300
|
|
863
|
+
*
|
|
864
|
+
* // Used for calculating LCM
|
|
865
|
+
* const lcm = (a * b) / avGcd(a, b);
|
|
866
|
+
* ```
|
|
867
|
+
*
|
|
868
|
+
* @see [av_gcd](https://ffmpeg.org/doxygen/trunk/group__lavu__math.html#ga0e8419780352de538c1c15098cb1a587) - FFmpeg Doxygen
|
|
869
|
+
*/
|
|
870
|
+
export declare function avGcd(a: bigint | number, b: bigint | number): bigint;
|
|
871
|
+
/**
|
|
872
|
+
* Rescale timestamp with specified rounding mode.
|
|
873
|
+
*
|
|
874
|
+
* Rescales a timestamp from one time base to another with specific rounding behavior.
|
|
875
|
+
* More control than avRescaleQ() which uses default rounding.
|
|
876
|
+
*
|
|
877
|
+
* Direct mapping to av_rescale_q_rnd().
|
|
878
|
+
*
|
|
879
|
+
* @param a - Timestamp to rescale
|
|
880
|
+
*
|
|
881
|
+
* @param bq - Source time base
|
|
882
|
+
*
|
|
883
|
+
* @param cq - Destination time base
|
|
884
|
+
*
|
|
885
|
+
* @param rnd - Rounding mode (AV_ROUND_ZERO, AV_ROUND_INF, AV_ROUND_DOWN, AV_ROUND_UP, AV_ROUND_NEAR_INF)
|
|
886
|
+
*
|
|
887
|
+
* @returns Rescaled timestamp
|
|
888
|
+
*
|
|
889
|
+
* @example
|
|
890
|
+
* ```typescript
|
|
891
|
+
* import { AV_ROUND_UP, AV_ROUND_DOWN } from 'node-av/constants';
|
|
892
|
+
*
|
|
893
|
+
* const pts = 1000n;
|
|
894
|
+
* const srcTb = { num: 1, den: 48000 };
|
|
895
|
+
* const dstTb = { num: 1, den: 90000 };
|
|
896
|
+
*
|
|
897
|
+
* // Round up for safer comparisons
|
|
898
|
+
* const ptsUp = avRescaleQRnd(pts, srcTb, dstTb, AV_ROUND_UP);
|
|
899
|
+
*
|
|
900
|
+
* // Round down for conservative timestamps
|
|
901
|
+
* const ptsDown = avRescaleQRnd(pts, srcTb, dstTb, AV_ROUND_DOWN);
|
|
902
|
+
* ```
|
|
903
|
+
*
|
|
904
|
+
* @see [av_rescale_q_rnd](https://ffmpeg.org/doxygen/trunk/group__lavu__math.html#ga60044a302e86b5c2d8b19a81c8179f30) - FFmpeg Doxygen
|
|
905
|
+
*/
|
|
906
|
+
export declare function avRescaleQRnd(a: bigint | number | null, bq: IRational, cq: IRational, rnd: number): bigint;
|
|
907
|
+
/**
|
|
908
|
+
* Get the duration of a single audio frame in samples.
|
|
909
|
+
*
|
|
910
|
+
* Returns the number of samples per audio frame for codecs with constant frame size,
|
|
911
|
+
* or calculates it based on frame bytes for variable frame size codecs.
|
|
912
|
+
*
|
|
913
|
+
* Direct mapping to av_get_audio_frame_duration2().
|
|
914
|
+
*
|
|
915
|
+
* @param codecpar - Codec parameters
|
|
916
|
+
*
|
|
917
|
+
* @param frameBytes - Size of the frame in bytes
|
|
918
|
+
*
|
|
919
|
+
* @returns Number of samples in the frame, or 0 if unknown
|
|
920
|
+
*
|
|
921
|
+
* @example
|
|
922
|
+
* ```typescript
|
|
923
|
+
* const frameDuration = avGetAudioFrameDuration2(codecpar, frameBytes);
|
|
924
|
+
* ```
|
|
925
|
+
*
|
|
926
|
+
* @see [av_get_audio_frame_duration2](https://ffmpeg.org/doxygen/7.1/group__lavc__misc.html) - FFmpeg Doxygen
|
|
927
|
+
*/
|
|
928
|
+
export declare function avGetAudioFrameDuration2(codecpar: NativeWrapper<NativeCodecParameters>, frameBytes: number): number;
|
|
701
929
|
/**
|
|
702
930
|
* Allocate audio samples buffer.
|
|
703
931
|
*
|