node-av 1.1.0 → 1.2.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 (134) hide show
  1. package/README.md +51 -38
  2. package/dist/api/bitstream-filter.d.ts +180 -123
  3. package/dist/api/bitstream-filter.js +180 -125
  4. package/dist/api/bitstream-filter.js.map +1 -1
  5. package/dist/api/decoder.d.ts +279 -132
  6. package/dist/api/decoder.js +285 -142
  7. package/dist/api/decoder.js.map +1 -1
  8. package/dist/api/encoder.d.ts +246 -162
  9. package/dist/api/encoder.js +272 -208
  10. package/dist/api/encoder.js.map +1 -1
  11. package/dist/api/filter-presets.d.ts +690 -94
  12. package/dist/api/filter-presets.js +686 -102
  13. package/dist/api/filter-presets.js.map +1 -1
  14. package/dist/api/filter.d.ts +249 -213
  15. package/dist/api/filter.js +252 -242
  16. package/dist/api/filter.js.map +1 -1
  17. package/dist/api/hardware.d.ts +224 -117
  18. package/dist/api/hardware.js +380 -214
  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 -61
  24. package/dist/api/io-stream.js +43 -46
  25. package/dist/api/io-stream.js.map +1 -1
  26. package/dist/api/media-input.d.ts +242 -140
  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 +206 -128
  30. package/dist/api/media-output.js +210 -128
  31. package/dist/api/media-output.js.map +1 -1
  32. package/dist/api/pipeline.d.ts +168 -38
  33. package/dist/api/pipeline.js +238 -14
  34. package/dist/api/pipeline.js.map +1 -1
  35. package/dist/api/types.d.ts +21 -187
  36. package/dist/api/utils.d.ts +1 -2
  37. package/dist/api/utils.js +9 -0
  38. package/dist/api/utils.js.map +1 -1
  39. package/dist/lib/audio-fifo.d.ts +127 -170
  40. package/dist/lib/audio-fifo.js +130 -173
  41. package/dist/lib/audio-fifo.js.map +1 -1
  42. package/dist/lib/binding.js +5 -0
  43. package/dist/lib/binding.js.map +1 -1
  44. package/dist/lib/bitstream-filter-context.d.ts +139 -184
  45. package/dist/lib/bitstream-filter-context.js +139 -188
  46. package/dist/lib/bitstream-filter-context.js.map +1 -1
  47. package/dist/lib/bitstream-filter.d.ts +68 -54
  48. package/dist/lib/bitstream-filter.js +68 -54
  49. package/dist/lib/bitstream-filter.js.map +1 -1
  50. package/dist/lib/codec-context.d.ts +316 -380
  51. package/dist/lib/codec-context.js +316 -381
  52. package/dist/lib/codec-context.js.map +1 -1
  53. package/dist/lib/codec-parameters.d.ts +160 -170
  54. package/dist/lib/codec-parameters.js +162 -172
  55. package/dist/lib/codec-parameters.js.map +1 -1
  56. package/dist/lib/codec-parser.d.ts +91 -104
  57. package/dist/lib/codec-parser.js +92 -103
  58. package/dist/lib/codec-parser.js.map +1 -1
  59. package/dist/lib/codec.d.ts +264 -281
  60. package/dist/lib/codec.js +268 -285
  61. package/dist/lib/codec.js.map +1 -1
  62. package/dist/lib/dictionary.d.ts +149 -203
  63. package/dist/lib/dictionary.js +158 -212
  64. package/dist/lib/dictionary.js.map +1 -1
  65. package/dist/lib/error.d.ts +96 -130
  66. package/dist/lib/error.js +98 -128
  67. package/dist/lib/error.js.map +1 -1
  68. package/dist/lib/filter-context.d.ts +284 -218
  69. package/dist/lib/filter-context.js +290 -227
  70. package/dist/lib/filter-context.js.map +1 -1
  71. package/dist/lib/filter-graph.d.ts +251 -292
  72. package/dist/lib/filter-graph.js +253 -294
  73. package/dist/lib/filter-graph.js.map +1 -1
  74. package/dist/lib/filter-inout.d.ts +87 -95
  75. package/dist/lib/filter-inout.js +87 -95
  76. package/dist/lib/filter-inout.js.map +1 -1
  77. package/dist/lib/filter.d.ts +93 -111
  78. package/dist/lib/filter.js +93 -111
  79. package/dist/lib/filter.js.map +1 -1
  80. package/dist/lib/format-context.d.ts +320 -428
  81. package/dist/lib/format-context.js +313 -385
  82. package/dist/lib/format-context.js.map +1 -1
  83. package/dist/lib/frame.d.ts +262 -405
  84. package/dist/lib/frame.js +263 -408
  85. package/dist/lib/frame.js.map +1 -1
  86. package/dist/lib/hardware-device-context.d.ts +149 -203
  87. package/dist/lib/hardware-device-context.js +149 -203
  88. package/dist/lib/hardware-device-context.js.map +1 -1
  89. package/dist/lib/hardware-frames-context.d.ts +170 -180
  90. package/dist/lib/hardware-frames-context.js +171 -181
  91. package/dist/lib/hardware-frames-context.js.map +1 -1
  92. package/dist/lib/index.d.ts +2 -1
  93. package/dist/lib/index.js +2 -2
  94. package/dist/lib/index.js.map +1 -1
  95. package/dist/lib/input-format.d.ts +89 -117
  96. package/dist/lib/input-format.js +89 -117
  97. package/dist/lib/input-format.js.map +1 -1
  98. package/dist/lib/io-context.d.ts +209 -241
  99. package/dist/lib/io-context.js +220 -252
  100. package/dist/lib/io-context.js.map +1 -1
  101. package/dist/lib/log.d.ts +85 -119
  102. package/dist/lib/log.js +85 -122
  103. package/dist/lib/log.js.map +1 -1
  104. package/dist/lib/native-types.d.ts +117 -106
  105. package/dist/lib/native-types.js +0 -7
  106. package/dist/lib/native-types.js.map +1 -1
  107. package/dist/lib/option.d.ts +284 -241
  108. package/dist/lib/option.js +309 -249
  109. package/dist/lib/option.js.map +1 -1
  110. package/dist/lib/output-format.d.ts +77 -101
  111. package/dist/lib/output-format.js +77 -101
  112. package/dist/lib/output-format.js.map +1 -1
  113. package/dist/lib/packet.d.ts +172 -240
  114. package/dist/lib/packet.js +172 -241
  115. package/dist/lib/packet.js.map +1 -1
  116. package/dist/lib/rational.d.ts +0 -2
  117. package/dist/lib/rational.js +0 -2
  118. package/dist/lib/rational.js.map +1 -1
  119. package/dist/lib/software-resample-context.d.ts +241 -325
  120. package/dist/lib/software-resample-context.js +242 -326
  121. package/dist/lib/software-resample-context.js.map +1 -1
  122. package/dist/lib/software-scale-context.d.ts +129 -173
  123. package/dist/lib/software-scale-context.js +131 -175
  124. package/dist/lib/software-scale-context.js.map +1 -1
  125. package/dist/lib/stream.d.ts +87 -197
  126. package/dist/lib/stream.js +87 -197
  127. package/dist/lib/stream.js.map +1 -1
  128. package/dist/lib/utilities.d.ts +372 -181
  129. package/dist/lib/utilities.js +373 -182
  130. package/dist/lib/utilities.js.map +1 -1
  131. package/install/check.js +0 -1
  132. package/package.json +21 -12
  133. package/release_notes.md +43 -59
  134. package/CHANGELOG.md +0 -8
