@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.
Files changed (254) hide show
  1. package/BUILD_LINUX.md +61 -0
  2. package/LICENSE.md +22 -0
  3. package/README.md +662 -0
  4. package/build_mac_local.sh +69 -0
  5. package/dist/api/audio-frame-buffer.d.ts +205 -0
  6. package/dist/api/audio-frame-buffer.js +287 -0
  7. package/dist/api/audio-frame-buffer.js.map +1 -0
  8. package/dist/api/bitstream-filter.d.ts +820 -0
  9. package/dist/api/bitstream-filter.js +1242 -0
  10. package/dist/api/bitstream-filter.js.map +1 -0
  11. package/dist/api/constants.d.ts +44 -0
  12. package/dist/api/constants.js +45 -0
  13. package/dist/api/constants.js.map +1 -0
  14. package/dist/api/data/test_av1.ivf +0 -0
  15. package/dist/api/data/test_h264.h264 +0 -0
  16. package/dist/api/data/test_hevc.h265 +0 -0
  17. package/dist/api/data/test_mjpeg.mjpeg +0 -0
  18. package/dist/api/data/test_vp8.ivf +0 -0
  19. package/dist/api/data/test_vp9.ivf +0 -0
  20. package/dist/api/decoder.d.ts +1088 -0
  21. package/dist/api/decoder.js +1775 -0
  22. package/dist/api/decoder.js.map +1 -0
  23. package/dist/api/demuxer.d.ts +1219 -0
  24. package/dist/api/demuxer.js +2081 -0
  25. package/dist/api/demuxer.js.map +1 -0
  26. package/dist/api/device.d.ts +586 -0
  27. package/dist/api/device.js +961 -0
  28. package/dist/api/device.js.map +1 -0
  29. package/dist/api/encoder.d.ts +1132 -0
  30. package/dist/api/encoder.js +1988 -0
  31. package/dist/api/encoder.js.map +1 -0
  32. package/dist/api/filter-complex.d.ts +821 -0
  33. package/dist/api/filter-complex.js +1604 -0
  34. package/dist/api/filter-complex.js.map +1 -0
  35. package/dist/api/filter-presets.d.ts +1286 -0
  36. package/dist/api/filter-presets.js +2152 -0
  37. package/dist/api/filter-presets.js.map +1 -0
  38. package/dist/api/filter.d.ts +1234 -0
  39. package/dist/api/filter.js +1976 -0
  40. package/dist/api/filter.js.map +1 -0
  41. package/dist/api/fmp4-stream.d.ts +426 -0
  42. package/dist/api/fmp4-stream.js +739 -0
  43. package/dist/api/fmp4-stream.js.map +1 -0
  44. package/dist/api/hardware.d.ts +651 -0
  45. package/dist/api/hardware.js +1260 -0
  46. package/dist/api/hardware.js.map +1 -0
  47. package/dist/api/index.d.ts +17 -0
  48. package/dist/api/index.js +32 -0
  49. package/dist/api/index.js.map +1 -0
  50. package/dist/api/io-stream.d.ts +307 -0
  51. package/dist/api/io-stream.js +282 -0
  52. package/dist/api/io-stream.js.map +1 -0
  53. package/dist/api/muxer.d.ts +957 -0
  54. package/dist/api/muxer.js +2002 -0
  55. package/dist/api/muxer.js.map +1 -0
  56. package/dist/api/pipeline.d.ts +607 -0
  57. package/dist/api/pipeline.js +1145 -0
  58. package/dist/api/pipeline.js.map +1 -0
  59. package/dist/api/utilities/async-queue.d.ts +120 -0
  60. package/dist/api/utilities/async-queue.js +211 -0
  61. package/dist/api/utilities/async-queue.js.map +1 -0
  62. package/dist/api/utilities/audio-sample.d.ts +117 -0
  63. package/dist/api/utilities/audio-sample.js +112 -0
  64. package/dist/api/utilities/audio-sample.js.map +1 -0
  65. package/dist/api/utilities/channel-layout.d.ts +76 -0
  66. package/dist/api/utilities/channel-layout.js +80 -0
  67. package/dist/api/utilities/channel-layout.js.map +1 -0
  68. package/dist/api/utilities/electron-shared-texture.d.ts +328 -0
  69. package/dist/api/utilities/electron-shared-texture.js +503 -0
  70. package/dist/api/utilities/electron-shared-texture.js.map +1 -0
  71. package/dist/api/utilities/image.d.ts +207 -0
  72. package/dist/api/utilities/image.js +213 -0
  73. package/dist/api/utilities/image.js.map +1 -0
  74. package/dist/api/utilities/index.d.ts +12 -0
  75. package/dist/api/utilities/index.js +25 -0
  76. package/dist/api/utilities/index.js.map +1 -0
  77. package/dist/api/utilities/media-type.d.ts +49 -0
  78. package/dist/api/utilities/media-type.js +53 -0
  79. package/dist/api/utilities/media-type.js.map +1 -0
  80. package/dist/api/utilities/pixel-format.d.ts +89 -0
  81. package/dist/api/utilities/pixel-format.js +97 -0
  82. package/dist/api/utilities/pixel-format.js.map +1 -0
  83. package/dist/api/utilities/sample-format.d.ts +129 -0
  84. package/dist/api/utilities/sample-format.js +141 -0
  85. package/dist/api/utilities/sample-format.js.map +1 -0
  86. package/dist/api/utilities/scheduler.d.ts +138 -0
  87. package/dist/api/utilities/scheduler.js +98 -0
  88. package/dist/api/utilities/scheduler.js.map +1 -0
  89. package/dist/api/utilities/streaming.d.ts +186 -0
  90. package/dist/api/utilities/streaming.js +309 -0
  91. package/dist/api/utilities/streaming.js.map +1 -0
  92. package/dist/api/utilities/timestamp.d.ts +193 -0
  93. package/dist/api/utilities/timestamp.js +206 -0
  94. package/dist/api/utilities/timestamp.js.map +1 -0
  95. package/dist/api/utilities/whisper-model.d.ts +310 -0
  96. package/dist/api/utilities/whisper-model.js +528 -0
  97. package/dist/api/utilities/whisper-model.js.map +1 -0
  98. package/dist/api/utils.d.ts +19 -0
  99. package/dist/api/utils.js +39 -0
  100. package/dist/api/utils.js.map +1 -0
  101. package/dist/api/whisper.d.ts +324 -0
  102. package/dist/api/whisper.js +362 -0
  103. package/dist/api/whisper.js.map +1 -0
  104. package/dist/constants/channel-layouts.d.ts +53 -0
  105. package/dist/constants/channel-layouts.js +57 -0
  106. package/dist/constants/channel-layouts.js.map +1 -0
  107. package/dist/constants/constants.d.ts +2325 -0
  108. package/dist/constants/constants.js +1887 -0
  109. package/dist/constants/constants.js.map +1 -0
  110. package/dist/constants/decoders.d.ts +633 -0
  111. package/dist/constants/decoders.js +641 -0
  112. package/dist/constants/decoders.js.map +1 -0
  113. package/dist/constants/encoders.d.ts +295 -0
  114. package/dist/constants/encoders.js +308 -0
  115. package/dist/constants/encoders.js.map +1 -0
  116. package/dist/constants/hardware.d.ts +26 -0
  117. package/dist/constants/hardware.js +27 -0
  118. package/dist/constants/hardware.js.map +1 -0
  119. package/dist/constants/index.d.ts +5 -0
  120. package/dist/constants/index.js +6 -0
  121. package/dist/constants/index.js.map +1 -0
  122. package/dist/ffmpeg/index.d.ts +99 -0
  123. package/dist/ffmpeg/index.js +115 -0
  124. package/dist/ffmpeg/index.js.map +1 -0
  125. package/dist/ffmpeg/utils.d.ts +31 -0
  126. package/dist/ffmpeg/utils.js +68 -0
  127. package/dist/ffmpeg/utils.js.map +1 -0
  128. package/dist/ffmpeg/version.d.ts +6 -0
  129. package/dist/ffmpeg/version.js +7 -0
  130. package/dist/ffmpeg/version.js.map +1 -0
  131. package/dist/index.d.ts +4 -0
  132. package/dist/index.js +9 -0
  133. package/dist/index.js.map +1 -0
  134. package/dist/lib/audio-fifo.d.ts +399 -0
  135. package/dist/lib/audio-fifo.js +431 -0
  136. package/dist/lib/audio-fifo.js.map +1 -0
  137. package/dist/lib/binding.d.ts +228 -0
  138. package/dist/lib/binding.js +60 -0
  139. package/dist/lib/binding.js.map +1 -0
  140. package/dist/lib/bitstream-filter-context.d.ts +379 -0
  141. package/dist/lib/bitstream-filter-context.js +441 -0
  142. package/dist/lib/bitstream-filter-context.js.map +1 -0
  143. package/dist/lib/bitstream-filter.d.ts +140 -0
  144. package/dist/lib/bitstream-filter.js +154 -0
  145. package/dist/lib/bitstream-filter.js.map +1 -0
  146. package/dist/lib/codec-context.d.ts +1071 -0
  147. package/dist/lib/codec-context.js +1354 -0
  148. package/dist/lib/codec-context.js.map +1 -0
  149. package/dist/lib/codec-parameters.d.ts +616 -0
  150. package/dist/lib/codec-parameters.js +761 -0
  151. package/dist/lib/codec-parameters.js.map +1 -0
  152. package/dist/lib/codec-parser.d.ts +201 -0
  153. package/dist/lib/codec-parser.js +213 -0
  154. package/dist/lib/codec-parser.js.map +1 -0
  155. package/dist/lib/codec.d.ts +586 -0
  156. package/dist/lib/codec.js +713 -0
  157. package/dist/lib/codec.js.map +1 -0
  158. package/dist/lib/device.d.ts +291 -0
  159. package/dist/lib/device.js +324 -0
  160. package/dist/lib/device.js.map +1 -0
  161. package/dist/lib/dictionary.d.ts +333 -0
  162. package/dist/lib/dictionary.js +372 -0
  163. package/dist/lib/dictionary.js.map +1 -0
  164. package/dist/lib/error.d.ts +242 -0
  165. package/dist/lib/error.js +303 -0
  166. package/dist/lib/error.js.map +1 -0
  167. package/dist/lib/fifo.d.ts +416 -0
  168. package/dist/lib/fifo.js +453 -0
  169. package/dist/lib/fifo.js.map +1 -0
  170. package/dist/lib/filter-context.d.ts +712 -0
  171. package/dist/lib/filter-context.js +789 -0
  172. package/dist/lib/filter-context.js.map +1 -0
  173. package/dist/lib/filter-graph-segment.d.ts +160 -0
  174. package/dist/lib/filter-graph-segment.js +171 -0
  175. package/dist/lib/filter-graph-segment.js.map +1 -0
  176. package/dist/lib/filter-graph.d.ts +641 -0
  177. package/dist/lib/filter-graph.js +704 -0
  178. package/dist/lib/filter-graph.js.map +1 -0
  179. package/dist/lib/filter-inout.d.ts +198 -0
  180. package/dist/lib/filter-inout.js +257 -0
  181. package/dist/lib/filter-inout.js.map +1 -0
  182. package/dist/lib/filter.d.ts +243 -0
  183. package/dist/lib/filter.js +272 -0
  184. package/dist/lib/filter.js.map +1 -0
  185. package/dist/lib/format-context.d.ts +1254 -0
  186. package/dist/lib/format-context.js +1379 -0
  187. package/dist/lib/format-context.js.map +1 -0
  188. package/dist/lib/frame-utils.d.ts +116 -0
  189. package/dist/lib/frame-utils.js +98 -0
  190. package/dist/lib/frame-utils.js.map +1 -0
  191. package/dist/lib/frame.d.ts +1222 -0
  192. package/dist/lib/frame.js +1435 -0
  193. package/dist/lib/frame.js.map +1 -0
  194. package/dist/lib/hardware-device-context.d.ts +362 -0
  195. package/dist/lib/hardware-device-context.js +383 -0
  196. package/dist/lib/hardware-device-context.js.map +1 -0
  197. package/dist/lib/hardware-frames-context.d.ts +419 -0
  198. package/dist/lib/hardware-frames-context.js +477 -0
  199. package/dist/lib/hardware-frames-context.js.map +1 -0
  200. package/dist/lib/index.d.ts +35 -0
  201. package/dist/lib/index.js +60 -0
  202. package/dist/lib/index.js.map +1 -0
  203. package/dist/lib/input-format.d.ts +249 -0
  204. package/dist/lib/input-format.js +306 -0
  205. package/dist/lib/input-format.js.map +1 -0
  206. package/dist/lib/io-context.d.ts +696 -0
  207. package/dist/lib/io-context.js +769 -0
  208. package/dist/lib/io-context.js.map +1 -0
  209. package/dist/lib/log.d.ts +174 -0
  210. package/dist/lib/log.js +184 -0
  211. package/dist/lib/log.js.map +1 -0
  212. package/dist/lib/native-types.d.ts +946 -0
  213. package/dist/lib/native-types.js +2 -0
  214. package/dist/lib/native-types.js.map +1 -0
  215. package/dist/lib/option.d.ts +927 -0
  216. package/dist/lib/option.js +1583 -0
  217. package/dist/lib/option.js.map +1 -0
  218. package/dist/lib/output-format.d.ts +180 -0
  219. package/dist/lib/output-format.js +213 -0
  220. package/dist/lib/output-format.js.map +1 -0
  221. package/dist/lib/packet.d.ts +501 -0
  222. package/dist/lib/packet.js +590 -0
  223. package/dist/lib/packet.js.map +1 -0
  224. package/dist/lib/rational.d.ts +251 -0
  225. package/dist/lib/rational.js +278 -0
  226. package/dist/lib/rational.js.map +1 -0
  227. package/dist/lib/software-resample-context.d.ts +552 -0
  228. package/dist/lib/software-resample-context.js +592 -0
  229. package/dist/lib/software-resample-context.js.map +1 -0
  230. package/dist/lib/software-scale-context.d.ts +344 -0
  231. package/dist/lib/software-scale-context.js +366 -0
  232. package/dist/lib/software-scale-context.js.map +1 -0
  233. package/dist/lib/stream.d.ts +379 -0
  234. package/dist/lib/stream.js +526 -0
  235. package/dist/lib/stream.js.map +1 -0
  236. package/dist/lib/sync-queue.d.ts +179 -0
  237. package/dist/lib/sync-queue.js +197 -0
  238. package/dist/lib/sync-queue.js.map +1 -0
  239. package/dist/lib/types.d.ts +34 -0
  240. package/dist/lib/types.js +2 -0
  241. package/dist/lib/types.js.map +1 -0
  242. package/dist/lib/utilities.d.ts +1127 -0
  243. package/dist/lib/utilities.js +1225 -0
  244. package/dist/lib/utilities.js.map +1 -0
  245. package/dist/utils/electron.d.ts +49 -0
  246. package/dist/utils/electron.js +63 -0
  247. package/dist/utils/electron.js.map +1 -0
  248. package/dist/utils/index.d.ts +4 -0
  249. package/dist/utils/index.js +5 -0
  250. package/dist/utils/index.js.map +1 -0
  251. package/install/check.js +121 -0
  252. package/install/ffmpeg.js +66 -0
  253. package/jellyfin-ffmpeg.patch +181 -0
  254. package/package.json +129 -0
