node-av 1.1.0 → 1.3.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.
Files changed (166) hide show
  1. package/README.md +51 -59
  2. package/dist/api/bitstream-filter.d.ts +183 -123
  3. package/dist/api/bitstream-filter.js +185 -127
  4. package/dist/api/bitstream-filter.js.map +1 -1
  5. package/dist/api/decoder.d.ts +282 -130
  6. package/dist/api/decoder.js +290 -142
  7. package/dist/api/decoder.js.map +1 -1
  8. package/dist/api/encoder.d.ts +249 -160
  9. package/dist/api/encoder.js +276 -207
  10. package/dist/api/encoder.js.map +1 -1
  11. package/dist/api/filter-presets.d.ts +1944 -96
  12. package/dist/api/filter-presets.js +2059 -105
  13. package/dist/api/filter-presets.js.map +1 -1
  14. package/dist/api/filter.d.ts +264 -200
  15. package/dist/api/filter.js +269 -231
  16. package/dist/api/filter.js.map +1 -1
  17. package/dist/api/hardware.d.ts +246 -117
  18. package/dist/api/hardware.js +440 -217
  19. package/dist/api/hardware.js.map +1 -1
  20. package/dist/api/index.d.ts +3 -3
  21. package/dist/api/index.js +1 -1
  22. package/dist/api/index.js.map +1 -1
  23. package/dist/api/io-stream.d.ts +65 -55
  24. package/dist/api/io-stream.js +43 -40
  25. package/dist/api/io-stream.js.map +1 -1
  26. package/dist/api/media-input.d.ts +242 -139
  27. package/dist/api/media-input.js +205 -103
  28. package/dist/api/media-input.js.map +1 -1
  29. package/dist/api/media-output.d.ts +208 -126
  30. package/dist/api/media-output.js +212 -126
  31. package/dist/api/media-output.js.map +1 -1
  32. package/dist/api/pipeline.d.ts +361 -38
  33. package/dist/api/pipeline.js +255 -14
  34. package/dist/api/pipeline.js.map +1 -1
  35. package/dist/api/types.d.ts +26 -187
  36. package/dist/api/utilities/audio-sample.d.ts +0 -8
  37. package/dist/api/utilities/audio-sample.js +0 -8
  38. package/dist/api/utilities/audio-sample.js.map +1 -1
  39. package/dist/api/utilities/channel-layout.d.ts +0 -8
  40. package/dist/api/utilities/channel-layout.js +0 -8
  41. package/dist/api/utilities/channel-layout.js.map +1 -1
  42. package/dist/api/utilities/image.d.ts +0 -8
  43. package/dist/api/utilities/image.js +0 -8
  44. package/dist/api/utilities/image.js.map +1 -1
  45. package/dist/api/utilities/index.d.ts +3 -3
  46. package/dist/api/utilities/index.js +3 -3
  47. package/dist/api/utilities/index.js.map +1 -1
  48. package/dist/api/utilities/media-type.d.ts +1 -9
  49. package/dist/api/utilities/media-type.js +1 -9
  50. package/dist/api/utilities/media-type.js.map +1 -1
  51. package/dist/api/utilities/pixel-format.d.ts +1 -9
  52. package/dist/api/utilities/pixel-format.js +1 -9
  53. package/dist/api/utilities/pixel-format.js.map +1 -1
  54. package/dist/api/utilities/sample-format.d.ts +1 -9
  55. package/dist/api/utilities/sample-format.js +1 -9
  56. package/dist/api/utilities/sample-format.js.map +1 -1
  57. package/dist/api/utilities/streaming.d.ts +0 -8
  58. package/dist/api/utilities/streaming.js +0 -8
  59. package/dist/api/utilities/streaming.js.map +1 -1
  60. package/dist/api/utilities/timestamp.d.ts +0 -8
  61. package/dist/api/utilities/timestamp.js +0 -8
  62. package/dist/api/utilities/timestamp.js.map +1 -1
  63. package/dist/api/utils.d.ts +1 -2
  64. package/dist/api/utils.js +11 -0
  65. package/dist/api/utils.js.map +1 -1
  66. package/dist/constants/constants.d.ts +1 -1
  67. package/dist/constants/constants.js +2 -0
  68. package/dist/constants/constants.js.map +1 -1
  69. package/dist/lib/audio-fifo.d.ts +127 -170
  70. package/dist/lib/audio-fifo.js +130 -173
  71. package/dist/lib/audio-fifo.js.map +1 -1
  72. package/dist/lib/binding.d.ts +1 -0
  73. package/dist/lib/binding.js +7 -0
  74. package/dist/lib/binding.js.map +1 -1
  75. package/dist/lib/bitstream-filter-context.d.ts +139 -184
  76. package/dist/lib/bitstream-filter-context.js +139 -188
  77. package/dist/lib/bitstream-filter-context.js.map +1 -1
  78. package/dist/lib/bitstream-filter.d.ts +68 -54
  79. package/dist/lib/bitstream-filter.js +68 -54
  80. package/dist/lib/bitstream-filter.js.map +1 -1
  81. package/dist/lib/codec-context.d.ts +316 -380
  82. package/dist/lib/codec-context.js +316 -381
  83. package/dist/lib/codec-context.js.map +1 -1
  84. package/dist/lib/codec-parameters.d.ts +160 -170
  85. package/dist/lib/codec-parameters.js +162 -172
  86. package/dist/lib/codec-parameters.js.map +1 -1
  87. package/dist/lib/codec-parser.d.ts +91 -104
  88. package/dist/lib/codec-parser.js +92 -103
  89. package/dist/lib/codec-parser.js.map +1 -1
  90. package/dist/lib/codec.d.ts +266 -283
  91. package/dist/lib/codec.js +270 -287
  92. package/dist/lib/codec.js.map +1 -1
  93. package/dist/lib/dictionary.d.ts +149 -203
  94. package/dist/lib/dictionary.js +158 -212
  95. package/dist/lib/dictionary.js.map +1 -1
  96. package/dist/lib/error.d.ts +96 -130
  97. package/dist/lib/error.js +98 -128
  98. package/dist/lib/error.js.map +1 -1
  99. package/dist/lib/filter-context.d.ts +284 -218
  100. package/dist/lib/filter-context.js +290 -227
  101. package/dist/lib/filter-context.js.map +1 -1
  102. package/dist/lib/filter-graph.d.ts +251 -292
  103. package/dist/lib/filter-graph.js +253 -294
  104. package/dist/lib/filter-graph.js.map +1 -1
  105. package/dist/lib/filter-inout.d.ts +87 -95
  106. package/dist/lib/filter-inout.js +87 -95
  107. package/dist/lib/filter-inout.js.map +1 -1
  108. package/dist/lib/filter.d.ts +93 -111
  109. package/dist/lib/filter.js +93 -111
  110. package/dist/lib/filter.js.map +1 -1
  111. package/dist/lib/format-context.d.ts +320 -428
  112. package/dist/lib/format-context.js +313 -385
  113. package/dist/lib/format-context.js.map +1 -1
  114. package/dist/lib/frame.d.ts +262 -405
  115. package/dist/lib/frame.js +263 -408
  116. package/dist/lib/frame.js.map +1 -1
  117. package/dist/lib/hardware-device-context.d.ts +149 -203
  118. package/dist/lib/hardware-device-context.js +149 -203
  119. package/dist/lib/hardware-device-context.js.map +1 -1
  120. package/dist/lib/hardware-frames-context.d.ts +170 -180
  121. package/dist/lib/hardware-frames-context.js +171 -181
  122. package/dist/lib/hardware-frames-context.js.map +1 -1
  123. package/dist/lib/index.d.ts +3 -2
  124. package/dist/lib/index.js +3 -3
  125. package/dist/lib/index.js.map +1 -1
  126. package/dist/lib/input-format.d.ts +89 -117
  127. package/dist/lib/input-format.js +89 -117
  128. package/dist/lib/input-format.js.map +1 -1
  129. package/dist/lib/io-context.d.ts +209 -241
  130. package/dist/lib/io-context.js +220 -252
  131. package/dist/lib/io-context.js.map +1 -1
  132. package/dist/lib/log.d.ts +85 -119
  133. package/dist/lib/log.js +85 -122
  134. package/dist/lib/log.js.map +1 -1
  135. package/dist/lib/native-types.d.ts +118 -106
  136. package/dist/lib/native-types.js +0 -7
  137. package/dist/lib/native-types.js.map +1 -1
  138. package/dist/lib/option.d.ts +437 -218
  139. package/dist/lib/option.js +462 -226
  140. package/dist/lib/option.js.map +1 -1
  141. package/dist/lib/output-format.d.ts +77 -101
  142. package/dist/lib/output-format.js +77 -101
  143. package/dist/lib/output-format.js.map +1 -1
  144. package/dist/lib/packet.d.ts +172 -240
  145. package/dist/lib/packet.js +172 -241
  146. package/dist/lib/packet.js.map +1 -1
  147. package/dist/lib/rational.d.ts +0 -2
  148. package/dist/lib/rational.js +0 -2
  149. package/dist/lib/rational.js.map +1 -1
  150. package/dist/lib/software-resample-context.d.ts +241 -325
  151. package/dist/lib/software-resample-context.js +242 -326
  152. package/dist/lib/software-resample-context.js.map +1 -1
  153. package/dist/lib/software-scale-context.d.ts +129 -173
  154. package/dist/lib/software-scale-context.js +131 -175
  155. package/dist/lib/software-scale-context.js.map +1 -1
  156. package/dist/lib/stream.d.ts +87 -197
  157. package/dist/lib/stream.js +87 -197
  158. package/dist/lib/stream.js.map +1 -1
  159. package/dist/lib/utilities.d.ts +435 -181
  160. package/dist/lib/utilities.js +438 -182
  161. package/dist/lib/utilities.js.map +1 -1
  162. package/install/check.js +0 -1
  163. package/install/ffmpeg.js +0 -11
  164. package/package.json +25 -18
  165. package/release_notes.md +24 -59
  166. package/CHANGELOG.md +0 -8