@@ -1,60 +1,46 @@
1
- /**
2
- * Decoder - High-level wrapper for media decoding
3
- *
4
- * Simplifies FFmpeg's decoding API with automatic codec selection,
5
- * parameter configuration, and frame management.
6
- *
7
- * Handles codec initialization, packet decoding, and frame output.
8
- * Supports hardware acceleration and zero-copy transcoding.
9
- *
10
- * @module api/decoder
11
- */
12
1
  import { AVERROR_EOF, AVMEDIA_TYPE_VIDEO } from '../constants/constants.js';
13
2
  import { AVERROR_EAGAIN, Codec, CodecContext, FFmpegError, Frame } from '../lib/index.js';
14
3
  /**
15
- * High-level decoder for media streams.
16
- *
17
- * Handles codec initialization, packet decoding, and frame output.
18
- * Designed for simple, efficient decoding workflows.
4
+ * High-level decoder for audio and video streams.
19
5
  *
20
- * Manages codec context lifecycle and provides automatic cleanup.
21
- * Supports hardware acceleration with zero-copy frame sharing.
6
+ * Provides a simplified interface for decoding media streams from packets to frames.
7
+ * Handles codec initialization, hardware acceleration setup, and frame management.
8
+ * Supports both synchronous packet-by-packet decoding and async iteration over frames.
9
+ * Essential component in media processing pipelines for converting compressed data to raw frames.
22
10
  *
23
11
  * @example
24
12
  * ```typescript
25
- * // Create decoder for video stream
26
- * const media = await MediaInput.open('video.mp4');
27
- * const stream = media.video(); // Get video stream
28
- * const decoder = await Decoder.create(stream);
13
+ * import { MediaInput, Decoder } from 'node-av/api';
29
14
  *
30
- * // Decode packets
31
- * for await (const packet of media.packets()) {
32
- * if (packet.streamIndex === stream.index) {
33
- * const frame = await decoder.decode(packet);
34
- * if (frame) {
35
- * console.log(`Decoded frame: ${frame.width}x${frame.height}`);
36
- * // Process frame...
37
- * }
38
- * }
39
- * }
15
+ * // Open media and create decoder
16
+ * await using input = await MediaInput.open('video.mp4');
17
+ * using decoder = await Decoder.create(input.video());
40
18
  *
41
- * // Flush decoder
42
- * const lastFrame = await decoder.flush();
43
- * decoder.close();
19
+ * // Decode frames
20
+ * for await (const frame of decoder.frames(input.packets())) {
21
+ * console.log(`Decoded frame: ${frame.width}x${frame.height}`);
22
+ * frame.free();
23
+ * }
44
24
  * ```
45
25
  *
46
26
  * @example
47
27
  * ```typescript
48
- * // With hardware acceleration
49
- * const hw = await HardwareContext.auto();
50
- * const stream = media.video();
51
- * const decoder = await Decoder.create(stream, {
52
- * hardware: hw
53
- * });
54
- * // ... use decoder
55
- * decoder.close();
56
- * hw?.dispose(); // Safe to call again (no-op)
28
+ * import { HardwareContext } from 'node-av/api';
29
+ * import { AV_HWDEVICE_TYPE_CUDA } from 'node-av/constants';
30
+ *
31
+ * // Setup hardware acceleration
32
+ * const hw = HardwareContext.create(AV_HWDEVICE_TYPE_CUDA);
33
+ * using decoder = await Decoder.create(stream, { hardware: hw });
34
+ *
35
+ * // Frames will be decoded on GPU
36
+ * for await (const frame of decoder.frames(packets)) {
37
+ * // frame.hwFramesCtx contains GPU memory reference
38
+ * }
57
39
  * ```
40
+ *
41
+ * @see {@link Encoder} For encoding frames to packets
42
+ * @see {@link MediaInput} For reading media files
43
+ * @see {@link HardwareContext} For GPU acceleration
58
44
  */