@@ -0,0 +1,761 @@
1
+ import { bindings } from './binding.js';
2
+ import { Rational } from './rational.js';
3
+ import { stringToFourCC } from './utilities.js';
4
+ /**
5
+ * Codec parameters for stream configuration.
6
+ *
7
+ * Stores essential codec parameters without requiring a full codec context.
8
+ * Used to describe stream properties in containers, transfer codec configuration
9
+ * between contexts, and initialize decoders/encoders. Contains format, dimensions,
10
+ * sample rates, and other codec-specific parameters.
11
+ *
12
+ * Direct mapping to FFmpeg's AVCodecParameters.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { CodecParameters, CodecContext, FFmpegError } from 'node-av';
17
+ *
18
+ * // Create and allocate parameters
19
+ * const params = new CodecParameters();
20
+ * params.alloc();
21
+ *
22
+ * // Copy from stream
23
+ * const stream = formatContext.streams[0];
24
+ * const ret = stream.codecpar.copy(params);
25
+ * FFmpegError.throwIfError(ret, 'copy');
26
+ *
27
+ * // Transfer to codec context
28
+ * const ret2 = params.toContext(codecContext);
29
+ * FFmpegError.throwIfError(ret2, 'toContext');
30
+ *
31
+ * // Get parameters info
32
+ * console.log(`Codec: ${params.codecId}`);
33
+ * console.log(`Dimensions: ${params.width}x${params.height}`);
34
+ * console.log(`Bitrate: ${params.bitRate}`);
35
+ * ```
36
+ *
37
+ * @see [AVCodecParameters](https://ffmpeg.org/doxygen/trunk/structAVCodecParameters.html) - FFmpeg Doxygen
38
+ * @see {@link CodecContext} For full codec operations
39
+ * @see {@link Stream} For stream parameters
40
+ */
41
+ export class CodecParameters {
42
+ native;
43
+ constructor() {
44
+ this.native = new bindings.CodecParameters();
45
+ }
46
+ /**
47
+ * Codec type.
48
+ *
49
+ * Media type (video, audio, subtitle, etc.).
50
+ *
51
+ * Direct mapping to AVCodecParameters->codec_type.
52
+ */
53
+ get codecType() {
54
+ return this.native.codecType;
55
+ }
56
+ set codecType(value) {
57
+ this.native.codecType = value;
58
+ }
59
+ /**
60
+ * Codec ID.
61
+ *
62
+ * Specific codec identifier (e.g., AV_CODEC_ID_H264).
63
+ *
64
+ * Direct mapping to AVCodecParameters->codec_id.
65
+ */
66
+ get codecId() {
67
+ return this.native.codecId;
68
+ }
69
+ set codecId(value) {
70
+ this.native.codecId = value;
71
+ }
72
+ /**
73
+ * Codec tag.
74
+ *
75
+ * Additional codec tag used by some formats.
76
+ *
77
+ * Direct mapping to AVCodecParameters->codec_tag.
78
+ */
79
+ get codecTag() {
80
+ return this.native.codecTag;
81
+ }
82
+ set codecTag(value) {
83
+ if (typeof value === 'string') {
84
+ if (value.length !== 4) {
85
+ throw new Error('FourCC string must be exactly 4 characters');
86
+ }
87
+ value = stringToFourCC(value);
88
+ }
89
+ this.native.codecTag = value;
90
+ }
91
+ /**
92
+ * Codec tag as string (FourCC).
93
+ *
94
+ * Human-readable string representation of the codec tag.
95
+ * Returns the FourCC (Four Character Code) format.
96
+ */
97
+ get codecTagString() {
98
+ return this.native.codecTagString;
99
+ }
100
+ /**
101
+ * Extra codec data.
102
+ *
103
+ * Codec-specific initialization data (e.g., H.264 SPS/PPS).
104
+ *
105
+ * Direct mapping to AVCodecParameters->extradata.
106
+ */
107
+ get extradata() {
108
+ return this.native.extradata;
109
+ }
110
+ set extradata(value) {
111
+ this.native.extradata = value;
112
+ }
113
+ /**
114
+ * Extra data size.
115
+ *
116
+ * Size of extradata buffer in bytes.
117
+ *
118
+ * Direct mapping to AVCodecParameters->extradata_size.
119
+ */
120
+ get extradataSize() {
121
+ return this.native.extradataSize;
122
+ }
123
+ /**
124
+ * Pixel or sample format.
125
+ *
126
+ * Format of video pixels or audio samples.
127
+ *
128
+ * Direct mapping to AVCodecParameters->format.
129
+ */
130
+ get format() {
131
+ return this.native.format;
132
+ }
133
+ set format(value) {
134
+ this.native.format = value;
135
+ }
136
+ /**
137
+ * Bit rate.
138
+ *
139
+ * Average bitrate in bits per second.
140
+ *
141
+ * Direct mapping to AVCodecParameters->bit_rate.
142
+ */
143
+ get bitRate() {
144
+ return this.native.bitRate;
145
+ }
146
+ set bitRate(value) {
147
+ this.native.bitRate = value;
148
+ }
149
+ /**
150
+ * Number of bits per coded sample.
151
+ *
152
+ * Bits per sample/pixel from the demuxer (needed by some codecs).
153
+ * For uncompressed formats, this is the bits per sample.
154
+ *
155
+ * Direct mapping to AVCodecParameters->bits_per_coded_sample.
156
+ */
157
+ get bitsPerCodedSample() {
158
+ return this.native.bitsPerCodedSample;
159
+ }
160
+ set bitsPerCodedSample(value) {
161
+ this.native.bitsPerCodedSample = value;
162
+ }
163
+ /**
164
+ * Number of bits per raw sample.
165
+ *
166
+ * Bits per sample before compression/encoding.
167
+ * Only set when different from bitsPerCodedSample.
168
+ *
169
+ * Direct mapping to AVCodecParameters->bits_per_raw_sample.
170
+ */
171
+ get bitsPerRawSample() {
172
+ return this.native.bitsPerRawSample;
173
+ }
174
+ set bitsPerRawSample(value) {
175
+ this.native.bitsPerRawSample = value;
176
+ }
177
+ /**
178
+ * Codec profile.
179
+ *
180
+ * Profile level (e.g., baseline, main, high for H.264).
181
+ *
182
+ * Direct mapping to AVCodecParameters->profile.
183
+ */
184
+ get profile() {
185
+ return this.native.profile;
186
+ }
187
+ set profile(value) {
188
+ this.native.profile = value;
189
+ }
190
+ /**
191
+ * Codec level.
192
+ *
193
+ * Level within the profile.
194
+ *
195
+ * Direct mapping to AVCodecParameters->level.
196
+ */
197
+ get level() {
198
+ return this.native.level;
199
+ }
200
+ set level(value) {
201
+ this.native.level = value;
202
+ }
203
+ /**
204
+ * Video width.
205
+ *
206
+ * Width of video frames in pixels.
207
+ *
208
+ * Direct mapping to AVCodecParameters->width.
209
+ */
210
+ get width() {
211
+ return this.native.width;
212
+ }
213
+ set width(value) {
214
+ this.native.width = value;
215
+ }
216
+ /**
217
+ * Video height.
218
+ *
219
+ * Height of video frames in pixels.
220
+ *
221
+ * Direct mapping to AVCodecParameters->height.
222
+ */
223
+ get height() {
224
+ return this.native.height;
225
+ }
226
+ set height(value) {
227
+ this.native.height = value;
228
+ }
229
+ /**
230
+ * Sample aspect ratio.
231
+ *
232
+ * Pixel aspect ratio for video.
233
+ *
234
+ * Direct mapping to AVCodecParameters->sample_aspect_ratio.
235
+ */
236
+ get sampleAspectRatio() {
237
+ const sar = this.native.sampleAspectRatio;
238
+ return new Rational(sar.num, sar.den);
239
+ }
240
+ set sampleAspectRatio(value) {
241
+ this.native.sampleAspectRatio = { num: value.num, den: value.den };
242
+ }
243
+ /**
244
+ * Frame rate.
245
+ *
246
+ * Video frame rate in frames per second.
247
+ *
248
+ * Direct mapping to AVCodecParameters->framerate.
249
+ */
250
+ get frameRate() {
251
+ const fr = this.native.frameRate;
252
+ return new Rational(fr.num, fr.den);
253
+ }
254
+ set frameRate(value) {
255
+ this.native.frameRate = { num: value.num, den: value.den };
256
+ }
257
+ /**
258
+ * Color range.
259
+ *
260
+ * MPEG (limited) or JPEG (full) range.
261
+ *
262
+ * Direct mapping to AVCodecParameters->color_range.
263
+ */
264
+ get colorRange() {
265
+ return this.native.colorRange;
266
+ }
267
+ set colorRange(value) {
268
+ this.native.colorRange = value;
269
+ }
270
+ /**
271
+ * Color primaries.
272
+ *
273
+ * Chromaticity coordinates of source primaries.
274
+ *
275
+ * Direct mapping to AVCodecParameters->color_primaries.
276
+ */
277
+ get colorPrimaries() {
278
+ return this.native.colorPrimaries;
279
+ }
280
+ set colorPrimaries(value) {
281
+ this.native.colorPrimaries = value;
282
+ }
283
+ /**
284
+ * Color transfer characteristic.
285
+ *
286
+ * Color transfer function (gamma).
287
+ *
288
+ * Direct mapping to AVCodecParameters->color_trc.
289
+ */
290
+ get colorTrc() {
291
+ return this.native.colorTrc;
292
+ }
293
+ set colorTrc(value) {
294
+ this.native.colorTrc = value;
295
+ }
296
+ /**
297
+ * Color space.
298
+ *
299
+ * YUV colorspace type.
300
+ *
301
+ * Direct mapping to AVCodecParameters->color_space.
302
+ */
303
+ get colorSpace() {
304
+ return this.native.colorSpace;
305
+ }
306
+ set colorSpace(value) {
307
+ this.native.colorSpace = value;
308
+ }
309
+ /**
310
+ * Chroma sample location.
311
+ *
312
+ * Location of chroma samples.
313
+ *
314
+ * Direct mapping to AVCodecParameters->chroma_location.
315
+ */
316
+ get chromaLocation() {
317
+ return this.native.chromaLocation;
318
+ }
319
+ set chromaLocation(value) {
320
+ this.native.chromaLocation = value;
321
+ }
322
+ /**
323
+ * Audio channel layout.
324
+ *
325
+ * Configuration of audio channels.
326
+ *
327
+ * Direct mapping to AVCodecParameters->ch_layout.
328
+ */
329
+ get channelLayout() {
330
+ return this.native.channelLayout;
331
+ }
332
+ set channelLayout(value) {
333
+ this.native.channelLayout = value;
334
+ }
335
+ /**
336
+ * Number of audio channels.
337
+ *
338
+ * @deprecated Use channelLayout.nbChannels instead
339
+ *
340
+ * Direct mapping to AVCodecParameters->channels.
341
+ */
342
+ get channels() {
343
+ return this.native.channels;
344
+ }
345
+ set channels(value) {
346
+ this.native.channels = value;
347
+ }
348
+ /**
349
+ * Audio sample rate.
350
+ *
351
+ * Sample rate in Hz.
352
+ *
353
+ * Direct mapping to AVCodecParameters->sample_rate.
354
+ */
355
+ get sampleRate() {
356
+ return this.native.sampleRate;
357
+ }
358
+ set sampleRate(value) {
359
+ this.native.sampleRate = value;
360
+ }
361
+ /**
362
+ * Audio frame size in samples.
363
+ *
364
+ * Number of samples per audio frame for codecs with constant frame size.
365
+ * For AAC this is typically 1024, for MP3 it's 1152.
366
+ * For codecs with variable frame size, this may be 0.
367
+ *
368
+ * Direct mapping to AVCodecParameters->frame_size.
369
+ */
370
+ get frameSize() {
371
+ return this.native.frameSize;
372
+ }
373
+ set frameSize(value) {
374
+ this.native.frameSize = value;
375
+ }
376
+ /**
377
+ * Initial audio padding.
378
+ *
379
+ * Amount of padding (priming) samples at the beginning of the audio stream.
380
+ * For AAC encoding, this is typically 1024 samples.
381
+ * The muxer uses this value to correctly calculate packet timestamps.
382
+ *
383
+ * Direct mapping to AVCodecParameters->initial_padding.
384
+ */
385
+ get initialPadding() {
386
+ return this.native.initialPadding;
387
+ }
388
+ set initialPadding(value) {
389
+ this.native.initialPadding = value;
390
+ }
391
+ /**
392
+ * Video delay in frames.
393
+ *
394
+ * Number of frames the decoded output will be delayed relative to the encoded input.
395
+ * Used for timestamp correction in video streams.
396
+ *
397
+ * Direct mapping to AVCodecParameters->video_delay.
398
+ */
399
+ get videoDelay() {
400
+ return this.native.videoDelay;
401
+ }
402
+ set videoDelay(value) {
403
+ this.native.videoDelay = value;
404
+ }
405
+ /**
406
+ * Number of coded side data entries.
407
+ *
408
+ * Returns the count of coded side data attached to codec parameters.
409
+ *
410
+ * @returns Number of side data entries
411
+ *
412
+ * @example
413
+ * ```typescript
414
+ * console.log(`Codec has ${params.nbCodedSideData} side data entries`);
415
+ * ```
416
+ */
417
+ get nbCodedSideData() {
418
+ return this.native.nbCodedSideData;
419
+ }
420
+ /**
421
+ * Codec properties.
422
+ *
423
+ * Bitfield of AV_CODEC_PROP_* flags indicating codec features.
424
+ *
425
+ * Direct mapping to AVCodecDescriptor->props.
426
+ *
427
+ * @example
428
+ * ```typescript
429
+ * import { AV_CODEC_PROP_FIELDS } from 'node-av/constants';
430
+ *
431
+ * const props = params.codecProperties;
432
+ * if (props & AV_CODEC_PROP_FIELDS) {
433
+ * console.log('Codec supports interlaced video (fields)');
434
+ * }
435
+ * ```
436
+ *
437
+ * @see {@link hasProperties} For checking specific properties
438
+ */
439
+ get codecProperties() {
440
+ return this.native.codecProperties;
441
+ }
442
+ /**
443
+ * Check if codec has specific properties.
444
+ *
445
+ * Tests whether all specified properties are present using bitwise AND.
446
+ *
447
+ * @param props - One or more property values to check
448
+ *
449
+ * @returns true if all specified properties are present, false otherwise
450
+ *
451
+ * @example
452
+ * ```typescript
453
+ * import { AV_CODEC_PROP_FIELDS, AV_CODEC_PROP_REORDER } from 'node-av/constants';
454
+ *
455
+ * if (params.hasProperties(AV_CODEC_PROP_FIELDS)) {
456
+ * console.log('Codec supports interlaced video (fields)');
457
+ * }
458
+ *
459
+ * // Check multiple properties
460
+ * if (params.hasProperties(AV_CODEC_PROP_LOSSY, AV_CODEC_PROP_REORDER)) {
461
+ * console.log('Codec is lossy and supports frame reordering');
462
+ * }
463
+ * ```
464
+ *
465
+ * @see {@link codecProperties} For direct properties access
466
+ */
467
+ hasProperties(...props) {
468
+ for (const prop of props) {
469
+ if ((this.native.codecProperties & prop) !== prop) {
470
+ return false;
471
+ }
472
+ }
473
+ return true;
474
+ }
475
+ /**
476
+ * Allocate codec parameters.
477
+ *
478
+ * Allocates memory for the parameters structure.
479
+ *
480
+ * Direct mapping to avcodec_parameters_alloc().
481
+ *
482
+ * @throws {Error} If allocation fails (ENOMEM)
483
+ *
484
+ * @example
485
+ * ```typescript
486
+ * const params = new CodecParameters();
487
+ * params.alloc();
488
+ * // Parameters ready for use
489
+ * ```
490
+ *
491
+ * @see {@link free} To deallocate
492
+ */
493
+ alloc() {
494
+ this.native.alloc();
495
+ }
496
+ /**
497
+ * Free codec parameters.
498
+ *
499
+ * Releases all memory associated with the parameters.
500
+ *
501
+ * Direct mapping to avcodec_parameters_free().
502
+ *
503
+ * @example
504
+ * ```typescript
505
+ * params.free();
506
+ * // Parameters now invalid
507
+ * ```
508
+ *
509
+ * @see {@link alloc} To allocate
510
+ * @see {@link Symbol.dispose} For automatic cleanup
511
+ */
512
+ free() {
513
+ this.native.free();
514
+ }
515
+ /**
516
+ * Copy parameters to destination.
517
+ *
518
+ * Copies all codec parameters to another instance.
519
+ *
520
+ * Direct mapping to avcodec_parameters_copy().
521
+ *
522
+ * @param dst - Destination parameters
523
+ *
524
+ * @returns 0 on success, negative AVERROR on error:
525
+ * - AVERROR_ENOMEM: Memory allocation failure
526
+ *
527
+ * @example
528
+ * ```typescript
529
+ * import { FFmpegError } from 'node-av';
530
+ *
531
+ * const dst = new CodecParameters();
532
+ * dst.alloc();
533
+ * const ret = src.copy(dst);
534
+ * FFmpegError.throwIfError(ret, 'copy');
535
+ * ```
536
+ */
537
+ copy(dst) {
538
+ return this.native.copy(dst.getNative());
539
+ }
540
+ /**
541
+ * Fill parameters from codec context.
542
+ *
543
+ * Extracts codec parameters from a configured codec context.
544
+ *
545
+ * Direct mapping to avcodec_parameters_from_context().
546
+ *
547
+ * @param codecContext - Source codec context
548
+ *
549
+ * @returns 0 on success, negative AVERROR on error:
550
+ * - AVERROR_ENOMEM: Memory allocation failure
551
+ *
552
+ * @example
553
+ * ```typescript
554
+ * import { FFmpegError } from 'node-av';
555
+ *
556
+ * // Extract parameters from encoder
557
+ * const ret = params.fromContext(encoderContext);
558
+ * FFmpegError.throwIfError(ret, 'fromContext');
559
+ * ```
560
+ *
561
+ * @see {@link toContext} To apply to context
562
+ */
563
+ fromContext(codecContext) {
564
+ return this.native.fromContext(codecContext.getNative());
565
+ }
566
+ /**
567
+ * Apply parameters to codec context.
568
+ *
569
+ * Configures a codec context with these parameters.
570
+ * Essential for initializing decoders with stream parameters.
571
+ *
572
+ * Direct mapping to avcodec_parameters_to_context().
573
+ *
574
+ * @param codecContext - Destination codec context
575
+ *
576
+ * @returns 0 on success, negative AVERROR on error:
577
+ * - AVERROR_ENOMEM: Memory allocation failure
578
+ *
579
+ * @example
580
+ * ```typescript
581
+ * import { FFmpegError } from 'node-av';
582
+ *
583
+ * // Configure decoder with stream parameters
584
+ * const stream = formatContext.streams[0];
585
+ * const ret = stream.codecpar.toContext(decoderContext);
586
+ * FFmpegError.throwIfError(ret, 'toContext');
587
+ * ```
588
+ *
589
+ * @see {@link fromContext} To extract from context
590
+ */
591
+ toContext(codecContext) {
592
+ return this.native.toContext(codecContext.getNative());
593
+ }
594
+ /**
595
+ * Parse extradata to extract codec parameters.
596
+ *
597
+ * Opens a decoder to parse extradata (SPS/PPS for H.264, etc.) and extract
598
+ * codec parameters like width/height for video or sample_rate for audio.
599
+ * This is used when extradata exists (e.g., from SDP sprop-parameter-sets)
600
+ * but dimensions are missing due to insufficient probesize.
601
+ *
602
+ * Uses FFmpeg's decoder to parse extradata, same as avformat_find_stream_info()
603
+ * does internally. Works for all codecs (H.264, H.265, VP9, AV1, etc.).
604
+ *
605
+ * @returns 0 on success, negative error code on failure
606
+ *
607
+ * @example
608
+ * ```typescript
609
+ * import { FFmpegError } from 'node-av';
610
+ *
611
+ * // After opening RTSP with low probesize
612
+ * const input = await Demuxer.open('rtsp://...', {
613
+ * options: { probesize: 32 }
614
+ * });
615
+ *
616
+ * const stream = input.video();
617
+ * if (stream.codecpar.width === 0 && stream.codecpar.extradata) {
618
+ * // Parse extradata to get dimensions
619
+ * const ret = stream.codecpar.parseExtradata();
620
+ * FFmpegError.throwIfError(ret, 'parseExtradata');
621
+ * console.log(`Dimensions: ${stream.codecpar.width}x${stream.codecpar.height}`);
622
+ * }
623
+ * ```
624
+ */
625
+ parseExtradata() {
626
+ return this.native.parseExtradata();
627
+ }
628
+ /**
629
+ * Convert to JSON representation.
630
+ *
631
+ * Returns all codec parameters as a plain object.
632
+ * Useful for debugging and serialization.
633
+ *
634
+ * @returns Object with all parameter values
635
+ *
636
+ * @example
637
+ * ```typescript
638
+ * const json = params.toJSON();
639
+ * console.log(JSON.stringify(json, null, 2));
640
+ * ```
641
+ */
642
+ toJSON() {
643
+ return this.native.toJSON();
644
+ }
645
+ /**
646
+ * Get coded side data.
647
+ *
648
+ * Retrieves additional data associated with the codec parameters
649
+ * (e.g., HDR metadata, Dolby Vision configuration, mastering display).
650
+ *
651
+ * Direct mapping to accessing AVCodecParameters.coded_side_data.
652
+ *
653
+ * @param type - Type of side data to retrieve
654
+ *
655
+ * @returns Side data buffer, or null if not present
656
+ *
657
+ * @example
658
+ * ```typescript
659
+ * import { AV_PKT_DATA_MASTERING_DISPLAY_METADATA } from 'node-av/constants';
660
+ *
661
+ * // Get HDR mastering display metadata
662
+ * const hdrData = params.getCodedSideData(AV_PKT_DATA_MASTERING_DISPLAY_METADATA);
663
+ * if (hdrData) {
664
+ * console.log(`HDR metadata: ${hdrData.length} bytes`);
665
+ * }
666
+ * ```
667
+ *
668
+ * @see {@link addCodedSideData} To add side data
669
+ * @see {@link nbCodedSideData} For count of side data entries
670
+ */
671
+ getCodedSideData(type) {
672
+ return this.native.getCodedSideData(type);
673
+ }
674
+ /**
675
+ * Get all coded side data entries.
676
+ *
677
+ * Returns all side data attached to the codec parameters.
678
+ * Each entry contains the type and data buffer.
679
+ * This allows iteration over all side data like FFmpeg CLI does.
680
+ *
681
+ * Direct mapping to accessing AVCodecParameters.coded_side_data array.
682
+ *
683
+ * @returns Array of side data entries with type and data
684
+ *
685
+ * @example
686
+ * ```typescript
687
+ * // Iterate all side data like FFmpeg does (ffmpeg_mux_init.c)
688
+ * const allSideData = params.getAllCodedSideData();
689
+ * for (const sd of allSideData) {
690
+ * console.log(`Type: ${sd.type}, Size: ${sd.data.length}`);
691
+ * // Copy to output stream
692
+ * outParams.addCodedSideData(sd.type, sd.data);
693
+ * }
694
+ * ```
695
+ *
696
+ * @see {@link getCodedSideData} To get specific side data by type
697
+ * @see {@link addCodedSideData} To add side data
698
+ * @see {@link nbCodedSideData} For count of side data entries
699
+ */
700
+ getAllCodedSideData() {
701
+ return this.native.getAllCodedSideData();
702
+ }
703
+ /**
704
+ * Add coded side data to codec parameters.
705
+ *
706
+ * Attaches additional data to the codec parameters. The data is copied.
707
+ * Commonly used for HDR metadata, Dolby Vision configuration, etc.
708
+ *
709
+ * Direct mapping to av_packet_side_data_add() for coded_side_data.
710
+ *
711
+ * @param type - Type of side data
712
+ *
713
+ * @param data - Side data buffer
714
+ *
715
+ * @returns 0 on success, negative AVERROR on error
716
+ *
717
+ * @example
718
+ * ```typescript
719
+ * import { FFmpegError } from 'node-av';
720
+ * import { AV_PKT_DATA_DOVI_CONF } from 'node-av/constants';
721
+ *
722
+ * // Add Dolby Vision configuration
723
+ * const doviConf = Buffer.from([...]); // Dolby Vision config data
724
+ * const ret = params.addCodedSideData(AV_PKT_DATA_DOVI_CONF, doviConf);
725
+ * FFmpegError.throwIfError(ret, 'addCodedSideData');
726
+ * ```
727
+ *
728
+ * @see {@link getCodedSideData} To retrieve side data
729
+ */
730
+ addCodedSideData(type, data) {
731
+ return this.native.addCodedSideData(type, data);
732
+ }
733
+ /**
734
+ * Get the underlying native CodecParameters object.
735
+ *
736
+ * @returns The native CodecParameters binding object
737
+ *
738
+ * @internal
739
+ */
740
+ getNative() {
741
+ return this.native;
742
+ }
743
+ /**
744
+ * Dispose of the codec parameters.
745
+ *
746
+ * Implements the Disposable interface for automatic cleanup.
747
+ *
748
+ * @example
749
+ * ```typescript
750
+ * {
751
+ * using params = new CodecParameters();
752
+ * params.alloc();
753
+ * // Use params...
754
+ * } // Automatically disposed when leaving scope
755
+ * ```
756
+ */
757
+ [Symbol.dispose]() {
758
+ this.native[Symbol.dispose]();
759
+ }
760
+ }
761
+ //# sourceMappingURL=codec-parameters.js.map