@@ -1,138 +1,253 @@
1
+ import type { AVCodecID, AVMediaType, AVPixelFormat, AVSampleFormat } from '../constants/constants.js';
2
+ import type { FormatContext } from './format-context.js';
3
+ import type { ChannelLayout, IRational } from './types.js';
1
4
  /**
2
- * FFmpeg utility functions collection.
5
+ * Get bytes per audio sample.
3
6
  *
4
- * Provides direct mappings to various FFmpeg utility functions from libavutil.
5
- * These functions handle common operations like timestamp conversion, image buffer
6
- * allocation, sample format queries, and more.
7
+ * Returns the number of bytes required to store a single audio sample
8
+ * in the specified format.
9
+ *
10
+ * Direct mapping to av_get_bytes_per_sample().
11
+ *
12
+ * @param sampleFmt - Audio sample format
13
+ * @returns Number of bytes per sample, or 0 if unknown format
7
14
  *
8
15
  * @example
9
16
  * ```typescript
10
- * import { avImageAlloc, avTs2TimeStr, avRescaleQ, FFmpegError } from 'node-av';
11
- * import { AV_PIX_FMT_YUV420P, IRational } from 'node-av';
12
- *
13
- * // Allocate image buffer
14
- * const image = avImageAlloc(1920, 1080, AV_PIX_FMT_YUV420P, 32);
15
- * console.log(`Allocated ${image.size} bytes`);
17
+ * import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
16
18
  *
17
- * // Convert timestamp to readable time
18
- * const timebase: IRational = { num: 1, den: 90000 };
19
- * const pts = 450000n;
20
- * console.log(avTs2TimeStr(pts, timebase)); // "5.000000"
19
+ * const bytesS16 = avGetBytesPerSample(AV_SAMPLE_FMT_S16); // Returns 2
20
+ * const bytesFloat = avGetBytesPerSample(AV_SAMPLE_FMT_FLTP); // Returns 4
21
21
  * ```
22
+ *
23
+ * @see [av_get_bytes_per_sample](https://ffmpeg.org/doxygen/7.1/group__lavu__sampfmts.html#ga0c3c218e1dd570ad4917c69a35a6c77d) - FFmpeg Doxygen
22
24
  */