59
45
  export class Decoder {
60
46
  codecContext;
@@ -62,15 +48,14 @@ export class Decoder {
62
48
  streamIndex;
63
49
  stream;
64
50
  isOpen = true;
65
- hardware; // Reference to hardware context for auto-sharing frames context
51
+ hardware;
66
52
  /**
67
- * Private constructor - use Decoder.create() instead.
68
- *
69
- * Initializes the decoder with a codec context and allocates a frame buffer.
53
+ * @param codecContext - Configured codec context
54
+ * @param stream - Media stream being decoded
55
+ * @param hardware - Optional hardware context
56
+ * Use {@link create} factory method
70
57
  *
71
- * @param codecContext - Initialized codec context
72
- * @param stream - The stream this decoder is for
73
- * @param hardware - Optional hardware context for auto-sharing frames context
58
+ * @internal
74
59
  */
75
60
  constructor(codecContext, stream, hardware) {
76
61
  this.codecContext = codecContext;
@@ -81,27 +66,49 @@ export class Decoder {
81
66
  this.frame.alloc();
82
67
  }
83
68
  /**
84
- * Create a decoder for a specific stream.
69
+ * Create a decoder for a media stream.
85
70
  *
86
- * Factory method that handles codec discovery, context setup,
87
- * and initialization.
71
+ * Initializes a decoder with the appropriate codec and configuration.
72
+ * Automatically detects and configures hardware acceleration if provided.
73
+ * Applies custom codec options and threading configuration.
88
74
  *
89
- * Uses avcodec_find_decoder() to locate the appropriate codec,
90
- * then initializes and opens the codec context.
91
- *
92
- * @param stream - Stream to decode
75
+ * @param stream - Media stream to decode
93
76
  * @param options - Decoder configuration options
77
+ * @returns Configured decoder instance
94
78
  *
95
- * @returns Promise resolving to configured Decoder
79
+ * @throws {Error} If decoder not found for codec
80
+ * @throws {FFmpegError} If codec initialization fails
96
81
  *
97
- * @throws {Error} If codec unavailable
82
+ * @example
83
+ * ```typescript
84
+ * import { MediaInput, Decoder } from 'node-av/api';
85
+ *
86
+ * await using input = await MediaInput.open('video.mp4');
87
+ * using decoder = await Decoder.create(input.video());
88
+ * ```
98
89
  *
99
90
  * @example
100
91
  * ```typescript
101
- * const media = await MediaInput.open('video.mp4');
102
- * const stream = media.video();
103
- * const decoder = await Decoder.create(stream);
92
+ * using decoder = await Decoder.create(stream, {
93
+ * threads: 4,
94
+ * options: {
95
+ * 'refcounted_frames': '1',
96
+ * 'skip_frame': 'nonkey' // Only decode keyframes
97
+ * }
98
+ * });
99
+ * ```
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * const hw = HardwareContext.auto();
104
+ * using decoder = await Decoder.create(stream, {
105
+ * hardware: hw,
106
+ * threads: 0 // Auto-detect thread count
107
+ * });
104
108
  * ```
109
+ *
110
+ * @see {@link HardwareContext} For GPU acceleration setup
111
+ * @see {@link DecoderOptions} For configuration options
105
112
  */
106
113
  static async create(stream, options = {}) {
107
114
  if (!stream) {
@@ -151,6 +158,15 @@ export class Decoder {
151
158
  }
152
159
  /**
153
160
  * Check if decoder is open.
161
+ *
162
+ * @returns true if decoder is open and ready
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * if (decoder.isDecoderOpen) {
167
+ * const frame = await decoder.decode(packet);
168
+ * }
169
+ * ```
154
170
  */
155
171
  get isDecoderOpen() {
156
172
  return this.isOpen;
@@ -158,28 +174,46 @@ export class Decoder {
158
174
  /**
159
175
  * Get output stream information.
160
176
  *
161
- * Returns the actual decoder output format, which may differ from the input stream.
162
- * For hardware decoders, this returns the hardware pixel format.
177
+ * Returns format information about decoded frames.
178
+ * For hardware decoding, returns the hardware pixel format.
179
+ * Essential for configuring downstream components like encoders or filters.
180
+ *
181
+ * @returns Stream format information
182
+ *
183
+ * @example
184
+ * ```typescript
185
+ * const info = decoder.getOutputStreamInfo();
186
+ * if (info.type === 'video') {
187
+ * console.log(`Video: ${info.width}x${info.height} @ ${info.pixelFormat}`);
188
+ * console.log(`Frame rate: ${info.frameRate.num}/${info.frameRate.den}`);
189
+ * }
190
+ * ```
191
+ *
192
+ * @example
193
+ * ```typescript
194
+ * const info = decoder.getOutputStreamInfo();
195
+ * if (info.type === 'audio') {
196
+ * console.log(`Audio: ${info.sampleRate}Hz ${info.sampleFormat}`);
197
+ * console.log(`Channels: ${info.channelLayout}`);
198
+ * }
199
+ * ```
163
200
  *
164
- * @returns StreamInfo with decoder output properties
201
+ * @see {@link StreamInfo} For format details
202
+ * @see {@link Encoder.create} For matching encoder configuration
165
203
  */
166
204
  getOutputStreamInfo() {
167
205
  if (this.stream.codecpar.codecType === AVMEDIA_TYPE_VIDEO) {
168
- // For hardware decoders, the codecContext.pixelFormat is not set correctly
169
- // We need to use the hardware pixel format directly
170
- const pixelFormat = this.hardware ? this.hardware.getHardwarePixelFormat() : this.codecContext.pixelFormat;
171
206
  return {
172
207
  type: 'video',
173
208
  width: this.codecContext.width,
174
209
  height: this.codecContext.height,
175
- pixelFormat,
210
+ pixelFormat: this.hardware?.devicePixelFormat ?? this.codecContext.pixelFormat,
176
211
  timeBase: this.stream.timeBase,
177
212
  frameRate: this.stream.rFrameRate,
178
213
  sampleAspectRatio: this.codecContext.sampleAspectRatio,
179
214
  };
180
215
  }
181
216
  else {
182
- // For audio
183
217
  return {
184
218
  type: 'audio',
185
219
  sampleRate: this.codecContext.sampleRate,
@@ -190,27 +224,62 @@ export class Decoder {
190
224
  }
191
225
  }
192
226
  /**
193
- * Decode a packet and return a frame if available.
227
+ * Check if decoder uses hardware acceleration.
194
228
  *
195
- * Sends packet to decoder and attempts to receive a frame.
196
- * May return null if decoder needs more data.
229
+ * @returns true if hardware-accelerated
197
230
  *
198
- * Uses avcodec_send_packet() and avcodec_receive_frame() internally.
199
- * The decoder may buffer packets before producing frames.
231
+ * @example
232
+ * ```typescript
233
+ * if (decoder.isHardware()) {
234
+ * console.log('Using GPU acceleration');
235
+ * }
236
+ * ```
237
+ *
238
+ * @see {@link HardwareContext} For hardware setup
239
+ */
240
+ isHardware() {
241
+ return !!this.hardware;
242
+ }
243
+ /**
244
+ * Decode a packet to a frame.
245
+ *
246
+ * Sends a packet to the decoder and attempts to receive a decoded frame.
247
+ * Handles internal buffering - may return null if more packets needed.
248
+ * Automatically manages decoder state and error recovery.
200
249
  *
201
- * @param packet - Packet to decode
250
+ * Direct mapping to avcodec_send_packet() and avcodec_receive_frame().
202
251
  *
203
- * @returns Promise resolving to Frame or null
252
+ * @param packet - Compressed packet to decode
253
+ * @returns Decoded frame or null if more data needed
204
254
  *
205
- * @throws {Error} If decoder is closed or decode fails
255
+ * @throws {Error} If decoder is closed
256
+ * @throws {FFmpegError} If decoding fails
206
257
  *
207
258
  * @example
208
259
  * ```typescript
209
260
  * const frame = await decoder.decode(packet);
210
261
  * if (frame) {
211
- * // Process frame
262
+ * console.log(`Decoded frame with PTS: ${frame.pts}`);
263
+ * frame.free();
212
264
  * }
213
265
  * ```
266
+ *
267
+ * @example
268
+ * ```typescript
269
+ * for await (const packet of input.packets()) {
270
+ * if (packet.streamIndex === decoder.getStreamIndex()) {
271
+ * const frame = await decoder.decode(packet);
272
+ * if (frame) {
273
+ * await processFrame(frame);
274
+ * frame.free();
275
+ * }
276
+ * }
277
+ * packet.free();
278
+ * }
279
+ * ```
280
+ *
281
+ * @see {@link frames} For automatic packet iteration
282
+ * @see {@link flush} For end-of-stream handling
214
283
  */
215
284
  async decode(packet) {
216
285
  if (!this.isOpen) {
@@ -234,26 +303,31 @@ export class Decoder {
234
303
  return frame;
235
304
  }
236
305
  /**
237
- * Flush decoder and get remaining frames.
306
+ * Flush decoder and get buffered frame.
238
307
  *
239
- * Sends null packet to trigger flush mode.
240
- * Call repeatedly until it returns null.
308
+ * Signals end-of-stream and retrieves remaining frames.
309
+ * Call repeatedly until null to get all buffered frames.
310
+ * Essential for ensuring all frames are decoded.
241
311
  *
242
- * Uses avcodec_send_packet(NULL) to signal end of stream.
243
- * Retrieves buffered frames from the decoder.
312
+ * Direct mapping to avcodec_send_packet(NULL).
244
313
  *
245
- * @returns Promise resolving to Frame or null
314
+ * @returns Buffered frame or null if none remaining
246
315
  *
247
316
  * @throws {Error} If decoder is closed
248
317
  *
249
318
  * @example
250
319
  * ```typescript
251
- * // Flush all remaining frames
320
+ * // After all packets processed
252
321
  * let frame;
253
322
  * while ((frame = await decoder.flush()) !== null) {
254
- * // Process final frames
323
+ * console.log('Got buffered frame');
324
+ * await processFrame(frame);
325
+ * frame.free();
255
326
  * }
256
327
  * ```
328
+ *
329
+ * @see {@link flushFrames} For async iteration
330
+ * @see {@link frames} For complete decoding pipeline
257
331
  */
258
332
  async flush() {
259
333
  if (!this.isOpen) {
@@ -266,26 +340,27 @@ export class Decoder {
266
340
  return frame;
267
341
  }
268
342
  /**
269
- * Flush decoder and yield all remaining frames as a generator.
343
+ * Flush all buffered frames as async generator.
270
344
  *
271
- * More convenient than calling flush() in a loop.
272
- * Automatically sends flush signal and yields all buffered frames.
273
- *
274
- * IMPORTANT: The yielded frames MUST be freed by the caller!
275
- * Use 'using' statement or manually call frame.free() to avoid memory leaks.
276
- *
277
- * @returns Async generator of remaining frames
345
+ * Convenient async iteration over remaining frames.
346
+ * Automatically handles repeated flush calls.
347
+ * Useful for end-of-stream processing.
278
348
  *
349
+ * @yields Buffered frames
279
350
  * @throws {Error} If decoder is closed
280
351
  *
281
352
  * @example
282
353
  * ```typescript
283
- * // Process all remaining frames with generator
354
+ * // Flush at end of decoding
284
355
  * for await (const frame of decoder.flushFrames()) {
285
- * // Process final frame
286
- * using _ = frame; // Auto cleanup
356
+ * console.log('Processing buffered frame');
357
+ * await encoder.encode(frame);
358
+ * frame.free();
287
359
  * }
288
360
  * ```
361
+ *
362
+ * @see {@link flush} For single frame flush
363
+ * @see {@link frames} For complete pipeline
289
364
  */
290
365
  async *flushFrames() {
291
366
  if (!this.isOpen) {
@@ -297,36 +372,55 @@ export class Decoder {
297
372
  }
298
373
  }
299
374
  /**
300
- * Async iterator that decodes packets and yields frames.
375
+ * Decode packet stream to frame stream.
301
376
  *
302
- * Filters packets for this decoder's stream and yields decoded frames.
303
- * Automatically handles packet cleanup and decoder flushing.
377
+ * High-level async generator for complete decoding pipeline.
378
+ * Automatically filters packets for this stream, manages memory,
379
+ * and flushes buffered frames at end.
380
+ * Primary interface for stream-based decoding.
304
381
  *
305
- * Processes packets in sequence, decoding each and yielding frames.
306
- * After all packets are processed, flushes the decoder for remaining frames.
307
- *
308
- * IMPORTANT: The yielded frames MUST be freed by the caller!
309
- * Use 'using' statement or manually call frame.free() to avoid memory leaks.
310
- *
311
- * @param packets - Async iterable of packets (e.g., from MediaInput.packets())
312
- *
313
- * @yields Decoded frames (ownership transferred to caller)
382
+ * @param packets - Async iterable of packets
383
+ * @yields Decoded frames
384
+ * @throws {Error} If decoder is closed
385
+ * @throws {FFmpegError} If decoding fails
314
386
  *
315
387
  * @example
316
388
  * ```typescript
317
- * // RECOMMENDED: Use 'using' for automatic cleanup
318
- * for await (using frame of decoder.frames(media.packets())) {
389
+ * await using input = await MediaInput.open('video.mp4');
390
+ * using decoder = await Decoder.create(input.video());
391
+ *
392
+ * for await (const frame of decoder.frames(input.packets())) {
319
393
  * console.log(`Frame: ${frame.width}x${frame.height}`);
320
- * // Frame is automatically freed at end of iteration
394
+ * frame.free();
321
395
  * }
396
+ * ```
322
397
  *
323
- * // OR: Manual cleanup
324
- * for await (const frame of decoder.frames(media.packets())) {
325
- * console.log(`Frame: ${frame.width}x${frame.height}`);
326
- * // Process frame...
327
- * frame.free(); // MUST call free()!
398
+ * @example
399
+ * ```typescript
400
+ * for await (const frame of decoder.frames(input.packets())) {
401
+ * // Process frame
402
+ * await filter.filterFrame(frame);
403
+ *
404
+ * // Frame automatically freed
405
+ * frame.free();
328
406
  * }
329
407
  * ```
408
+ *
409
+ * @example
410
+ * ```typescript
411
+ * import { pipeline } from 'node-av/api';
412
+ *
413
+ * const control = pipeline(
414
+ * input,
415
+ * decoder,
416
+ * encoder,
417
+ * output
418
+ * );
419
+ * await control.completion;
420
+ * ```
421
+ *
422
+ * @see {@link decode} For single packet decoding
423
+ * @see {@link MediaInput.packets} For packet source
330
424
  */
331
425
  async *frames(packets) {
332
426
  if (!this.isOpen) {
@@ -357,42 +451,78 @@ export class Decoder {
357
451
  /**
358
452
  * Close decoder and free resources.
359
453
  *
360
- * After closing, the decoder cannot be used again.
454
+ * Releases codec context and internal frame buffer.
455
+ * Safe to call multiple times.
456
+ * Automatically called by Symbol.dispose.
361
457
  *
362
- * Frees the frame buffer and codec context.
363
- * Note: Does NOT dispose the HardwareContext - caller is responsible for that.
458
+ * @example
459
+ * ```typescript
460
+ * const decoder = await Decoder.create(stream);
461
+ * try {
462
+ * // Use decoder
463
+ * } finally {
464
+ * decoder.close();
465
+ * }
466
+ * ```
467
+ *
468
+ * @see {@link Symbol.dispose} For automatic cleanup
364
469
  */
365
470
  close() {
366
- if (!this.isOpen)
471
+ if (!this.isOpen) {
367
472
  return;
473
+ }
368
474
  this.frame.free();
369
475
  this.codecContext.freeContext();
370
- // NOTE: We do NOT dispose the hardware context here
371
- // The caller who created the HardwareContext is responsible for disposing it
372
- // This allows reusing the same HardwareContext for multiple decoders
373
476
  this.isOpen = false;
374
477
  }
375
478
  /**
376
- * Get the stream index this decoder is for.
479
+ * Get stream index.
480
+ *
481
+ * Returns the index of the stream being decoded.
482
+ * Used for packet filtering in multi-stream files.
483
+ *
484
+ * @returns Stream index
485
+ *
486
+ * @example
487
+ * ```typescript
488
+ * if (packet.streamIndex === decoder.getStreamIndex()) {
489
+ * const frame = await decoder.decode(packet);
490
+ * }
491
+ * ```
492
+ *
493
+ * @see {@link getStream} For full stream object
377
494
  */
378
495
  getStreamIndex() {
379
496
  return this.streamIndex;
380
497
  }
381
498
  /**
382
- * Get the original stream this decoder was created from.
383
- * Used for stream-copy operations in pipeline.
499
+ * Get stream object.
500
+ *
501
+ * Returns the underlying stream being decoded.
502
+ * Provides access to stream metadata and parameters.
503
+ *
504
+ * @returns Stream object
505
+ *
506
+ * @example
507
+ * ```typescript
508
+ * const stream = decoder.getStream();
509
+ * console.log(`Duration: ${stream.duration}`);
510
+ * console.log(`Time base: ${stream.timeBase.num}/${stream.timeBase.den}`);
511
+ * ```
512
+ *
513
+ * @see {@link Stream} For stream properties
514
+ * @see {@link getStreamIndex} For index only
384
515
  */
385
516
  getStream() {
386
517
  return this.stream;
387
518
  }
388
519
  /**
389
- * Get codec context for advanced configuration.
520
+ * Get underlying codec context.
390
521
  *
391
- * Use with caution - direct manipulation may cause issues.
522
+ * Returns the internal codec context for advanced operations.
523
+ * Returns null if decoder is closed.
392
524
  *
393
- * Provides access to the underlying AVCodecContext for advanced operations.
394
- *
395
- * @returns CodecContext or null if closed
525
+ * @returns Codec context or null
396
526
  *
397
527
  * @internal
398
528
  */
@@ -400,15 +530,18 @@ export class Decoder {
400
530
  return this.isOpen ? this.codecContext : null;
401
531
  }
402
532
  /**
403
- * Receive a frame from the decoder (internal).
533
+ * Receive frame from decoder.
404
534
  *
405
- * Internal method to receive decoded frames without conversion.
535
+ * Internal method to get decoded frames from codec.
536
+ * Handles frame cloning and error checking.
537
+ * Hardware frames include hw_frames_ctx reference.
406
538
  *
407
- * Uses avcodec_receive_frame() to get decoded frames from the codec.
408
- * Clones the frame for the user to prevent internal buffer corruption.
539
+ * Direct mapping to avcodec_receive_frame().
540
+ *
541
+ * @returns Cloned frame or null
542
+ *
543
+ * @throws {FFmpegError} If receive fails with error other than AVERROR_EAGAIN or AVERROR_EOF
409
544
  *
410
- * @returns Frame or null if no frame available
411
- * @internal
412
545
  */
413
546
  async receiveFrameInternal() {
414
547
  // Clear previous frame data
@@ -431,10 +564,20 @@ export class Decoder {
431
564
  }
432
565
  }
433
566
  /**
434
- * Symbol.dispose for automatic cleanup.
567
+ * Dispose of decoder.
568
+ *
569
+ * Implements Disposable interface for automatic cleanup.
570
+ * Equivalent to calling close().
571
+ *
572
+ * @example
573
+ * ```typescript
574
+ * {
575
+ * using decoder = await Decoder.create(stream);
576
+ * // Decode frames...
577
+ * } // Automatically closed
578
+ * ```
435
579
  *
436
- * Implements the Disposable interface for automatic resource management.
437
- * Calls close() to free all resources.
580
+ * @see {@link close} For manual cleanup
438
581
  */
439
582
  [Symbol.dispose]() {
440
583
  this.close();
@@ -1 +1 @@
1
- {"version":3,"file":"decoder.js","sourceRoot":"","sources":["../../src/api/decoder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAM1F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,OAAO,OAAO;IACV,YAAY,CAAe;IAC3B,KAAK,CAAQ;IACb,WAAW,CAAS;IACpB,MAAM,CAAS;IACf,M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