@revizly/node-av 5.2.2-beta.1
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/BUILD_LINUX.md +61 -0
- package/LICENSE.md +22 -0
- package/README.md +662 -0
- package/build_mac_local.sh +69 -0
- package/dist/api/audio-frame-buffer.d.ts +205 -0
- package/dist/api/audio-frame-buffer.js +287 -0
- package/dist/api/audio-frame-buffer.js.map +1 -0
- package/dist/api/bitstream-filter.d.ts +820 -0
- package/dist/api/bitstream-filter.js +1242 -0
- package/dist/api/bitstream-filter.js.map +1 -0
- 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_h264.h264 +0 -0
- package/dist/api/data/test_hevc.h265 +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 +1088 -0
- package/dist/api/decoder.js +1775 -0
- package/dist/api/decoder.js.map +1 -0
- package/dist/api/demuxer.d.ts +1219 -0
- package/dist/api/demuxer.js +2081 -0
- package/dist/api/demuxer.js.map +1 -0
- package/dist/api/device.d.ts +586 -0
- package/dist/api/device.js +961 -0
- package/dist/api/device.js.map +1 -0
- package/dist/api/encoder.d.ts +1132 -0
- package/dist/api/encoder.js +1988 -0
- package/dist/api/encoder.js.map +1 -0
- package/dist/api/filter-complex.d.ts +821 -0
- package/dist/api/filter-complex.js +1604 -0
- package/dist/api/filter-complex.js.map +1 -0
- package/dist/api/filter-presets.d.ts +1286 -0
- package/dist/api/filter-presets.js +2152 -0
- package/dist/api/filter-presets.js.map +1 -0
- package/dist/api/filter.d.ts +1234 -0
- package/dist/api/filter.js +1976 -0
- package/dist/api/filter.js.map +1 -0
- package/dist/api/fmp4-stream.d.ts +426 -0
- package/dist/api/fmp4-stream.js +739 -0
- package/dist/api/fmp4-stream.js.map +1 -0
- package/dist/api/hardware.d.ts +651 -0
- package/dist/api/hardware.js +1260 -0
- package/dist/api/hardware.js.map +1 -0
- package/dist/api/index.d.ts +17 -0
- package/dist/api/index.js +32 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/io-stream.d.ts +307 -0
- package/dist/api/io-stream.js +282 -0
- package/dist/api/io-stream.js.map +1 -0
- package/dist/api/muxer.d.ts +957 -0
- package/dist/api/muxer.js +2002 -0
- package/dist/api/muxer.js.map +1 -0
- package/dist/api/pipeline.d.ts +607 -0
- package/dist/api/pipeline.js +1145 -0
- package/dist/api/pipeline.js.map +1 -0
- package/dist/api/utilities/async-queue.d.ts +120 -0
- package/dist/api/utilities/async-queue.js +211 -0
- package/dist/api/utilities/async-queue.js.map +1 -0
- package/dist/api/utilities/audio-sample.d.ts +117 -0
- package/dist/api/utilities/audio-sample.js +112 -0
- package/dist/api/utilities/audio-sample.js.map +1 -0
- package/dist/api/utilities/channel-layout.d.ts +76 -0
- package/dist/api/utilities/channel-layout.js +80 -0
- package/dist/api/utilities/channel-layout.js.map +1 -0
- package/dist/api/utilities/electron-shared-texture.d.ts +328 -0
- package/dist/api/utilities/electron-shared-texture.js +503 -0
- package/dist/api/utilities/electron-shared-texture.js.map +1 -0
- package/dist/api/utilities/image.d.ts +207 -0
- package/dist/api/utilities/image.js +213 -0
- package/dist/api/utilities/image.js.map +1 -0
- package/dist/api/utilities/index.d.ts +12 -0
- package/dist/api/utilities/index.js +25 -0
- package/dist/api/utilities/index.js.map +1 -0
- package/dist/api/utilities/media-type.d.ts +49 -0
- package/dist/api/utilities/media-type.js +53 -0
- package/dist/api/utilities/media-type.js.map +1 -0
- package/dist/api/utilities/pixel-format.d.ts +89 -0
- package/dist/api/utilities/pixel-format.js +97 -0
- package/dist/api/utilities/pixel-format.js.map +1 -0
- package/dist/api/utilities/sample-format.d.ts +129 -0
- package/dist/api/utilities/sample-format.js +141 -0
- package/dist/api/utilities/sample-format.js.map +1 -0
- 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 +186 -0
- package/dist/api/utilities/streaming.js +309 -0
- package/dist/api/utilities/streaming.js.map +1 -0
- package/dist/api/utilities/timestamp.d.ts +193 -0
- package/dist/api/utilities/timestamp.js +206 -0
- package/dist/api/utilities/timestamp.js.map +1 -0
- 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/utils.d.ts +19 -0
- package/dist/api/utils.js +39 -0
- package/dist/api/utils.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/channel-layouts.d.ts +53 -0
- package/dist/constants/channel-layouts.js +57 -0
- package/dist/constants/channel-layouts.js.map +1 -0
- package/dist/constants/constants.d.ts +2325 -0
- package/dist/constants/constants.js +1887 -0
- package/dist/constants/constants.js.map +1 -0
- package/dist/constants/decoders.d.ts +633 -0
- package/dist/constants/decoders.js +641 -0
- package/dist/constants/decoders.js.map +1 -0
- package/dist/constants/encoders.d.ts +295 -0
- package/dist/constants/encoders.js +308 -0
- package/dist/constants/encoders.js.map +1 -0
- 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 +5 -0
- package/dist/constants/index.js +6 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/ffmpeg/index.d.ts +99 -0
- package/dist/ffmpeg/index.js +115 -0
- package/dist/ffmpeg/index.js.map +1 -0
- package/dist/ffmpeg/utils.d.ts +31 -0
- package/dist/ffmpeg/utils.js +68 -0
- package/dist/ffmpeg/utils.js.map +1 -0
- package/dist/ffmpeg/version.d.ts +6 -0
- package/dist/ffmpeg/version.js +7 -0
- package/dist/ffmpeg/version.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/audio-fifo.d.ts +399 -0
- package/dist/lib/audio-fifo.js +431 -0
- package/dist/lib/audio-fifo.js.map +1 -0
- package/dist/lib/binding.d.ts +228 -0
- package/dist/lib/binding.js +60 -0
- package/dist/lib/binding.js.map +1 -0
- package/dist/lib/bitstream-filter-context.d.ts +379 -0
- package/dist/lib/bitstream-filter-context.js +441 -0
- package/dist/lib/bitstream-filter-context.js.map +1 -0
- package/dist/lib/bitstream-filter.d.ts +140 -0
- package/dist/lib/bitstream-filter.js +154 -0
- package/dist/lib/bitstream-filter.js.map +1 -0
- package/dist/lib/codec-context.d.ts +1071 -0
- package/dist/lib/codec-context.js +1354 -0
- package/dist/lib/codec-context.js.map +1 -0
- package/dist/lib/codec-parameters.d.ts +616 -0
- package/dist/lib/codec-parameters.js +761 -0
- package/dist/lib/codec-parameters.js.map +1 -0
- package/dist/lib/codec-parser.d.ts +201 -0
- package/dist/lib/codec-parser.js +213 -0
- package/dist/lib/codec-parser.js.map +1 -0
- package/dist/lib/codec.d.ts +586 -0
- package/dist/lib/codec.js +713 -0
- package/dist/lib/codec.js.map +1 -0
- package/dist/lib/device.d.ts +291 -0
- package/dist/lib/device.js +324 -0
- package/dist/lib/device.js.map +1 -0
- package/dist/lib/dictionary.d.ts +333 -0
- package/dist/lib/dictionary.js +372 -0
- package/dist/lib/dictionary.js.map +1 -0
- package/dist/lib/error.d.ts +242 -0
- package/dist/lib/error.js +303 -0
- package/dist/lib/error.js.map +1 -0
- 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 +712 -0
- package/dist/lib/filter-context.js +789 -0
- package/dist/lib/filter-context.js.map +1 -0
- package/dist/lib/filter-graph-segment.d.ts +160 -0
- package/dist/lib/filter-graph-segment.js +171 -0
- package/dist/lib/filter-graph-segment.js.map +1 -0
- package/dist/lib/filter-graph.d.ts +641 -0
- package/dist/lib/filter-graph.js +704 -0
- package/dist/lib/filter-graph.js.map +1 -0
- package/dist/lib/filter-inout.d.ts +198 -0
- package/dist/lib/filter-inout.js +257 -0
- package/dist/lib/filter-inout.js.map +1 -0
- package/dist/lib/filter.d.ts +243 -0
- package/dist/lib/filter.js +272 -0
- package/dist/lib/filter.js.map +1 -0
- package/dist/lib/format-context.d.ts +1254 -0
- package/dist/lib/format-context.js +1379 -0
- package/dist/lib/format-context.js.map +1 -0
- package/dist/lib/frame-utils.d.ts +116 -0
- package/dist/lib/frame-utils.js +98 -0
- package/dist/lib/frame-utils.js.map +1 -0
- package/dist/lib/frame.d.ts +1222 -0
- package/dist/lib/frame.js +1435 -0
- package/dist/lib/frame.js.map +1 -0
- package/dist/lib/hardware-device-context.d.ts +362 -0
- package/dist/lib/hardware-device-context.js +383 -0
- package/dist/lib/hardware-device-context.js.map +1 -0
- package/dist/lib/hardware-frames-context.d.ts +419 -0
- package/dist/lib/hardware-frames-context.js +477 -0
- package/dist/lib/hardware-frames-context.js.map +1 -0
- package/dist/lib/index.d.ts +35 -0
- package/dist/lib/index.js +60 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/input-format.d.ts +249 -0
- package/dist/lib/input-format.js +306 -0
- package/dist/lib/input-format.js.map +1 -0
- package/dist/lib/io-context.d.ts +696 -0
- package/dist/lib/io-context.js +769 -0
- package/dist/lib/io-context.js.map +1 -0
- package/dist/lib/log.d.ts +174 -0
- package/dist/lib/log.js +184 -0
- package/dist/lib/log.js.map +1 -0
- package/dist/lib/native-types.d.ts +946 -0
- package/dist/lib/native-types.js +2 -0
- package/dist/lib/native-types.js.map +1 -0
- package/dist/lib/option.d.ts +927 -0
- package/dist/lib/option.js +1583 -0
- package/dist/lib/option.js.map +1 -0
- package/dist/lib/output-format.d.ts +180 -0
- package/dist/lib/output-format.js +213 -0
- package/dist/lib/output-format.js.map +1 -0
- package/dist/lib/packet.d.ts +501 -0
- package/dist/lib/packet.js +590 -0
- package/dist/lib/packet.js.map +1 -0
- package/dist/lib/rational.d.ts +251 -0
- package/dist/lib/rational.js +278 -0
- package/dist/lib/rational.js.map +1 -0
- package/dist/lib/software-resample-context.d.ts +552 -0
- package/dist/lib/software-resample-context.js +592 -0
- package/dist/lib/software-resample-context.js.map +1 -0
- package/dist/lib/software-scale-context.d.ts +344 -0
- package/dist/lib/software-scale-context.js +366 -0
- package/dist/lib/software-scale-context.js.map +1 -0
- package/dist/lib/stream.d.ts +379 -0
- package/dist/lib/stream.js +526 -0
- package/dist/lib/stream.js.map +1 -0
- 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 +34 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utilities.d.ts +1127 -0
- package/dist/lib/utilities.js +1225 -0
- package/dist/lib/utilities.js.map +1 -0
- package/dist/utils/electron.d.ts +49 -0
- package/dist/utils/electron.js +63 -0
- package/dist/utils/electron.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/install/check.js +121 -0
- package/install/ffmpeg.js +66 -0
- package/jellyfin-ffmpeg.patch +181 -0
- package/package.json +129 -0
|
@@ -0,0 +1,1127 @@
|
|
|
1
|
+
import type { AVCodecID, AVHWDeviceType, AVMediaType, AVPixelFormat, AVSampleFormat } from '../constants/constants.js';
|
|
2
|
+
import type { FFHWDeviceType } from '../constants/hardware.js';
|
|
3
|
+
import type { FormatContext } from './format-context.js';
|
|
4
|
+
import type { NativeCodecParameters, NativePacket, NativeStream, NativeWrapper } from './native-types.js';
|
|
5
|
+
import type { ChannelLayout, DtsPredictState, IRational } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Get FFmpeg library information.
|
|
8
|
+
*
|
|
9
|
+
* Returns detailed information about the FFmpeg libraries including
|
|
10
|
+
* version numbers and build configuration.
|
|
11
|
+
*
|
|
12
|
+
* @returns FFmpeg information object with version, configuration, and library versions
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { getFFmpegInfo } from 'node-av/lib';
|
|
17
|
+
*
|
|
18
|
+
* const info = getFFmpegInfo();
|
|
19
|
+
* console.log('FFmpeg version:', info.version);
|
|
20
|
+
* console.log('Configuration:', info.configuration);
|
|
21
|
+
* console.log('libavcodec:', info.libraries.avcodec);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function getFFmpegInfo(): {
|
|
25
|
+
version: string;
|
|
26
|
+
configuration: string;
|
|
27
|
+
libraries: {
|
|
28
|
+
avutil: string;
|
|
29
|
+
avcodec: string;
|
|
30
|
+
avformat: string;
|
|
31
|
+
avfilter: string;
|
|
32
|
+
avdevice: string;
|
|
33
|
+
swscale: string;
|
|
34
|
+
swresample: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Get bytes per audio sample.
|
|
39
|
+
*
|
|
40
|
+
* Returns the number of bytes required to store a single audio sample
|
|
41
|
+
* in the specified format.
|
|
42
|
+
*
|
|
43
|
+
* Direct mapping to av_get_bytes_per_sample().
|
|
44
|
+
*
|
|
45
|
+
* @param sampleFmt - Audio sample format
|
|
46
|
+
*
|
|
47
|
+
* @returns Number of bytes per sample, or 0 if unknown format
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
|
|
52
|
+
*
|
|
53
|
+
* const bytesS16 = avGetBytesPerSample(AV_SAMPLE_FMT_S16); // Returns 2
|
|
54
|
+
* const bytesFloat = avGetBytesPerSample(AV_SAMPLE_FMT_FLTP); // Returns 4
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @see [av_get_bytes_per_sample](https://ffmpeg.org/doxygen/7.1/group__lavu__sampfmts.html#ga0c3c218e1dd570ad4917c69a35a6c77d) - FFmpeg Doxygen
|
|
58
|
+
*/
|
|
59
|
+
export declare function avGetBytesPerSample(sampleFmt: AVSampleFormat): number;
|
|
60
|
+
/**
|
|
61
|
+
* Get sample format name.
|
|
62
|
+
*
|
|
63
|
+
* Returns the name of the audio sample format as a string.
|
|
64
|
+
*
|
|
65
|
+
* Direct mapping to av_get_sample_fmt_name().
|
|
66
|
+
*
|
|
67
|
+
* @param sampleFmt - Audio sample format
|
|
68
|
+
*
|
|
69
|
+
* @returns Format name, or null if unknown
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
|
|
74
|
+
*
|
|
75
|
+
* const name1 = avGetSampleFmtName(AV_SAMPLE_FMT_S16); // Returns "s16"
|
|
76
|
+
* const name2 = avGetSampleFmtName(AV_SAMPLE_FMT_FLTP); // Returns "fltp"
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @see [av_get_sample_fmt_name](https://ffmpeg.org/doxygen/7.1/group__lavu__sampfmts.html#ga31b9d149b2de9821a65f4f5612970838) - FFmpeg Doxygen
|
|
80
|
+
*/
|
|
81
|
+
export declare function avGetSampleFmtName(sampleFmt: AVSampleFormat): string | null;
|
|
82
|
+
/**
|
|
83
|
+
* Get sample format from name string.
|
|
84
|
+
*
|
|
85
|
+
* Converts a sample format name (like "s16", "fltp", etc.) to the
|
|
86
|
+
* corresponding AVSampleFormat enum value.
|
|
87
|
+
*
|
|
88
|
+
* Direct mapping to av_get_sample_fmt().
|
|
89
|
+
*
|
|
90
|
+
* @param name - Sample format name (e.g., "s16", "fltp", "s32p")
|
|
91
|
+
*
|
|
92
|
+
* @returns Sample format enum, or AV_SAMPLE_FMT_NONE if unknown
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const fmt1 = avGetSampleFmtFromName("s16"); // Returns AV_SAMPLE_FMT_S16
|
|
97
|
+
* const fmt2 = avGetSampleFmtFromName("fltp"); // Returns AV_SAMPLE_FMT_FLTP
|
|
98
|
+
* const none = avGetSampleFmtFromName("invalid"); // Returns AV_SAMPLE_FMT_NONE
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* @see [av_get_sample_fmt](https://ffmpeg.org/doxygen/7.1/group__lavu__sampfmts.html#ga5b95d0bf179912e8ff0d23ddfa99c9bc) - FFmpeg Doxygen
|
|
102
|
+
* @see {@link avGetSampleFmtName} For converting format to name string
|
|
103
|
+
*/
|
|
104
|
+
export declare function avGetSampleFmtFromName(name: string): AVSampleFormat;
|
|
105
|
+
/**
|
|
106
|
+
* Get packed sample format.
|
|
107
|
+
*
|
|
108
|
+
* Returns the packed (interleaved) version of a planar sample format,
|
|
109
|
+
* or the format itself if already packed.
|
|
110
|
+
*
|
|
111
|
+
* Direct mapping to av_get_packed_sample_fmt().
|
|
112
|
+
*
|
|
113
|
+
* @param sampleFmt - Audio sample format
|
|
114
|
+
*
|
|
115
|
+
* @returns Packed version of the format
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* import { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT } from 'node-av/constants';
|
|
120
|
+
*
|
|
121
|
+
* const packed = avGetPackedSampleFmt(AV_SAMPLE_FMT_FLTP); // Returns AV_SAMPLE_FMT_FLT
|
|
122
|
+
* const same = avGetPackedSampleFmt(AV_SAMPLE_FMT_FLT); // Returns AV_SAMPLE_FMT_FLT
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* @see [av_get_packed_sample_fmt](https://ffmpeg.org/doxygen/7.1/group__lavu__sampfmts.html#ga7817ec0eff4dc6fc0962f31e6d138bca) - FFmpeg Doxygen
|
|
126
|
+
* @see {@link avGetPlanarSampleFmt} For getting planar version
|
|
127
|
+
*/
|
|
128
|
+
export declare function avGetPackedSampleFmt(sampleFmt: AVSampleFormat): AVSampleFormat;
|
|
129
|
+
/**
|
|
130
|
+
* Get planar sample format.
|
|
131
|
+
*
|
|
132
|
+
* Returns the planar (non-interleaved) version of a packed sample format,
|
|
133
|
+
* or the format itself if already planar.
|
|
134
|
+
*
|
|
135
|
+
* Direct mapping to av_get_planar_sample_fmt().
|
|
136
|
+
*
|
|
137
|
+
* @param sampleFmt - Audio sample format
|
|
138
|
+
*
|
|
139
|
+
* @returns Planar version of the format
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* import { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
|
|
144
|
+
*
|
|
145
|
+
* const planar = avGetPlanarSampleFmt(AV_SAMPLE_FMT_FLT); // Returns AV_SAMPLE_FMT_FLTP
|
|
146
|
+
* const same = avGetPlanarSampleFmt(AV_SAMPLE_FMT_FLTP); // Returns AV_SAMPLE_FMT_FLTP
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* @see [av_get_planar_sample_fmt](https://ffmpeg.org/doxygen/7.1/group__lavu__sampfmts.html#ga82caf838259d95cc6c4fd87633bb0e19) - FFmpeg Doxygen
|
|
150
|
+
* @see {@link avGetPackedSampleFmt} For getting packed version
|
|
151
|
+
*/
|
|
152
|
+
export declare function avGetPlanarSampleFmt(sampleFmt: AVSampleFormat): AVSampleFormat;
|
|
153
|
+
/**
|
|
154
|
+
* Check if sample format is planar.
|
|
155
|
+
*
|
|
156
|
+
* Returns whether the audio sample format stores channels in separate planes
|
|
157
|
+
* (planar) rather than interleaved.
|
|
158
|
+
*
|
|
159
|
+
* Direct mapping to av_sample_fmt_is_planar().
|
|
160
|
+
*
|
|
161
|
+
* @param sampleFmt - Audio sample format to check
|
|
162
|
+
*
|
|
163
|
+
* @returns True if planar, false if packed/interleaved
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P } from 'node-av/constants';
|
|
168
|
+
*
|
|
169
|
+
* const isPacked = avSampleFmtIsPlanar(AV_SAMPLE_FMT_S16); // Returns false
|
|
170
|
+
* const isPlanar = avSampleFmtIsPlanar(AV_SAMPLE_FMT_S16P); // Returns true
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* @see [av_sample_fmt_is_planar](https://ffmpeg.org/doxygen/7.1/group__lavu__sampfmts.html#ga06ba8a64dc4382c422789a5d0b6bf592) - FFmpeg Doxygen
|
|
174
|
+
*/
|
|
175
|
+
export declare function avSampleFmtIsPlanar(sampleFmt: AVSampleFormat): boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Get codec name from codec ID.
|
|
178
|
+
*
|
|
179
|
+
* Returns the canonical codec name corresponding to the codec ID.
|
|
180
|
+
*
|
|
181
|
+
* Direct mapping to avcodec_get_name().
|
|
182
|
+
*
|
|
183
|
+
* @param codecId - Codec ID from AVCodecID enum
|
|
184
|
+
*
|
|
185
|
+
* @returns Codec name string or null
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* import { AV_CODEC_ID_H264, AV_CODEC_ID_HEVC } from 'node-av/constants';
|
|
190
|
+
* import { avGetCodecName } from 'node-av/lib';
|
|
191
|
+
*
|
|
192
|
+
* const h264Name = avGetCodecName(AV_CODEC_ID_H264); // Returns "h264"
|
|
193
|
+
* const hevcName = avGetCodecName(AV_CODEC_ID_HEVC); // Returns "hevc"
|
|
194
|
+
* const unknownName = avGetCodecName(99999); // Returns null
|
|
195
|
+
* ```
|
|
196
|
+
*
|
|
197
|
+
* @see [avcodec_get_name](https://ffmpeg.org/doxygen/7.1/group__lavc__core.html#ga2016a52e94f867ebe5113bdf448e182d) - FFmpeg Doxygen
|
|
198
|
+
*/
|
|
199
|
+
export declare function avGetCodecName(codecId: AVCodecID): string | null;
|
|
200
|
+
/**
|
|
201
|
+
* Get RFC 6381 codec string from codec parameters.
|
|
202
|
+
*
|
|
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).
|
|
205
|
+
*
|
|
206
|
+
* Supported codecs:
|
|
207
|
+
* - **WebM codecs**: VP8, VP9 (with detailed profile/level), Vorbis, Opus, FLAC
|
|
208
|
+
* - **H.264** (avc1): `avc1.PPCCLL` (profile, constraints, level)
|
|
209
|
+
* - **HEVC** (hvc1): `hvc1.P.PC.TL.C` (profile, profile_compatibility, tier+level, constraints)
|
|
210
|
+
* - **AV1** (av01): `av01.P.LLT.BB...` (profile, level, tier, bitdepth, color info)
|
|
211
|
+
* - **AAC**: `mp4a.40.AOT` (audio object type)
|
|
212
|
+
* - **MP2**: `mp4a.40.33`
|
|
213
|
+
* - **MP3**: `mp4a.40.34`
|
|
214
|
+
* - **AC-3**: `ac-3`
|
|
215
|
+
* - **E-AC-3**: `ec-3`
|
|
216
|
+
* - **MPEG-4 Visual**: `mp4v.20` (profile/level not implemented)
|
|
217
|
+
*
|
|
218
|
+
* @param codecpar - Codec parameters
|
|
219
|
+
*
|
|
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
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```typescript
|
|
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
|
|
232
|
+
*
|
|
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
|
|
236
|
+
*
|
|
237
|
+
* // Use for DASH/HLS manifest
|
|
238
|
+
* const mimeType = `video/mp4; codecs="${codecString}"`;
|
|
239
|
+
* ```
|
|
240
|
+
*
|
|
241
|
+
* @see [codecstring.c](https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/codecstring.c) - FFmpeg implementation
|
|
242
|
+
*/
|
|
243
|
+
export declare function avGetCodecString(codecpar: NativeWrapper<NativeCodecParameters>, frameRate?: IRational): string | null;
|
|
244
|
+
/**
|
|
245
|
+
* Get DASH MIME type for codec parameters.
|
|
246
|
+
*
|
|
247
|
+
* Determines the MIME type for MPEG-DASH segments based on codec.
|
|
248
|
+
* Uses FFmpeg's segment type selection logic:
|
|
249
|
+
* - WebM codecs (VP8, VP9, Vorbis, Opus) → `video/webm` or `audio/webm`
|
|
250
|
+
* - All other codecs → `video/mp4` or `audio/mp4`
|
|
251
|
+
*
|
|
252
|
+
* @param codecpar - Codec parameters
|
|
253
|
+
*
|
|
254
|
+
* @returns MIME type string, or null if invalid media type
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```typescript
|
|
258
|
+
* import { avGetMimeTypeDash } from 'node-av/lib';
|
|
259
|
+
*
|
|
260
|
+
* const stream = input.video();
|
|
261
|
+
* const mimeType = avGetMimeTypeDash(stream.codecpar);
|
|
262
|
+
* console.log(mimeType); // "video/mp4" for H.264
|
|
263
|
+
*
|
|
264
|
+
* // VP9 codec
|
|
265
|
+
* const mimeTypeVP9 = avGetMimeTypeDash(vp9Stream.codecpar);
|
|
266
|
+
* console.log(mimeTypeVP9); // "video/webm"
|
|
267
|
+
* ```
|
|
268
|
+
*
|
|
269
|
+
* @see https://ffmpeg.org/doxygen/trunk/dashenc_8c_source.html#l00285 - FFmpeg dashenc.c segment type selection
|
|
270
|
+
*/
|
|
271
|
+
export declare function avGetMimeTypeDash(codecpar: NativeWrapper<NativeCodecParameters>): string | null;
|
|
272
|
+
/**
|
|
273
|
+
* Get pixel format name.
|
|
274
|
+
*
|
|
275
|
+
* Returns the name of the pixel format as a string.
|
|
276
|
+
*
|
|
277
|
+
* Direct mapping to av_get_pix_fmt_name().
|
|
278
|
+
*
|
|
279
|
+
* @param pixFmt - Pixel format
|
|
280
|
+
*
|
|
281
|
+
* @returns Format name, or null if unknown
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```typescript
|
|
285
|
+
* import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_RGB24 } from 'node-av/constants';
|
|
286
|
+
*
|
|
287
|
+
* const name1 = avGetPixFmtName(AV_PIX_FMT_YUV420P); // Returns "yuv420p"
|
|
288
|
+
* const name2 = avGetPixFmtName(AV_PIX_FMT_RGB24); // Returns "rgb24"
|
|
289
|
+
* ```
|
|
290
|
+
*
|
|
291
|
+
* @see [av_get_pix_fmt_name](https://ffmpeg.org/doxygen/7.1/pixdesc_8c.html#ab92e2a8a9b58c982560c49df9f01e47e) - FFmpeg Doxygen
|
|
292
|
+
*/
|
|
293
|
+
export declare function avGetPixFmtName(pixFmt: AVPixelFormat): string | null;
|
|
294
|
+
/**
|
|
295
|
+
* Get pixel format from name.
|
|
296
|
+
*
|
|
297
|
+
* Returns the pixel format enum value from its string name.
|
|
298
|
+
*
|
|
299
|
+
* Direct mapping to av_get_pix_fmt().
|
|
300
|
+
*
|
|
301
|
+
* @param name - Pixel format name
|
|
302
|
+
*
|
|
303
|
+
* @returns Pixel format enum, or AV_PIX_FMT_NONE if unknown
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
* ```typescript
|
|
307
|
+
* const fmt1 = avGetPixFmtFromName("yuv420p"); // Returns AV_PIX_FMT_YUV420P
|
|
308
|
+
* const fmt2 = avGetPixFmtFromName("rgb24"); // Returns AV_PIX_FMT_RGB24
|
|
309
|
+
* const none = avGetPixFmtFromName("invalid"); // Returns AV_PIX_FMT_NONE
|
|
310
|
+
* ```
|
|
311
|
+
*
|
|
312
|
+
* @see [av_get_pix_fmt](https://ffmpeg.org/doxygen/7.1/pixdesc_8h.html#a925ef18d69c24c3be8c53d5a7dc0660e) - FFmpeg Doxygen
|
|
313
|
+
*/
|
|
314
|
+
export declare function avGetPixFmtFromName(name: string): AVPixelFormat;
|
|
315
|
+
/**
|
|
316
|
+
* Check if pixel format is hardware accelerated.
|
|
317
|
+
*
|
|
318
|
+
* Returns whether the pixel format represents hardware-accelerated frames
|
|
319
|
+
* (GPU memory) rather than software frames (system memory).
|
|
320
|
+
*
|
|
321
|
+
* Direct mapping to av_pix_fmt_desc_get() with hwaccel check.
|
|
322
|
+
*
|
|
323
|
+
* @param pixFmt - Pixel format to check
|
|
324
|
+
*
|
|
325
|
+
* @returns True if hardware format, false if software format
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```typescript
|
|
329
|
+
* import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_CUDA } from 'node-av/constants';
|
|
330
|
+
*
|
|
331
|
+
* const isSoftware = avIsHardwarePixelFormat(AV_PIX_FMT_YUV420P); // Returns false
|
|
332
|
+
* const isHardware = avIsHardwarePixelFormat(AV_PIX_FMT_CUDA); // Returns true
|
|
333
|
+
* ```
|
|
334
|
+
*
|
|
335
|
+
* @see [av_pix_fmt_desc_get](https://ffmpeg.org/doxygen/7.1/pixdesc_8c.html#afe0c3e8aef5173de28bbdaea4298f5f0) - FFmpeg Doxygen
|
|
336
|
+
*/
|
|
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;
|
|
384
|
+
/**
|
|
385
|
+
* Get media type string.
|
|
386
|
+
*
|
|
387
|
+
* Returns a human-readable string for the media type.
|
|
388
|
+
*
|
|
389
|
+
* Direct mapping to av_get_media_type_string().
|
|
390
|
+
*
|
|
391
|
+
* @param mediaType - Media type enum
|
|
392
|
+
*
|
|
393
|
+
* @returns Media type name, or null if unknown
|
|
394
|
+
*
|
|
395
|
+
* @example
|
|
396
|
+
* ```typescript
|
|
397
|
+
* import { AVMEDIA_TYPE_VIDEO, AVMEDIA_TYPE_AUDIO } from 'node-av/constants';
|
|
398
|
+
*
|
|
399
|
+
* const video = avGetMediaTypeString(AVMEDIA_TYPE_VIDEO); // Returns "video"
|
|
400
|
+
* const audio = avGetMediaTypeString(AVMEDIA_TYPE_AUDIO); // Returns "audio"
|
|
401
|
+
* ```
|
|
402
|
+
*
|
|
403
|
+
* @see [av_get_media_type_string](https://ffmpeg.org/doxygen/7.1/group__lavu__misc.html#gaf21645cfa855b2caf9699d7dc7b2d08e) - FFmpeg Doxygen
|
|
404
|
+
*/
|
|
405
|
+
export declare function avGetMediaTypeString(mediaType: AVMediaType): string | null;
|
|
406
|
+
/**
|
|
407
|
+
* Allocate image buffer.
|
|
408
|
+
*
|
|
409
|
+
* Allocates a buffer large enough to hold an image with the specified dimensions
|
|
410
|
+
* and pixel format. Returns buffer and layout information.
|
|
411
|
+
*
|
|
412
|
+
* Direct mapping to av_image_alloc().
|
|
413
|
+
*
|
|
414
|
+
* @param width - Image width in pixels
|
|
415
|
+
*
|
|
416
|
+
* @param height - Image height in pixels
|
|
417
|
+
*
|
|
418
|
+
* @param pixFmt - Pixel format
|
|
419
|
+
*
|
|
420
|
+
* @param align - Buffer alignment (typically 1 or 32)
|
|
421
|
+
*
|
|
422
|
+
* @returns Object with buffer, size, and line sizes
|
|
423
|
+
*
|
|
424
|
+
* @throws {FFmpegError} If allocation fails
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* ```typescript
|
|
428
|
+
* import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
|
|
429
|
+
*
|
|
430
|
+
* const { buffer, size, linesizes } = avImageAlloc(
|
|
431
|
+
* 1920, 1080, AV_PIX_FMT_YUV420P, 32
|
|
432
|
+
* );
|
|
433
|
+
* console.log(`Allocated ${size} bytes`);
|
|
434
|
+
* console.log(`Line sizes: ${linesizes}`);
|
|
435
|
+
* ```
|
|
436
|
+
*
|
|
437
|
+
* @see [av_image_alloc](https://ffmpeg.org/doxygen/7.1/group__lavu__picture.html#ga841e0a89a642e24141af1918a2c10448) - FFmpeg Doxygen
|
|
438
|
+
* @see {@link avImageGetBufferSize} To calculate size without allocating
|
|
439
|
+
*/
|
|
440
|
+
export declare function avImageAlloc(width: number, height: number, pixFmt: AVPixelFormat, align: number): {
|
|
441
|
+
buffer: Buffer;
|
|
442
|
+
size: number;
|
|
443
|
+
linesizes: number[];
|
|
444
|
+
};
|
|
445
|
+
/**
|
|
446
|
+
* Copy image data.
|
|
447
|
+
*
|
|
448
|
+
* Copies image data from source to destination buffers.
|
|
449
|
+
*
|
|
450
|
+
* Direct mapping to av_image_copy2().
|
|
451
|
+
*
|
|
452
|
+
* @param dstData - Destination data planes
|
|
453
|
+
*
|
|
454
|
+
* @param dstLinesizes - Destination bytes per line
|
|
455
|
+
*
|
|
456
|
+
* @param srcData - Source data planes
|
|
457
|
+
*
|
|
458
|
+
* @param srcLinesizes - Source bytes per line
|
|
459
|
+
*
|
|
460
|
+
* @param pixFmt - Pixel format
|
|
461
|
+
*
|
|
462
|
+
* @param width - Image width
|
|
463
|
+
*
|
|
464
|
+
* @param height - Image height
|
|
465
|
+
*
|
|
466
|
+
* @example
|
|
467
|
+
* ```typescript
|
|
468
|
+
* avImageCopy2(
|
|
469
|
+
* dstPlanes, dstStrides,
|
|
470
|
+
* srcPlanes, srcStrides,
|
|
471
|
+
* AV_PIX_FMT_YUV420P, 1920, 1080
|
|
472
|
+
* );
|
|
473
|
+
* ```
|
|
474
|
+
*
|
|
475
|
+
* @see [av_image_copy2](https://ffmpeg.org/doxygen/7.1/group__lavu__picture.html#ga911cb7d723163b88bdbbdacbeeaacf2d) - FFmpeg Doxygen
|
|
476
|
+
*/
|
|
477
|
+
export declare function avImageCopy2(dstData: Buffer[], dstLinesizes: number[], srcData: Buffer[], srcLinesizes: number[], pixFmt: AVPixelFormat, width: number, height: number): void;
|
|
478
|
+
/**
|
|
479
|
+
* Get image buffer size.
|
|
480
|
+
*
|
|
481
|
+
* Calculates the required buffer size for an image without allocating.
|
|
482
|
+
*
|
|
483
|
+
* Direct mapping to av_image_get_buffer_size().
|
|
484
|
+
*
|
|
485
|
+
* @param pixFmt - Pixel format
|
|
486
|
+
*
|
|
487
|
+
* @param width - Image width
|
|
488
|
+
*
|
|
489
|
+
* @param height - Image height
|
|
490
|
+
*
|
|
491
|
+
* @param align - Buffer alignment
|
|
492
|
+
*
|
|
493
|
+
* @returns Required buffer size in bytes
|
|
494
|
+
*
|
|
495
|
+
* @example
|
|
496
|
+
* ```typescript
|
|
497
|
+
* import { AV_PIX_FMT_RGB24 } from 'node-av/constants';
|
|
498
|
+
*
|
|
499
|
+
* const size = avImageGetBufferSize(AV_PIX_FMT_RGB24, 1920, 1080, 1);
|
|
500
|
+
* console.log(`Need ${size} bytes for Full HD RGB24`);
|
|
501
|
+
* ```
|
|
502
|
+
*
|
|
503
|
+
* @see [av_image_get_buffer_size](https://ffmpeg.org/doxygen/7.1/group__lavu__picture.html#ga24a67963c3ae0054a2a4bab35930e694) - FFmpeg Doxygen
|
|
504
|
+
* @see {@link avImageAlloc} To allocate the buffer
|
|
505
|
+
*/
|
|
506
|
+
export declare function avImageGetBufferSize(pixFmt: AVPixelFormat, width: number, height: number, align: number): number;
|
|
507
|
+
/**
|
|
508
|
+
* Copy image to buffer.
|
|
509
|
+
*
|
|
510
|
+
* Copies image data from separate planes to a single contiguous buffer.
|
|
511
|
+
*
|
|
512
|
+
* Direct mapping to av_image_copy_to_buffer().
|
|
513
|
+
*
|
|
514
|
+
* @param dst - Destination buffer
|
|
515
|
+
*
|
|
516
|
+
* @param dstSize - Destination buffer size
|
|
517
|
+
*
|
|
518
|
+
* @param srcData - Source data planes
|
|
519
|
+
*
|
|
520
|
+
* @param srcLinesize - Source bytes per line
|
|
521
|
+
*
|
|
522
|
+
* @param pixFmt - Pixel format
|
|
523
|
+
*
|
|
524
|
+
* @param width - Image width
|
|
525
|
+
*
|
|
526
|
+
* @param height - Image height
|
|
527
|
+
*
|
|
528
|
+
* @param align - Buffer alignment
|
|
529
|
+
*
|
|
530
|
+
* @returns Bytes written, or negative AVERROR
|
|
531
|
+
*
|
|
532
|
+
* @example
|
|
533
|
+
* ```typescript
|
|
534
|
+
* const buffer = Buffer.alloc(bufferSize);
|
|
535
|
+
* const written = avImageCopyToBuffer(
|
|
536
|
+
* buffer, bufferSize,
|
|
537
|
+
* srcPlanes, srcStrides,
|
|
538
|
+
* AV_PIX_FMT_YUV420P, 1920, 1080, 1
|
|
539
|
+
* );
|
|
540
|
+
* ```
|
|
541
|
+
*
|
|
542
|
+
* @see [av_image_copy_to_buffer](https://ffmpeg.org/doxygen/7.1/group__lavu__picture.html#ga6f8576f1ef0c2d9a9f7c5ac7f9a28c52) - FFmpeg Doxygen
|
|
543
|
+
*/
|
|
544
|
+
export declare function avImageCopyToBuffer(dst: Buffer, dstSize: number, srcData: Buffer[] | null, srcLinesize: number[] | null, pixFmt: AVPixelFormat, width: number, height: number, align: number): number;
|
|
545
|
+
/**
|
|
546
|
+
* Convert timestamp to string.
|
|
547
|
+
*
|
|
548
|
+
* Converts a timestamp to a string representation.
|
|
549
|
+
*
|
|
550
|
+
* Direct mapping to av_ts2str().
|
|
551
|
+
*
|
|
552
|
+
* @param ts - Timestamp value
|
|
553
|
+
*
|
|
554
|
+
* @returns String representation
|
|
555
|
+
*
|
|
556
|
+
* @example
|
|
557
|
+
* ```typescript
|
|
558
|
+
* const str1 = avTs2Str(1234567n); // Returns "1234567"
|
|
559
|
+
* const str2 = avTs2Str(null); // Returns "NOPTS"
|
|
560
|
+
* ```
|
|
561
|
+
*
|
|
562
|
+
* @see [av_ts2str](https://ffmpeg.org/doxygen/7.1/timestamp_8h.html#a86d797e907fa454ed5fd34bfb0bcd747) - FFmpeg Doxygen
|
|
563
|
+
*/
|
|
564
|
+
export declare function avTs2Str(ts: bigint | number | null): string;
|
|
565
|
+
/**
|
|
566
|
+
* Convert timestamp to time string.
|
|
567
|
+
*
|
|
568
|
+
* Converts a timestamp to a time string using the specified time base.
|
|
569
|
+
*
|
|
570
|
+
* Direct mapping to av_ts2timestr().
|
|
571
|
+
*
|
|
572
|
+
* @param ts - Timestamp value
|
|
573
|
+
*
|
|
574
|
+
* @param timeBase - Time base for conversion
|
|
575
|
+
*
|
|
576
|
+
* @returns Time string representation
|
|
577
|
+
*
|
|
578
|
+
* @example
|
|
579
|
+
* ```typescript
|
|
580
|
+
* const timeStr = avTs2TimeStr(90000n, { num: 1, den: 90000 }); // Returns "1.000000"
|
|
581
|
+
* const nopts = avTs2TimeStr(null, { num: 1, den: 1000 }); // Returns "NOPTS"
|
|
582
|
+
* ```
|
|
583
|
+
*
|
|
584
|
+
* @see [av_ts2timestr](https://ffmpeg.org/doxygen/7.1/timestamp_8h.html#ad344b91ede6b86fc0a530611293f42da) - FFmpeg Doxygen
|
|
585
|
+
*/
|
|
586
|
+
export declare function avTs2TimeStr(ts: bigint | number | null, timeBase: IRational | null): string;
|
|
587
|
+
/**
|
|
588
|
+
* Allocate image arrays.
|
|
589
|
+
*
|
|
590
|
+
* Allocates image data as separate plane arrays.
|
|
591
|
+
*
|
|
592
|
+
* @param width - Image width
|
|
593
|
+
*
|
|
594
|
+
* @param height - Image height
|
|
595
|
+
*
|
|
596
|
+
* @param pixFmt - Pixel format
|
|
597
|
+
*
|
|
598
|
+
* @param align - Buffer alignment
|
|
599
|
+
*
|
|
600
|
+
* @returns Object with data planes, line sizes, and total size
|
|
601
|
+
*
|
|
602
|
+
* @example
|
|
603
|
+
* ```typescript
|
|
604
|
+
* const { data, linesizes, size } = avImageAllocArrays(
|
|
605
|
+
* 1920, 1080, AV_PIX_FMT_YUV420P, 32
|
|
606
|
+
* );
|
|
607
|
+
* console.log(`Allocated ${data.length} planes, total ${size} bytes`);
|
|
608
|
+
* ```
|
|
609
|
+
*/
|
|
610
|
+
export declare function avImageAllocArrays(width: number, height: number, pixFmt: AVPixelFormat, align: number): {
|
|
611
|
+
data: Buffer[];
|
|
612
|
+
linesizes: number[];
|
|
613
|
+
size: number;
|
|
614
|
+
};
|
|
615
|
+
/**
|
|
616
|
+
* Compare timestamps.
|
|
617
|
+
*
|
|
618
|
+
* Compares two timestamps with different time bases.
|
|
619
|
+
*
|
|
620
|
+
* Direct mapping to av_compare_ts().
|
|
621
|
+
*
|
|
622
|
+
* @param tsA - First timestamp
|
|
623
|
+
*
|
|
624
|
+
* @param tbA - First time base
|
|
625
|
+
*
|
|
626
|
+
* @param tsB - Second timestamp
|
|
627
|
+
*
|
|
628
|
+
* @param tbB - Second time base
|
|
629
|
+
*
|
|
630
|
+
* @returns -1 if A < B, 0 if A == B, 1 if A > B
|
|
631
|
+
*
|
|
632
|
+
* @example
|
|
633
|
+
* ```typescript
|
|
634
|
+
* const cmp = avCompareTs(
|
|
635
|
+
* 1000n, { num: 1, den: 1000 }, // 1 second
|
|
636
|
+
* 900n, { num: 1, den: 900 } // 1 second
|
|
637
|
+
* );
|
|
638
|
+
* // Returns 0 (equal)
|
|
639
|
+
* ```
|
|
640
|
+
*
|
|
641
|
+
* @see [av_compare_ts](https://ffmpeg.org/doxygen/7.1/group__lavu__math.html#ga151744358fff630942b926e67e67c415) - FFmpeg Doxygen
|
|
642
|
+
*/
|
|
643
|
+
export declare function avCompareTs(tsA: bigint | number | null, tbA: IRational, tsB: bigint | number | null, tbB: IRational): number;
|
|
644
|
+
/**
|
|
645
|
+
* Rescale timestamp.
|
|
646
|
+
*
|
|
647
|
+
* Rescales a timestamp from one time base to another.
|
|
648
|
+
*
|
|
649
|
+
* Direct mapping to av_rescale_q().
|
|
650
|
+
*
|
|
651
|
+
* @param a - Timestamp to rescale
|
|
652
|
+
*
|
|
653
|
+
* @param bq - Source time base
|
|
654
|
+
*
|
|
655
|
+
* @param cq - Destination time base
|
|
656
|
+
*
|
|
657
|
+
* @returns Rescaled timestamp
|
|
658
|
+
*
|
|
659
|
+
* @example
|
|
660
|
+
* ```typescript
|
|
661
|
+
* // Convert 1 second from 1000Hz to 90kHz
|
|
662
|
+
* const rescaled = avRescaleQ(
|
|
663
|
+
* 1000n,
|
|
664
|
+
* { num: 1, den: 1000 }, // 1000 Hz
|
|
665
|
+
* { num: 1, den: 90000 } // 90 kHz
|
|
666
|
+
* );
|
|
667
|
+
* // Returns 90000n
|
|
668
|
+
* ```
|
|
669
|
+
*
|
|
670
|
+
* @see [av_rescale_q](https://ffmpeg.org/doxygen/7.1/group__lavu__math.html#gaf02994a8bbeaa91d4757df179cbe567f) - FFmpeg Doxygen
|
|
671
|
+
*/
|
|
672
|
+
export declare function avRescaleQ(a: bigint | number | null, bq: IRational, cq: IRational): bigint;
|
|
673
|
+
/**
|
|
674
|
+
* Sleep for microseconds.
|
|
675
|
+
*
|
|
676
|
+
* Suspends execution for the specified number of microseconds.
|
|
677
|
+
*
|
|
678
|
+
* Direct mapping to av_usleep().
|
|
679
|
+
*
|
|
680
|
+
* @param usec - Microseconds to sleep
|
|
681
|
+
*
|
|
682
|
+
* @example
|
|
683
|
+
* ```typescript
|
|
684
|
+
* avUsleep(1000000); // Sleep for 1 second
|
|
685
|
+
* avUsleep(16667); // Sleep for ~16.67ms (60fps frame time)
|
|
686
|
+
* ```
|
|
687
|
+
*
|
|
688
|
+
* @see [av_usleep](https://ffmpeg.org/doxygen/7.1/time_8c.html#a4eee9c65835652a808973f4bc1641a51) - FFmpeg Doxygen
|
|
689
|
+
*/
|
|
690
|
+
export declare function avUsleep(usec: number): void;
|
|
691
|
+
/**
|
|
692
|
+
* Rescale with rounding.
|
|
693
|
+
*
|
|
694
|
+
* Rescales a value with specified rounding behavior.
|
|
695
|
+
*
|
|
696
|
+
* Direct mapping to av_rescale_rnd().
|
|
697
|
+
*
|
|
698
|
+
* @param a - Value to rescale
|
|
699
|
+
*
|
|
700
|
+
* @param b - Multiplier
|
|
701
|
+
*
|
|
702
|
+
* @param c - Divisor
|
|
703
|
+
*
|
|
704
|
+
* @param rnd - Rounding mode (AV_ROUND_*)
|
|
705
|
+
*
|
|
706
|
+
* @returns Rescaled value
|
|
707
|
+
*
|
|
708
|
+
* @example
|
|
709
|
+
* ```typescript
|
|
710
|
+
* import { AV_ROUND_NEAR_INF } from 'node-av/constants';
|
|
711
|
+
*
|
|
712
|
+
* const rescaled = avRescaleRnd(1000n, 90000n, 1000n, AV_ROUND_NEAR_INF);
|
|
713
|
+
* // Returns 90000n
|
|
714
|
+
* ```
|
|
715
|
+
*
|
|
716
|
+
* @see [av_rescale_rnd](https://ffmpeg.org/doxygen/7.1/group__lavu__math.html#ga82d40664213508918093822461cc597e) - FFmpeg Doxygen
|
|
717
|
+
*/
|
|
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;
|
|
929
|
+
/**
|
|
930
|
+
* Allocate audio samples buffer.
|
|
931
|
+
*
|
|
932
|
+
* Allocates buffers for audio samples with the specified format.
|
|
933
|
+
*
|
|
934
|
+
* Direct mapping to av_samples_alloc().
|
|
935
|
+
*
|
|
936
|
+
* @param nbChannels - Number of audio channels
|
|
937
|
+
*
|
|
938
|
+
* @param nbSamples - Number of samples per channel
|
|
939
|
+
*
|
|
940
|
+
* @param sampleFmt - Sample format
|
|
941
|
+
*
|
|
942
|
+
* @param align - Buffer alignment
|
|
943
|
+
*
|
|
944
|
+
* @returns Object with data buffers, line size, and total size
|
|
945
|
+
*
|
|
946
|
+
* @throws {FFmpegError} If allocation fails
|
|
947
|
+
*
|
|
948
|
+
* @example
|
|
949
|
+
* ```typescript
|
|
950
|
+
* import { AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
|
|
951
|
+
*
|
|
952
|
+
* const { data, linesize, size } = avSamplesAlloc(
|
|
953
|
+
* 2, 1024, AV_SAMPLE_FMT_FLTP, 0
|
|
954
|
+
* );
|
|
955
|
+
* console.log(`Allocated ${data.length} buffers, ${size} bytes total`);
|
|
956
|
+
* ```
|
|
957
|
+
*
|
|
958
|
+
* @see [av_samples_alloc](https://ffmpeg.org/doxygen/7.1/group__lavu__sampmanip.html#ga4db4c77f928d32c7d8854732f50b8c04) - FFmpeg Doxygen
|
|
959
|
+
* @see {@link avSamplesGetBufferSize} To calculate size without allocating
|
|
960
|
+
*/
|
|
961
|
+
export declare function avSamplesAlloc(nbChannels: number, nbSamples: number, sampleFmt: AVSampleFormat, align: number): {
|
|
962
|
+
data: Buffer[];
|
|
963
|
+
linesize: number;
|
|
964
|
+
size: number;
|
|
965
|
+
};
|
|
966
|
+
/**
|
|
967
|
+
* Get audio samples buffer size.
|
|
968
|
+
*
|
|
969
|
+
* Calculates the required buffer size for audio samples.
|
|
970
|
+
*
|
|
971
|
+
* Direct mapping to av_samples_get_buffer_size().
|
|
972
|
+
*
|
|
973
|
+
* @param nbChannels - Number of channels
|
|
974
|
+
*
|
|
975
|
+
* @param nbSamples - Number of samples per channel
|
|
976
|
+
*
|
|
977
|
+
* @param sampleFmt - Sample format
|
|
978
|
+
*
|
|
979
|
+
* @param align - Buffer alignment
|
|
980
|
+
*
|
|
981
|
+
* @returns Object with size and line size
|
|
982
|
+
*
|
|
983
|
+
* @throws {FFmpegError} If parameters are invalid
|
|
984
|
+
*
|
|
985
|
+
* @example
|
|
986
|
+
* ```typescript
|
|
987
|
+
* import { AV_SAMPLE_FMT_S16 } from 'node-av/constants';
|
|
988
|
+
*
|
|
989
|
+
* const { size, linesize } = avSamplesGetBufferSize(
|
|
990
|
+
* 2, 1024, AV_SAMPLE_FMT_S16, 0
|
|
991
|
+
* );
|
|
992
|
+
* console.log(`Need ${size} bytes, ${linesize} per channel`);
|
|
993
|
+
* ```
|
|
994
|
+
*
|
|
995
|
+
* @see [av_samples_get_buffer_size](https://ffmpeg.org/doxygen/7.1/group__lavu__sampfmts.html#gaa7368bc4e3a366b688e81938ed55eb06) - FFmpeg Doxygen
|
|
996
|
+
* @see {@link avSamplesAlloc} To allocate the buffer
|
|
997
|
+
*/
|
|
998
|
+
export declare function avSamplesGetBufferSize(nbChannels: number, nbSamples: number, sampleFmt: AVSampleFormat, align: number): {
|
|
999
|
+
size: number;
|
|
1000
|
+
linesize: number;
|
|
1001
|
+
};
|
|
1002
|
+
/**
|
|
1003
|
+
* Image crop function.
|
|
1004
|
+
*
|
|
1005
|
+
* Crops an image region from source buffer to destination buffer.
|
|
1006
|
+
*
|
|
1007
|
+
* @param dstBuffer - Destination buffer (must be pre-allocated)
|
|
1008
|
+
*
|
|
1009
|
+
* @param srcBuffer - Source buffer containing the image
|
|
1010
|
+
*
|
|
1011
|
+
* @param pixFmt - Pixel format
|
|
1012
|
+
*
|
|
1013
|
+
* @param srcWidth - Source image width
|
|
1014
|
+
*
|
|
1015
|
+
* @param srcHeight - Source image height
|
|
1016
|
+
*
|
|
1017
|
+
* @param cropX - X coordinate of crop region (left)
|
|
1018
|
+
*
|
|
1019
|
+
* @param cropY - Y coordinate of crop region (top)
|
|
1020
|
+
*
|
|
1021
|
+
* @param cropWidth - Width of crop region
|
|
1022
|
+
*
|
|
1023
|
+
* @param cropHeight - Height of crop region
|
|
1024
|
+
*
|
|
1025
|
+
* @returns Number of bytes copied
|
|
1026
|
+
*
|
|
1027
|
+
* @example
|
|
1028
|
+
* ```typescript
|
|
1029
|
+
* import { AV_PIX_FMT_NV12 } from 'node-av/constants';
|
|
1030
|
+
*
|
|
1031
|
+
* const dstSize = avImageGetBufferSize(AV_PIX_FMT_NV12, 100, 100, 1);
|
|
1032
|
+
* const dstBuffer = Buffer.alloc(dstSize);
|
|
1033
|
+
*
|
|
1034
|
+
* const bytesCopied = avImageCrop(
|
|
1035
|
+
* dstBuffer, srcBuffer,
|
|
1036
|
+
* AV_PIX_FMT_NV12,
|
|
1037
|
+
* 320, 180, // source dimensions
|
|
1038
|
+
* 10, 10, // crop position
|
|
1039
|
+
* 100, 100 // crop size
|
|
1040
|
+
* );
|
|
1041
|
+
* ```
|
|
1042
|
+
*/
|
|
1043
|
+
export declare function avImageCrop(dstBuffer: Buffer, srcBuffer: Buffer, pixFmt: AVPixelFormat, srcWidth: number, srcHeight: number, cropX: number, cropY: number, cropWidth: number, cropHeight: number): number;
|
|
1044
|
+
/**
|
|
1045
|
+
* Describe channel layout.
|
|
1046
|
+
*
|
|
1047
|
+
* Returns a human-readable description of a channel layout.
|
|
1048
|
+
*
|
|
1049
|
+
* Direct mapping to av_channel_layout_describe().
|
|
1050
|
+
*
|
|
1051
|
+
* @param channelLayout - Channel layout to describe
|
|
1052
|
+
*
|
|
1053
|
+
* @returns Layout description string, or null
|
|
1054
|
+
*
|
|
1055
|
+
* @example
|
|
1056
|
+
* ```typescript
|
|
1057
|
+
* const stereo = { nbChannels: 2, order: 1, u: { mask: 3n } };
|
|
1058
|
+
* const desc = avChannelLayoutDescribe(stereo); // Returns "stereo"
|
|
1059
|
+
* ```
|
|
1060
|
+
*
|
|
1061
|
+
* @see [av_channel_layout_describe](https://ffmpeg.org/doxygen/7.1/group__lavu__audio__channels.html#gacc7d7d1a280248aafb8f9196c9d4e24f) - FFmpeg Doxygen
|
|
1062
|
+
*/
|
|
1063
|
+
export declare function avChannelLayoutDescribe(channelLayout: Partial<ChannelLayout>): string | null;
|
|
1064
|
+
/**
|
|
1065
|
+
* Create SDP from format contexts.
|
|
1066
|
+
*
|
|
1067
|
+
* Creates an SDP (Session Description Protocol) string from format contexts.
|
|
1068
|
+
* Used for RTP/RTSP streaming.
|
|
1069
|
+
*
|
|
1070
|
+
* Direct mapping to av_sdp_create().
|
|
1071
|
+
*
|
|
1072
|
+
* @param contexts - Array of format contexts
|
|
1073
|
+
*
|
|
1074
|
+
* @returns SDP string, or null on error
|
|
1075
|
+
*
|
|
1076
|
+
* @example
|
|
1077
|
+
* ```typescript
|
|
1078
|
+
* const sdp = avSdpCreate([outputContext]);
|
|
1079
|
+
* if (sdp) {
|
|
1080
|
+
* console.log('SDP:\n' + sdp);
|
|
1081
|
+
* }
|
|
1082
|
+
* ```
|
|
1083
|
+
*
|
|
1084
|
+
* @see [av_sdp_create](https://ffmpeg.org/doxygen/7.1/group__lavf__misc.html#gaa2a7353a6bb0c8726797abd56b176af0) - FFmpeg Doxygen
|
|
1085
|
+
*/
|
|
1086
|
+
export declare function avSdpCreate(contexts: FormatContext[]): string | null;
|
|
1087
|
+
/**
|
|
1088
|
+
* Predict and update DTS timestamps for demuxed packets.
|
|
1089
|
+
*
|
|
1090
|
+
* This is a native implementation of FFmpeg's `ist_dts_update()`.
|
|
1091
|
+
* It predicts the next DTS based on codec type and stream metadata,
|
|
1092
|
+
* handling both audio (sample-based) and video (frame-rate-based) timing.
|
|
1093
|
+
*
|
|
1094
|
+
* @param packet - Native Packet
|
|
1095
|
+
*
|
|
1096
|
+
* @param stream - Native Stream
|
|
1097
|
+
*
|
|
1098
|
+
* @param state - Current DTS prediction state
|
|
1099
|
+
*
|
|
1100
|
+
* @returns Updated state with new DTS values
|
|
1101
|
+
*
|
|
1102
|
+
* @example
|
|
1103
|
+
* ```typescript
|
|
1104
|
+
* const newState = dtsPredict(packet, stream, {
|
|
1105
|
+
* sawFirstTs: false,
|
|
1106
|
+
* dts: AV_NOPTS_VALUE,
|
|
1107
|
+
* nextDts: AV_NOPTS_VALUE,
|
|
1108
|
+
* firstDts: AV_NOPTS_VALUE,
|
|
1109
|
+
* });
|
|
1110
|
+
* ```
|
|
1111
|
+
*/
|
|
1112
|
+
export declare function dtsPredict(packet: NativeWrapper<NativePacket>, stream: NativeWrapper<NativeStream>, state: DtsPredictState): DtsPredictState;
|
|
1113
|
+
/**
|
|
1114
|
+
* Convert string to FourCC.
|
|
1115
|
+
*
|
|
1116
|
+
* Converts a 4-character string to a packed FourCC integer.
|
|
1117
|
+
*
|
|
1118
|
+
* @param str - 4-character string
|
|
1119
|
+
*
|
|
1120
|
+
* @returns Packed FourCC as unsigned 32-bit integer
|
|
1121
|
+
*
|
|
1122
|
+
* @example
|
|
1123
|
+
* ```typescript
|
|
1124
|
+
* const fourcc = stringToFourCC("avc1"); // Returns 828601953 / 0x31637661
|
|
1125
|
+
* ```
|
|
1126
|
+
*/
|
|
1127
|
+
export declare function stringToFourCC(str: string): number;
|