23
- import type { AVMediaType, AVPixelFormat, AVSampleFormat } from '../constants/constants.js';
24
- import type { FormatContext } from './format-context.js';
25
- import type { ChannelLayout, IRational } from './types.js';
25
+ export declare function avGetBytesPerSample(sampleFmt: AVSampleFormat): number;
26
26
  /**
27
- * Get bytes per sample for a sample format.
27
+ * Get sample format name.
28
28
  *
29
- * Returns the number of bytes required to store one sample in the given format.
29
+ * Returns the name of the audio sample format as a string.
30
30
  *
31
- * Direct mapping to av_get_bytes_per_sample()
31
+ * Direct mapping to av_get_sample_fmt_name().
32
32
  *
33
33
  * @param sampleFmt - Audio sample format
34
- *
35
- * @returns Number of bytes per sample, or 0 for invalid format
34
+ * @returns Format name, or null if unknown
36
35
  *
37
36
  * @example
38
37
  * ```typescript
39
- * import { avGetBytesPerSample, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT } from 'node-av';
38
+ * import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
40
39
  *
41
- * console.log(avGetBytesPerSample(AV_SAMPLE_FMT_S16)); // 2
42
- * console.log(avGetBytesPerSample(AV_SAMPLE_FMT_FLT)); // 4
40
+ * const name1 = avGetSampleFmtName(AV_SAMPLE_FMT_S16); // Returns "s16"
41
+ * const name2 = avGetSampleFmtName(AV_SAMPLE_FMT_FLTP); // Returns "fltp"
43
42
  * ```
43
+ *
44
+ * @see [av_get_sample_fmt_name](https://ffmpeg.org/doxygen/7.1/group__lavu__sampfmts.html#ga31b9d149b2de9821a65f4f5612970838) - FFmpeg Doxygen
44
45
  */
45
- export declare function avGetBytesPerSample(sampleFmt: AVSampleFormat): number;
46
+ export declare function avGetSampleFmtName(sampleFmt: AVSampleFormat): string | null;
46
47
  /**
47
- * Get the name of a sample format.
48
+ * Get packed sample format.
48
49
  *
49
- * Returns a string describing the sample format.
50
+ * Returns the packed (interleaved) version of a planar sample format,
51
+ * or the format itself if already packed.
50
52
  *
51
- * Direct mapping to av_get_sample_fmt_name()
53
+ * Direct mapping to av_get_packed_sample_fmt().
52
54
  *
53
55
  * @param sampleFmt - Audio sample format
54
- *
55
- * @returns Format name string, or null for invalid format
56
+ * @returns Packed version of the format
56
57
  *
57
58
  * @example
58
59
  * ```typescript
59
- * import { avGetSampleFmtName, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP } from 'node-av';
60
+ * import { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT } from 'node-av/constants';
60
61
  *
61
- * console.log(avGetSampleFmtName(AV_SAMPLE_FMT_S16)); // "s16"
62
- * console.log(avGetSampleFmtName(AV_SAMPLE_FMT_FLTP)); // "fltp"
62
+ * const packed = avGetPackedSampleFmt(AV_SAMPLE_FMT_FLTP); // Returns AV_SAMPLE_FMT_FLT
63
+ * const same = avGetPackedSampleFmt(AV_SAMPLE_FMT_FLT); // Returns AV_SAMPLE_FMT_FLT
63
64
  * ```
64
- */
65
- export declare function avGetSampleFmtName(sampleFmt: AVSampleFormat): string | null;
66
- /**
67
- * Get packed sample format
68
- * Direct mapping to av_get_packed_sample_fmt()
65
+ *
66
+ * @see [av_get_packed_sample_fmt](https://ffmpeg.org/doxygen/7.1/group__lavu__sampfmts.html#ga7817ec0eff4dc6fc0962f31e6d138bca) - FFmpeg Doxygen
67
+ * @see {@link avGetPlanarSampleFmt} For getting planar version
69
68
  */
70
69
  export declare function avGetPackedSampleFmt(sampleFmt: AVSampleFormat): AVSampleFormat;
71
70
  /**
72
- * Get planar sample format
73
- * Direct mapping to av_get_planar_sample_fmt()
71
+ * Get planar sample format.
72
+ *
73
+ * Returns the planar (non-interleaved) version of a packed sample format,
74
+ * or the format itself if already planar.
75
+ *
76
+ * Direct mapping to av_get_planar_sample_fmt().
77
+ *
78
+ * @param sampleFmt - Audio sample format
79
+ * @returns Planar version of the format
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * import { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
84
+ *
85
+ * const planar = avGetPlanarSampleFmt(AV_SAMPLE_FMT_FLT); // Returns AV_SAMPLE_FMT_FLTP
86
+ * const same = avGetPlanarSampleFmt(AV_SAMPLE_FMT_FLTP); // Returns AV_SAMPLE_FMT_FLTP
87
+ * ```
88
+ *
89
+ * @see [av_get_planar_sample_fmt](https://ffmpeg.org/doxygen/7.1/group__lavu__sampfmts.html#ga82caf838259d95cc6c4fd87633bb0e19) - FFmpeg Doxygen
90
+ * @see {@link avGetPackedSampleFmt} For getting packed version
74
91
  */
75
92
  export declare function avGetPlanarSampleFmt(sampleFmt: AVSampleFormat): AVSampleFormat;
76
93
  /**
77
- * Check if sample format is planar
78
- * Direct mapping to av_sample_fmt_is_planar()
94
+ * Check if sample format is planar.
95
+ *
96
+ * Returns whether the audio sample format stores channels in separate planes
97
+ * (planar) rather than interleaved.
98
+ *
99
+ * Direct mapping to av_sample_fmt_is_planar().
100
+ *
101
+ * @param sampleFmt - Audio sample format to check
102
+ * @returns True if planar, false if packed/interleaved
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P } from 'node-av/constants';
107
+ *
108
+ * const isPacked = avSampleFmtIsPlanar(AV_SAMPLE_FMT_S16); // Returns false
109
+ * const isPlanar = avSampleFmtIsPlanar(AV_SAMPLE_FMT_S16P); // Returns true
110
+ * ```
111
+ *
112
+ * @see [av_sample_fmt_is_planar](https://ffmpeg.org/doxygen/7.1/group__lavu__sampfmts.html#ga06ba8a64dc4382c422789a5d0b6bf592) - FFmpeg Doxygen
79
113
  */
80
114
  export declare function avSampleFmtIsPlanar(sampleFmt: AVSampleFormat): boolean;
81
115
  /**
82
- * Get pixel format name
83
- * Direct mapping to av_get_pix_fmt_name()
116
+ * Get codec name from codec ID.
117
+ *
118
+ * Returns the canonical codec name corresponding to the codec ID.
119
+ *
120
+ * Direct mapping to avcodec_get_name().
121
+ *
122
+ * @param codecId - Codec ID from AVCodecID enum
123
+ * @returns Codec name string or null
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * import { AV_CODEC_ID_H264, AV_CODEC_ID_HEVC } from 'node-av/constants';
128
+ * import { avGetCodecName } from 'node-av/lib';
129
+ *
130
+ * const h264Name = avGetCodecName(AV_CODEC_ID_H264); // Returns "h264"
131
+ * const hevcName = avGetCodecName(AV_CODEC_ID_HEVC); // Returns "hevc"
132
+ * const unknownName = avGetCodecName(99999); // Returns null
133
+ * ```
134
+ *
135
+ * @see [avcodec_get_name](https://ffmpeg.org/doxygen/7.1/group__lavc__core.html#ga2016a52e94f867ebe5113bdf448e182d) - FFmpeg Doxygen
136
+ */
137
+ export declare function avGetCodecName(codecId: AVCodecID): string | null;
138
+ /**
139
+ * Get pixel format name.
140
+ *
141
+ * Returns the name of the pixel format as a string.
142
+ *
143
+ * Direct mapping to av_get_pix_fmt_name().
144
+ *
145
+ * @param pixFmt - Pixel format
146
+ * @returns Format name, or null if unknown
147
+ *
148
+ * @example
149
+ * ```typescript
150
+ * import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_RGB24 } from 'node-av/constants';
151
+ *
152
+ * const name1 = avGetPixFmtName(AV_PIX_FMT_YUV420P); // Returns "yuv420p"
153
+ * const name2 = avGetPixFmtName(AV_PIX_FMT_RGB24); // Returns "rgb24"
154
+ * ```
155
+ *
156
+ * @see [av_get_pix_fmt_name](https://ffmpeg.org/doxygen/7.1/pixdesc_8c.html#ab92e2a8a9b58c982560c49df9f01e47e) - FFmpeg Doxygen
84
157
  */
85
158
  export declare function avGetPixFmtName(pixFmt: AVPixelFormat): string | null;
86
159
  /**
87
- * Get pixel format from name
88
- * Direct mapping to av_get_pix_fmt()
160
+ * Get pixel format from name.
161
+ *
162
+ * Returns the pixel format enum value from its string name.
163
+ *
164
+ * Direct mapping to av_get_pix_fmt().
165
+ *
166
+ * @param name - Pixel format name
167
+ * @returns Pixel format enum, or AV_PIX_FMT_NONE if unknown
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * const fmt1 = avGetPixFmtFromName("yuv420p"); // Returns AV_PIX_FMT_YUV420P
172
+ * const fmt2 = avGetPixFmtFromName("rgb24"); // Returns AV_PIX_FMT_RGB24
173
+ * const none = avGetPixFmtFromName("invalid"); // Returns AV_PIX_FMT_NONE
174
+ * ```
175
+ *
176
+ * @see [av_get_pix_fmt](https://ffmpeg.org/doxygen/7.1/pixdesc_8h.html#a925ef18d69c24c3be8c53d5a7dc0660e) - FFmpeg Doxygen
89
177
  */
90
178
  export declare function avGetPixFmtFromName(name: string): AVPixelFormat;
91
179
  /**
92
- * Check if a pixel format is hardware-accelerated
93
- * Direct mapping using av_pix_fmt_desc_get() and AV_PIX_FMT_FLAG_HWACCEL
180
+ * Check if pixel format is hardware accelerated.
181
+ *
182
+ * Returns whether the pixel format represents hardware-accelerated frames
183
+ * (GPU memory) rather than software frames (system memory).
184
+ *
185
+ * Direct mapping to av_pix_fmt_desc_get() with hwaccel check.
186
+ *
187
+ * @param pixFmt - Pixel format to check
188
+ * @returns True if hardware format, false if software format
189
+ *
190
+ * @example
191
+ * ```typescript
192
+ * import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_CUDA } from 'node-av/constants';
193
+ *
194
+ * const isSoftware = avIsHardwarePixelFormat(AV_PIX_FMT_YUV420P); // Returns false
195
+ * const isHardware = avIsHardwarePixelFormat(AV_PIX_FMT_CUDA); // Returns true
196
+ * ```
197
+ *
198
+ * @see [av_pix_fmt_desc_get](https://ffmpeg.org/doxygen/7.1/pixdesc_8c.html#afe0c3e8aef5173de28bbdaea4298f5f0) - FFmpeg Doxygen
94
199
  */
95
200
  export declare function avIsHardwarePixelFormat(pixFmt: AVPixelFormat): boolean;
96
201
  /**
97
- * Get media type string
98
- * Direct mapping to av_get_media_type_string()
202
+ * Get media type string.
203
+ *
204
+ * Returns a human-readable string for the media type.
205
+ *
206
+ * Direct mapping to av_get_media_type_string().
207
+ *
208
+ * @param mediaType - Media type enum
209
+ * @returns Media type name, or null if unknown
210
+ *
211
+ * @example
212
+ * ```typescript
213
+ * import { AVMEDIA_TYPE_VIDEO, AVMEDIA_TYPE_AUDIO } from 'node-av/constants';
214
+ *
215
+ * const video = avGetMediaTypeString(AVMEDIA_TYPE_VIDEO); // Returns "video"
216
+ * const audio = avGetMediaTypeString(AVMEDIA_TYPE_AUDIO); // Returns "audio"
217
+ * ```
218
+ *
219
+ * @see [av_get_media_type_string](https://ffmpeg.org/doxygen/7.1/group__lavu__misc.html#gaf21645cfa855b2caf9699d7dc7b2d08e) - FFmpeg Doxygen
99
220
  */
100
221
  export declare function avGetMediaTypeString(mediaType: AVMediaType): string | null;
101
222
  /**
102
- * Allocate an image with size, pixel format and alignment.
223
+ * Allocate image buffer.
103
224
  *
104
- * Allocates a buffer large enough to hold an image with the given parameters.
105
- * The allocated buffer is properly aligned for optimal performance.
225
+ * Allocates a buffer large enough to hold an image with the specified dimensions
226
+ * and pixel format. Returns buffer and layout information.
106
227
  *
107
- * Direct mapping to av_image_alloc()
228
+ * Direct mapping to av_image_alloc().
108
229
  *
109
230
  * @param width - Image width in pixels
110
231
  * @param height - Image height in pixels
111
232
  * @param pixFmt - Pixel format
112
- * @param align - Buffer alignment (1 for no alignment, 32 for SIMD)
113
- *
114
- * @returns Object containing:
115
- * - buffer: Allocated image buffer
116
- * - size: Total size in bytes
117
- * - linesizes: Array of line sizes for each plane
233
+ * @param align - Buffer alignment (typically 1 or 32)
234
+ * @returns Object with buffer, size, and line sizes
118
235
  *
119
- * @throws {Error} If allocation fails
236
+ * @throws {FFmpegError} If allocation fails
120
237
  *
121
238
  * @example
122
239
  * ```typescript
123
- * import { avImageAlloc, AV_PIX_FMT_YUV420P, FFmpegError } from 'node-av';
124
- *
125
- * try {
126
- * const result = avImageAlloc(1920, 1080, AV_PIX_FMT_YUV420P, 32);
127
- * console.log(`Allocated ${result.size} bytes`);
128
- * console.log(`Y linesize: ${result.linesizes[0]}`);
129
- * // Use result.buffer for image data
130
- * } catch (error) {
131
- * console.error('Failed to allocate image buffer');
132
- * }
240
+ * import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
241
+ *
242
+ * const { buffer, size, linesizes } = avImageAlloc(
243
+ * 1920, 1080, AV_PIX_FMT_YUV420P, 32
244
+ * );
245
+ * console.log(`Allocated ${size} bytes`);
246
+ * console.log(`Line sizes: ${linesizes}`);
133
247
  * ```
134
248
  *
135
- * @see {@link avImageGetBufferSize} To calculate required size without allocating
249
+ * @see [av_image_alloc](https://ffmpeg.org/doxygen/7.1/group__lavu__picture.html#ga841e0a89a642e24141af1918a2c10448) - FFmpeg Doxygen
250
+ * @see {@link avImageGetBufferSize} To calculate size without allocating
136
251
  */
137
252
  export declare function avImageAlloc(width: number, height: number, pixFmt: AVPixelFormat, align: number): {
138
253
  buffer: Buffer;
@@ -140,83 +255,144 @@ export declare function avImageAlloc(width: number, height: number, pixFmt: AVPi
140
255
  linesizes: number[];
141
256
  };
142
257
  /**
143
- * Copy image data from src to dst
144
- * Direct mapping to av_image_copy2()
258
+ * Copy image data.
259
+ *
260
+ * Copies image data from source to destination buffers.
145
261
  *
146
- * @param dstData - Destination data buffers (one per plane)
147
- * @param dstLinesizes - Destination line sizes
148
- * @param srcData - Source data buffers (one per plane)
149
- * @param srcLinesizes - Source line sizes
262
+ * Direct mapping to av_image_copy2().
263
+ *
264
+ * @param dstData - Destination data planes
265
+ * @param dstLinesizes - Destination bytes per line
266
+ * @param srcData - Source data planes
267
+ * @param srcLinesizes - Source bytes per line
150
268
  * @param pixFmt - Pixel format
151
269
  * @param width - Image width
152
270
  * @param height - Image height
271
+ *
272
+ * @example
273
+ * ```typescript
274
+ * avImageCopy2(
275
+ * dstPlanes, dstStrides,
276
+ * srcPlanes, srcStrides,
277
+ * AV_PIX_FMT_YUV420P, 1920, 1080
278
+ * );
279
+ * ```
280
+ *
281
+ * @see [av_image_copy2](https://ffmpeg.org/doxygen/7.1/group__lavu__picture.html#ga911cb7d723163b88bdbbdacbeeaacf2d) - FFmpeg Doxygen
153
282
  */
154
283
  export declare function avImageCopy2(dstData: Buffer[], dstLinesizes: number[], srcData: Buffer[], srcLinesizes: number[], pixFmt: AVPixelFormat, width: number, height: number): void;
155
284
  /**
156
- * Get the required buffer size for an image
157
- * Direct mapping to av_image_get_buffer_size()
285
+ * Get image buffer size.
158
286
  *
159
- * @returns The required buffer size in bytes, or negative on error
287
+ * Calculates the required buffer size for an image without allocating.
288
+ *
289
+ * Direct mapping to av_image_get_buffer_size().
290
+ *
291
+ * @param pixFmt - Pixel format
292
+ * @param width - Image width
293
+ * @param height - Image height
294
+ * @param align - Buffer alignment
295
+ * @returns Required buffer size in bytes
296
+ *
297
+ * @example
298
+ * ```typescript
299
+ * import { AV_PIX_FMT_RGB24 } from 'node-av/constants';
300
+ *
301
+ * const size = avImageGetBufferSize(AV_PIX_FMT_RGB24, 1920, 1080, 1);
302
+ * console.log(`Need ${size} bytes for Full HD RGB24`);
303
+ * ```
304
+ *
305
+ * @see [av_image_get_buffer_size](https://ffmpeg.org/doxygen/7.1/group__lavu__picture.html#ga24a67963c3ae0054a2a4bab35930e694) - FFmpeg Doxygen
306
+ * @see {@link avImageAlloc} To allocate the buffer
160
307
  */
161
308
  export declare function avImageGetBufferSize(pixFmt: AVPixelFormat, width: number, height: number, align: number): number;
162
309
  /**
163
- * Copy image data to a single buffer.
310
+ * Copy image to buffer.
164
311
  *
165
- * Copies image data from separate planes into a single continuous buffer.
166
- * Useful for serialization or when a single buffer is required.
312
+ * Copies image data from separate planes to a single contiguous buffer.
167
313
  *
168
- * Direct mapping to av_image_copy_to_buffer()
314
+ * Direct mapping to av_image_copy_to_buffer().
169
315
  *
170
316
  * @param dst - Destination buffer
171
- * @param dstSize - Size of destination buffer in bytes
172
- * @param srcData - Array of source data planes
173
- * @param srcLinesize - Array of source linesizes
317
+ * @param dstSize - Destination buffer size
318
+ * @param srcData - Source data planes
319
+ * @param srcLinesize - Source bytes per line
174
320
  * @param pixFmt - Pixel format
175
- * @param width - Image width in pixels
176
- * @param height - Image height in pixels
321
+ * @param width - Image width
322
+ * @param height - Image height
177
323
  * @param align - Buffer alignment
178
- *
179
- * @returns Number of bytes written to dst, or negative AVERROR on error:
180
- * - >0: Number of bytes written
181
- * - AVERROR(EINVAL): Invalid parameters
182
- * - AVERROR(ENOMEM): Destination buffer too small
324
+ * @returns Bytes written, or negative AVERROR
183
325
  *
184
326
  * @example
185
327
  * ```typescript
186
- * import { avImageCopyToBuffer, avImageGetBufferSize, FFmpegError } from 'node-av';
187
- * import { AV_PIX_FMT_RGB24 } from 'node-av';
188
- *
189
- * const width = 640, height = 480;
190
- * const pixFmt = AV_PIX_FMT_RGB24;
191
- *
192
- * // Calculate required buffer size
193
- * const dstSize = avImageGetBufferSize(pixFmt, width, height, 1);
194
- * const dst = Buffer.alloc(dstSize);
195
- *
196
- * const ret = avImageCopyToBuffer(
197
- * dst, dstSize,
198
- * srcData, srcLinesize,
199
- * pixFmt, width, height, 1
328
+ * const buffer = Buffer.alloc(bufferSize);
329
+ * const written = avImageCopyToBuffer(
330
+ * buffer, bufferSize,
331
+ * srcPlanes, srcStrides,
332
+ * AV_PIX_FMT_YUV420P, 1920, 1080, 1
200
333
  * );
201
- *
202
- * FFmpegError.throwIfError(ret, 'avImageCopyToBuffer');
203
- * console.log(`Copied ${ret} bytes to buffer`);
204
334
  * ```
335
+ *
336
+ * @see [av_image_copy_to_buffer](https://ffmpeg.org/doxygen/7.1/group__lavu__picture.html#ga6f8576f1ef0c2d9a9f7c5ac7f9a28c52) - FFmpeg Doxygen
205
337
  */
206
338
  export declare function avImageCopyToBuffer(dst: Buffer, dstSize: number, srcData: Buffer[] | null, srcLinesize: number[] | null, pixFmt: AVPixelFormat, width: number, height: number, align: number): number;
207
339
  /**
208
- * Convert timestamp to string
209
- * Direct mapping to av_ts2str()
340
+ * Convert timestamp to string.
341
+ *
342
+ * Converts a timestamp to a string representation.
343
+ *
344
+ * Direct mapping to av_ts2str().
345
+ *
346
+ * @param ts - Timestamp value
347
+ * @returns String representation
348
+ *
349
+ * @example
350
+ * ```typescript
351
+ * const str1 = avTs2Str(1234567n); // Returns "1234567"
352
+ * const str2 = avTs2Str(null); // Returns "NOPTS"
353
+ * ```
354
+ *
355
+ * @see [av_ts2str](https://ffmpeg.org/doxygen/7.1/timestamp_8h.html#a86d797e907fa454ed5fd34bfb0bcd747) - FFmpeg Doxygen
210
356
  */
211
357
  export declare function avTs2Str(ts: bigint | number | null): string;
212
358
  /**
213
- * Convert timestamp to time string
214
- * Direct mapping to av_ts2timestr()
359
+ * Convert timestamp to time string.
360
+ *
361
+ * Converts a timestamp to a time string using the specified time base.
362
+ *
363
+ * Direct mapping to av_ts2timestr().
364
+ *
365
+ * @param ts - Timestamp value
366
+ * @param timeBase - Time base for conversion
367
+ * @returns Time string representation
368
+ *
369
+ * @example
370
+ * ```typescript
371
+ * const timeStr = avTs2TimeStr(90000n, { num: 1, den: 90000 }); // Returns "1.000000"
372
+ * const nopts = avTs2TimeStr(null, { num: 1, den: 1000 }); // Returns "NOPTS"
373
+ * ```
374
+ *
375
+ * @see [av_ts2timestr](https://ffmpeg.org/doxygen/7.1/timestamp_8h.html#ad344b91ede6b86fc0a530611293f42da) - FFmpeg Doxygen
215
376
  */
216
377
  export declare function avTs2TimeStr(ts: bigint | number | null, timeBase: IRational | null): string;
217
378
  /**
218
- * Helper to separate image allocation result into separate arrays
219
- * This is useful when you need separate data and linesize arrays
379
+ * Allocate image arrays.
380
+ *
381
+ * Allocates image data as separate plane arrays.
382
+ *
383
+ * @param width - Image width
384
+ * @param height - Image height
385
+ * @param pixFmt - Pixel format
386
+ * @param align - Buffer alignment
387
+ * @returns Object with data planes, line sizes, and total size
388
+ *
389
+ * @example
390
+ * ```typescript
391
+ * const { data, linesizes, size } = avImageAllocArrays(
392
+ * 1920, 1080, AV_PIX_FMT_YUV420P, 32
393
+ * );
394
+ * console.log(`Allocated ${data.length} planes, total ${size} bytes`);
395
+ * ```
220
396
  */
221
397
  export declare function avImageAllocArrays(width: number, height: number, pixFmt: AVPixelFormat, align: number): {
222
398
  data: Buffer[];
@@ -224,63 +400,125 @@ export declare function avImageAllocArrays(width: number, height: number, pixFmt
224
400
  size: number;
225
401
  };
226
402
  /**
227
- * Compare two timestamps
228
- * Direct mapping to av_compare_ts()
403
+ * Compare timestamps.
229
404
  *
230
- * @returns -1 if tsA < tsB, 0 if tsA == tsB, 1 if tsA > tsB
405
+ * Compares two timestamps with different time bases.
406
+ *
407
+ * Direct mapping to av_compare_ts().
408
+ *
409
+ * @param tsA - First timestamp
410
+ * @param tbA - First time base
411
+ * @param tsB - Second timestamp
412
+ * @param tbB - Second time base
413
+ * @returns -1 if A < B, 0 if A == B, 1 if A > B
414
+ *
415
+ * @example
416
+ * ```typescript
417
+ * const cmp = avCompareTs(
418
+ * 1000n, { num: 1, den: 1000 }, // 1 second
419
+ * 900n, { num: 1, den: 900 } // 1 second
420
+ * );
421
+ * // Returns 0 (equal)
422
+ * ```
423
+ *
424
+ * @see [av_compare_ts](https://ffmpeg.org/doxygen/7.1/group__lavu__math.html#ga151744358fff630942b926e67e67c415) - FFmpeg Doxygen
231
425
  */
232
426
  export declare function avCompareTs(tsA: bigint | number | null, tbA: IRational, tsB: bigint | number | null, tbB: IRational): number;
233
427
  /**
234
- * Rescale a timestamp from one timebase to another
235
- * Direct mapping to av_rescale_q()
236
- */
237
- export declare function avRescaleQ(a: bigint | number | null, bq: IRational, cq: IRational): bigint;
238
- /**
239
- * Sleep for a specified number of microseconds.
428
+ * Rescale timestamp.
240
429
  *
241
- * Provides a cross-platform microsecond sleep function.
242
- * Useful for timing operations or frame pacing.
430
+ * Rescales a timestamp from one time base to another.
243
431
  *
244
- * Direct mapping to av_usleep()
432
+ * Direct mapping to av_rescale_q().
245
433
  *
246
- * @param usec - Number of microseconds to sleep
434
+ * @param a - Timestamp to rescale
435
+ * @param bq - Source time base
436
+ * @param cq - Destination time base
437
+ * @returns Rescaled timestamp
247
438
  *
248
439
  * @example
249
440
  * ```typescript
250
- * import { avUsleep } from 'node-av';
441
+ * // Convert 1 second from 1000Hz to 90kHz
442
+ * const rescaled = avRescaleQ(
443
+ * 1000n,
444
+ * { num: 1, den: 1000 }, // 1000 Hz
445
+ * { num: 1, den: 90000 } // 90 kHz
446
+ * );
447
+ * // Returns 90000n
448
+ * ```
251
449
  *
252
- * // Sleep for 100ms (100,000 microseconds)
253
- * avUsleep(100000);
450
+ * @see [av_rescale_q](https://ffmpeg.org/doxygen/7.1/group__lavu__math.html#gaf02994a8bbeaa91d4757df179cbe567f) - FFmpeg Doxygen
451
+ */
452
+ export declare function avRescaleQ(a: bigint | number | null, bq: IRational, cq: IRational): bigint;
453
+ /**
454
+ * Sleep for microseconds.
455
+ *
456
+ * Suspends execution for the specified number of microseconds.
254
457
  *
255
- * // Sleep for 1 second
256
- * avUsleep(1000000);
458
+ * Direct mapping to av_usleep().
257
459
  *
258
- * // Frame pacing for 30fps (33.33ms per frame)
259
- * const frameTime = 1000000 / 30;
260
- * avUsleep(frameTime);
460
+ * @param usec - Microseconds to sleep
461
+ *
462
+ * @example
463
+ * ```typescript
464
+ * avUsleep(1000000); // Sleep for 1 second
465
+ * avUsleep(16667); // Sleep for ~16.67ms (60fps frame time)
261
466
  * ```
467
+ *
468
+ * @see [av_usleep](https://ffmpeg.org/doxygen/7.1/time_8c.html#a4eee9c65835652a808973f4bc1641a51) - FFmpeg Doxygen
262
469
  */
263
470
  export declare function avUsleep(usec: number): void;
264
471
  /**
265
- * Rescale a timestamp with rounding
266
- * Direct mapping to av_rescale_rnd()
472
+ * Rescale with rounding.
473
+ *
474
+ * Rescales a value with specified rounding behavior.
475
+ *
476
+ * Direct mapping to av_rescale_rnd().
267
477
  *
268
478
  * @param a - Value to rescale
269
- * @param b - Numerator of scale factor
270
- * @param c - Denominator of scale factor
271
- * @param rnd - Rounding mode (AVRounding enum)
479
+ * @param b - Multiplier
480
+ * @param c - Divisor
481
+ * @param rnd - Rounding mode (AV_ROUND_*)
272
482
  * @returns Rescaled value
483
+ *
484
+ * @example
485
+ * ```typescript
486
+ * import { AV_ROUND_NEAR_INF } from 'node-av/constants';
487
+ *
488
+ * const rescaled = avRescaleRnd(1000n, 90000n, 1000n, AV_ROUND_NEAR_INF);
489
+ * // Returns 90000n
490
+ * ```
491
+ *
492
+ * @see [av_rescale_rnd](https://ffmpeg.org/doxygen/7.1/group__lavu__math.html#ga82d40664213508918093822461cc597e) - FFmpeg Doxygen
273
493
  */
274
494
  export declare function avRescaleRnd(a: bigint | number, b: bigint | number, c: bigint | number, rnd: number): bigint;
275
495
  /**
276
- * Allocate audio sample buffers
277
- * Direct mapping to av_samples_alloc()
496
+ * Allocate audio samples buffer.
278
497
  *
279
- * @param nbChannels - Number of channels
498
+ * Allocates buffers for audio samples with the specified format.
499
+ *
500
+ * Direct mapping to av_samples_alloc().
501
+ *
502
+ * @param nbChannels - Number of audio channels
280
503
  * @param nbSamples - Number of samples per channel
281
504
  * @param sampleFmt - Sample format
282
- * @param align - Buffer alignment (0 for default)
283
- * @returns Object with allocated data buffers, linesize and total size, or error code
505
+ * @param align - Buffer alignment
506
+ * @returns Object with data buffers, line size, and total size
507
+ *
508
+ * @throws {FFmpegError} If allocation fails
509
+ *
510
+ * @example
511
+ * ```typescript
512
+ * import { AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
513
+ *
514
+ * const { data, linesize, size } = avSamplesAlloc(
515
+ * 2, 1024, AV_SAMPLE_FMT_FLTP, 0
516
+ * );
517
+ * console.log(`Allocated ${data.length} buffers, ${size} bytes total`);
518
+ * ```
519
+ *
520
+ * @see [av_samples_alloc](https://ffmpeg.org/doxygen/7.1/group__lavu__sampmanip.html#ga4db4c77f928d32c7d8854732f50b8c04) - FFmpeg Doxygen
521
+ * @see {@link avSamplesGetBufferSize} To calculate size without allocating
284
522
  */
285
523
  export declare function avSamplesAlloc(nbChannels: number, nbSamples: number, sampleFmt: AVSampleFormat, align: number): {
286
524
  data: Buffer[];
@@ -288,59 +526,75 @@ export declare function avSamplesAlloc(nbChannels: number, nbSamples: number, sa
288
526
  size: number;
289
527
  };
290
528
  /**
291
- * Get the required buffer size for audio samples
292
- * Direct mapping to av_samples_get_buffer_size()
529
+ * Get audio samples buffer size.
530
+ *
531
+ * Calculates the required buffer size for audio samples.
532
+ *
533
+ * Direct mapping to av_samples_get_buffer_size().
293
534
  *
294
535
  * @param nbChannels - Number of channels
295
536
  * @param nbSamples - Number of samples per channel
296
537
  * @param sampleFmt - Sample format
297
- * @param align - Buffer alignment (0 for default)
298
- * @returns Object with size and linesize, or error code
538
+ * @param align - Buffer alignment
539
+ * @returns Object with size and line size
540
+ *
541
+ * @throws {FFmpegError} If parameters are invalid
542
+ *
543
+ * @example
544
+ * ```typescript
545
+ * import { AV_SAMPLE_FMT_S16 } from 'node-av/constants';
546
+ *
547
+ * const { size, linesize } = avSamplesGetBufferSize(
548
+ * 2, 1024, AV_SAMPLE_FMT_S16, 0
549
+ * );
550
+ * console.log(`Need ${size} bytes, ${linesize} per channel`);
551
+ * ```
552
+ *
553
+ * @see [av_samples_get_buffer_size](https://ffmpeg.org/doxygen/7.1/group__lavu__sampfmts.html#gaa7368bc4e3a366b688e81938ed55eb06) - FFmpeg Doxygen
554
+ * @see {@link avSamplesAlloc} To allocate the buffer
299
555
  */
300
556
  export declare function avSamplesGetBufferSize(nbChannels: number, nbSamples: number, sampleFmt: AVSampleFormat, align: number): {
301
557
  size: number;
302
558
  linesize: number;
303
559
  };
304
560
  /**
305
- * Get a string description of a channel layout.
306
- * Direct mapping to av_channel_layout_describe()
561
+ * Describe channel layout.
307
562
  *
308
- * @param channelLayout - The channel layout object with order, nbChannels, and mask
309
- * @returns String description of the channel layout, or null if invalid
563
+ * Returns a human-readable description of a channel layout.
564
+ *
565
+ * Direct mapping to av_channel_layout_describe().
566
+ *
567
+ * @param channelLayout - Channel layout to describe
568
+ * @returns Layout description string, or null
569
+ *
570
+ * @example
571
+ * ```typescript
572
+ * const stereo = { nbChannels: 2, order: 1, u: { mask: 3n } };
573
+ * const desc = avChannelLayoutDescribe(stereo); // Returns "stereo"
574
+ * ```
575
+ *
576
+ * @see [av_channel_layout_describe](https://ffmpeg.org/doxygen/7.1/group__lavu__audio__channels.html#gacc7d7d1a280248aafb8f9196c9d4e24f) - FFmpeg Doxygen
310
577
  */
311
578
  export declare function avChannelLayoutDescribe(channelLayout: Partial<ChannelLayout>): string | null;
312
579
  /**
313
- * Create an SDP (Session Description Protocol) string for RTP/RTSP streaming.
580
+ * Create SDP from format contexts.
314
581
  *
315
- * Generates an SDP description from one or more FormatContext objects.
316
- * Useful for RTP/RTSP streaming scenarios where you need to describe
317
- * the media streams to clients.
582
+ * Creates an SDP (Session Description Protocol) string from format contexts.
583
+ * Used for RTP/RTSP streaming.
318
584
  *
319
- * Direct mapping to av_sdp_create()
585
+ * Direct mapping to av_sdp_create().
320
586
  *
321
- * @param contexts - Array of FormatContext objects to describe
322
- * @returns SDP string on success, or null on failure
323
- *
324
- * @throws {FFmpegError} On invalid parameters or SDP creation failure
587
+ * @param contexts - Array of format contexts
588
+ * @returns SDP string, or null on error
325
589
  *
326
590
  * @example
327
591
  * ```typescript
328
- * import { avSdpCreate, FormatContext, FFmpegError } from 'node-av';
329
- *
330
- * // Create format contexts for RTP output
331
- * const contexts: FormatContext[] = [];
332
- *
333
- * const ctx = new FormatContext();
334
- * // ... configure context for RTP output ...
335
- * contexts.push(ctx);
336
- *
337
- * // Generate SDP
338
- * const sdp = avSdpCreate(contexts);
592
+ * const sdp = avSdpCreate([outputContext]);
339
593
  * if (sdp) {
340
- * console.log('SDP:', result);
594
+ * console.log('SDP:\n' + sdp);
341
595
  * }
342
- *
343
- * // Use the SDP string for RTSP server or save to .sdp file
344
596
  * ```
597
+ *
598
+ * @see [av_sdp_create](https://ffmpeg.org/doxygen/7.1/group__lavf__misc.html#gaa2a7353a6bb0c8726797abd56b176af0) - FFmpeg Doxygen
345
599
  */
346
600
  export declare function avSdpCreate(contexts: FormatContext[]): string | null;