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,60 +1,46 @@
1
+ import { AVERROR_EAGAIN, AVERROR_EOF, AVMEDIA_TYPE_VIDEO } from '../constants/constants.js';
2
+ import { Codec, CodecContext, FFmpegError, Frame } from '../lib/index.js';
1
3
  /**
2
- * Decoder - High-level wrapper for media decoding
4
+ * High-level decoder for audio and video streams.
3
5
  *
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
- import { AVERROR_EOF, AVMEDIA_TYPE_VIDEO } from '../constants/constants.js';
13
- import { AVERROR_EAGAIN, Codec, CodecContext, FFmpegError, Frame } from '../lib/index.js';
14
- /**
15
- * High-level decoder for media streams.
16
- *
17
- * Handles codec initialization, packet decoding, and frame output.
18
- * Designed for simple, efficient decoding workflows.
19
- *
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,50 @@ 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
96
80
  *
97
- * @throws {Error} If codec unavailable
81
+ * @throws {FFmpegError} If codec initialization fails
98
82
  *
99
83
  * @example
100
84
  * ```typescript
101
- * const media = await MediaInput.open('video.mp4');
102
- * const stream = media.video();
103
- * const decoder = await Decoder.create(stream);
85
+ * import { MediaInput, Decoder } from 'node-av/api';
86
+ *
87
+ * await using input = await MediaInput.open('video.mp4');
88
+ * using decoder = await Decoder.create(input.video());
89
+ * ```
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * using decoder = await Decoder.create(stream, {
94
+ * threads: 4,
95
+ * options: {
96
+ * 'refcounted_frames': '1',
97
+ * 'skip_frame': 'nonkey' // Only decode keyframes
98
+ * }
99
+ * });
104
100
  * ```
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * const hw = HardwareContext.auto();
105
+ * using decoder = await Decoder.create(stream, {
106
+ * hardware: hw,
107
+ * threads: 0 // Auto-detect thread count
108
+ * });
109
+ * ```
110
+ *
111
+ * @see {@link HardwareContext} For GPU acceleration setup
112
+ * @see {@link DecoderOptions} For configuration options
105
113
  */
106
114
  static async create(stream, options = {}) {
107
115
  if (!stream) {
@@ -151,6 +159,15 @@ export class Decoder {
151
159
  }
152
160
  /**
153
161
  * Check if decoder is open.
162
+ *
163
+ * @returns true if decoder is open and ready
164
+ *
165
+ * @example
166
+ * ```typescript
167
+ * if (decoder.isDecoderOpen) {
168
+ * const frame = await decoder.decode(packet);
169
+ * }
170
+ * ```
154
171
  */
155
172
  get isDecoderOpen() {
156
173
  return this.isOpen;
@@ -158,28 +175,46 @@ export class Decoder {
158
175
  /**
159
176
  * Get output stream information.
160
177
  *
161
- * Returns the actual decoder output format, which may differ from the input stream.
162
- * For hardware decoders, this returns the hardware pixel format.
178
+ * Returns format information about decoded frames.
179
+ * For hardware decoding, returns the hardware pixel format.
180
+ * Essential for configuring downstream components like encoders or filters.
181
+ *
182
+ * @returns Stream format information
183
+ *
184
+ * @example
185
+ * ```typescript
186
+ * const info = decoder.getOutputStreamInfo();
187
+ * if (info.type === 'video') {
188
+ * console.log(`Video: ${info.width}x${info.height} @ ${info.pixelFormat}`);
189
+ * console.log(`Frame rate: ${info.frameRate.num}/${info.frameRate.den}`);
190
+ * }
191
+ * ```
192
+ *
193
+ * @example
194
+ * ```typescript
195
+ * const info = decoder.getOutputStreamInfo();
196
+ * if (info.type === 'audio') {
197
+ * console.log(`Audio: ${info.sampleRate}Hz ${info.sampleFormat}`);
198
+ * console.log(`Channels: ${info.channelLayout}`);
199
+ * }
200
+ * ```
163
201
  *
164
- * @returns StreamInfo with decoder output properties
202
+ * @see {@link StreamInfo} For format details
203
+ * @see {@link Encoder.create} For matching encoder configuration
165
204
  */
166
205
  getOutputStreamInfo() {
167
206
  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
207
  return {
172
208
  type: 'video',
173
209
  width: this.codecContext.width,
174
210
  height: this.codecContext.height,
175
- pixelFormat,
211
+ pixelFormat: this.hardware?.devicePixelFormat ?? this.codecContext.pixelFormat,
176
212
  timeBase: this.stream.timeBase,
177
213
  frameRate: this.stream.rFrameRate,
178
214
  sampleAspectRatio: this.codecContext.sampleAspectRatio,
179
215
  };
180
216
  }
181
217
  else {
182
- // For audio
183
218
  return {
184
219
  type: 'audio',
185
220
  sampleRate: this.codecContext.sampleRate,
@@ -190,27 +225,63 @@ export class Decoder {
190
225
  }
191
226
  }
192
227
  /**
193
- * Decode a packet and return a frame if available.
228
+ * Check if decoder uses hardware acceleration.
229
+ *
230
+ * @returns true if hardware-accelerated
231
+ *
232
+ * @example
233
+ * ```typescript
234
+ * if (decoder.isHardware()) {
235
+ * console.log('Using GPU acceleration');
236
+ * }
237
+ * ```
238
+ *
239
+ * @see {@link HardwareContext} For hardware setup
240
+ */
241
+ isHardware() {
242
+ return !!this.hardware;
243
+ }
244
+ /**
245
+ * Decode a packet to a frame.
194
246
  *
195
- * Sends packet to decoder and attempts to receive a frame.
196
- * May return null if decoder needs more data.
247
+ * Sends a packet to the decoder and attempts to receive a decoded frame.
248
+ * Handles internal buffering - may return null if more packets needed.
249
+ * Automatically manages decoder state and error recovery.
197
250
  *
198
- * Uses avcodec_send_packet() and avcodec_receive_frame() internally.
199
- * The decoder may buffer packets before producing frames.
251
+ * Direct mapping to avcodec_send_packet() and avcodec_receive_frame().
200
252
  *
201
- * @param packet - Packet to decode
253
+ * @param packet - Compressed packet to decode
254
+ * @returns Decoded frame or null if more data needed
202
255
  *
203
- * @returns Promise resolving to Frame or null
256
+ * @throws {Error} If decoder is closed
204
257
  *
205
- * @throws {Error} If decoder is closed or decode fails
258
+ * @throws {FFmpegError} If decoding fails
206
259
  *
207
260
  * @example
208
261
  * ```typescript
209
262
  * const frame = await decoder.decode(packet);
210
263
  * if (frame) {
211
- * // Process frame
264
+ * console.log(`Decoded frame with PTS: ${frame.pts}`);
265
+ * frame.free();
266
+ * }
267
+ * ```
268
+ *
269
+ * @example
270
+ * ```typescript
271
+ * for await (const packet of input.packets()) {
272
+ * if (packet.streamIndex === decoder.getStreamIndex()) {
273
+ * const frame = await decoder.decode(packet);
274
+ * if (frame) {
275
+ * await processFrame(frame);
276
+ * frame.free();
277
+ * }
278
+ * }
279
+ * packet.free();
212
280
  * }
213
281
  * ```
282
+ *
283
+ * @see {@link frames} For automatic packet iteration
284
+ * @see {@link flush} For end-of-stream handling
214
285
  */
215
286
  async decode(packet) {
216
287
  if (!this.isOpen) {
@@ -234,26 +305,31 @@ export class Decoder {
234
305
  return frame;
235
306
  }
236
307
  /**
237
- * Flush decoder and get remaining frames.
308
+ * Flush decoder and get buffered frame.
238
309
  *
239
- * Sends null packet to trigger flush mode.
240
- * Call repeatedly until it returns null.
310
+ * Signals end-of-stream and retrieves remaining frames.
311
+ * Call repeatedly until null to get all buffered frames.
312
+ * Essential for ensuring all frames are decoded.
241
313
  *
242
- * Uses avcodec_send_packet(NULL) to signal end of stream.
243
- * Retrieves buffered frames from the decoder.
314
+ * Direct mapping to avcodec_send_packet(NULL).
244
315
  *
245
- * @returns Promise resolving to Frame or null
316
+ * @returns Buffered frame or null if none remaining
246
317
  *
247
318
  * @throws {Error} If decoder is closed
248
319
  *
249
320
  * @example
250
321
  * ```typescript
251
- * // Flush all remaining frames
322
+ * // After all packets processed
252
323
  * let frame;
253
324
  * while ((frame = await decoder.flush()) !== null) {
254
- * // Process final frames
325
+ * console.log('Got buffered frame');
326
+ * await processFrame(frame);
327
+ * frame.free();
255
328
  * }
256
329
  * ```
330
+ *
331
+ * @see {@link flushFrames} For async iteration
332
+ * @see {@link frames} For complete decoding pipeline
257
333
  */
258
334
  async flush() {
259
335
  if (!this.isOpen) {
@@ -266,26 +342,27 @@ export class Decoder {
266
342
  return frame;
267
343
  }
268
344
  /**
269
- * Flush decoder and yield all remaining frames as a generator.
270
- *
271
- * More convenient than calling flush() in a loop.
272
- * Automatically sends flush signal and yields all buffered frames.
345
+ * Flush all buffered frames as async generator.
273
346
  *
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
347
+ * Convenient async iteration over remaining frames.
348
+ * Automatically handles repeated flush calls.
349
+ * Useful for end-of-stream processing.
278
350
  *
351
+ * @yields Buffered frames
279
352
  * @throws {Error} If decoder is closed
280
353
  *
281
354
  * @example
282
355
  * ```typescript
283
- * // Process all remaining frames with generator
356
+ * // Flush at end of decoding
284
357
  * for await (const frame of decoder.flushFrames()) {
285
- * // Process final frame
286
- * using _ = frame; // Auto cleanup
358
+ * console.log('Processing buffered frame');
359
+ * await encoder.encode(frame);
360
+ * frame.free();
287
361
  * }
288
362
  * ```
363
+ *
364
+ * @see {@link flush} For single frame flush
365
+ * @see {@link frames} For complete pipeline
289
366
  */
290
367
  async *flushFrames() {
291
368
  if (!this.isOpen) {
@@ -297,36 +374,56 @@ export class Decoder {
297
374
  }
298
375
  }
299
376
  /**
300
- * Async iterator that decodes packets and yields frames.
301
- *
302
- * Filters packets for this decoder's stream and yields decoded frames.
303
- * Automatically handles packet cleanup and decoder flushing.
304
- *
305
- * Processes packets in sequence, decoding each and yielding frames.
306
- * After all packets are processed, flushes the decoder for remaining frames.
377
+ * Decode packet stream to frame stream.
307
378
  *
308
- * IMPORTANT: The yielded frames MUST be freed by the caller!
309
- * Use 'using' statement or manually call frame.free() to avoid memory leaks.
379
+ * High-level async generator for complete decoding pipeline.
380
+ * Automatically filters packets for this stream, manages memory,
381
+ * and flushes buffered frames at end.
382
+ * Primary interface for stream-based decoding.
310
383
  *
311
- * @param packets - Async iterable of packets (e.g., from MediaInput.packets())
384
+ * @param packets - Async iterable of packets
385
+ * @yields Decoded frames
386
+ * @throws {Error} If decoder is closed
312
387
  *
313
- * @yields Decoded frames (ownership transferred to caller)
388
+ * @throws {FFmpegError} If decoding fails
314
389
  *
315
390
  * @example
316
391
  * ```typescript
317
- * // RECOMMENDED: Use 'using' for automatic cleanup
318
- * for await (using frame of decoder.frames(media.packets())) {
392
+ * await using input = await MediaInput.open('video.mp4');
393
+ * using decoder = await Decoder.create(input.video());
394
+ *
395
+ * for await (const frame of decoder.frames(input.packets())) {
319
396
  * console.log(`Frame: ${frame.width}x${frame.height}`);
320
- * // Frame is automatically freed at end of iteration
397
+ * frame.free();
321
398
  * }
399
+ * ```
322
400
  *
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()!
401
+ * @example
402
+ * ```typescript
403
+ * for await (const frame of decoder.frames(input.packets())) {
404
+ * // Process frame
405
+ * await filter.filterFrame(frame);
406
+ *
407
+ * // Frame automatically freed
408
+ * frame.free();
328
409
  * }
329
410
  * ```
411
+ *
412
+ * @example
413
+ * ```typescript
414
+ * import { pipeline } from 'node-av/api';
415
+ *
416
+ * const control = pipeline(
417
+ * input,
418
+ * decoder,
419
+ * encoder,
420
+ * output
421
+ * );
422
+ * await control.completion;
423
+ * ```
424
+ *
425
+ * @see {@link decode} For single packet decoding
426
+ * @see {@link MediaInput.packets} For packet source
330
427
  */
331
428
  async *frames(packets) {
332
429
  if (!this.isOpen) {
@@ -357,42 +454,78 @@ export class Decoder {
357
454
  /**
358
455
  * Close decoder and free resources.
359
456
  *
360
- * After closing, the decoder cannot be used again.
457
+ * Releases codec context and internal frame buffer.
458
+ * Safe to call multiple times.
459
+ * Automatically called by Symbol.dispose.
460
+ *
461
+ * @example
462
+ * ```typescript
463
+ * const decoder = await Decoder.create(stream);
464
+ * try {
465
+ * // Use decoder
466
+ * } finally {
467
+ * decoder.close();
468
+ * }
469
+ * ```
361
470
  *
362
- * Frees the frame buffer and codec context.
363
- * Note: Does NOT dispose the HardwareContext - caller is responsible for that.
471
+ * @see {@link Symbol.dispose} For automatic cleanup
364
472
  */
365
473
  close() {
366
- if (!this.isOpen)
474
+ if (!this.isOpen) {
367
475
  return;
476
+ }
368
477
  this.frame.free();
369
478
  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
479
  this.isOpen = false;
374
480
  }
375
481
  /**
376
- * Get the stream index this decoder is for.
482
+ * Get stream index.
483
+ *
484
+ * Returns the index of the stream being decoded.
485
+ * Used for packet filtering in multi-stream files.
486
+ *
487
+ * @returns Stream index
488
+ *
489
+ * @example
490
+ * ```typescript
491
+ * if (packet.streamIndex === decoder.getStreamIndex()) {
492
+ * const frame = await decoder.decode(packet);
493
+ * }
494
+ * ```
495
+ *
496
+ * @see {@link getStream} For full stream object
377
497
  */
378
498
  getStreamIndex() {
379
499
  return this.streamIndex;
380
500
  }
381
501
  /**
382
- * Get the original stream this decoder was created from.
383
- * Used for stream-copy operations in pipeline.
502
+ * Get stream object.
503
+ *
504
+ * Returns the underlying stream being decoded.
505
+ * Provides access to stream metadata and parameters.
506
+ *
507
+ * @returns Stream object
508
+ *
509
+ * @example
510
+ * ```typescript
511
+ * const stream = decoder.getStream();
512
+ * console.log(`Duration: ${stream.duration}`);
513
+ * console.log(`Time base: ${stream.timeBase.num}/${stream.timeBase.den}`);
514
+ * ```
515
+ *
516
+ * @see {@link Stream} For stream properties
517
+ * @see {@link getStreamIndex} For index only
384
518
  */
385
519
  getStream() {
386
520
  return this.stream;
387
521
  }
388
522
  /**
389
- * Get codec context for advanced configuration.
390
- *
391
- * Use with caution - direct manipulation may cause issues.
523
+ * Get underlying codec context.
392
524
  *
393
- * Provides access to the underlying AVCodecContext for advanced operations.
525
+ * Returns the internal codec context for advanced operations.
526
+ * Returns null if decoder is closed.
394
527
  *
395
- * @returns CodecContext or null if closed
528
+ * @returns Codec context or null
396
529
  *
397
530
  * @internal
398
531
  */
@@ -400,15 +533,20 @@ export class Decoder {
400
533
  return this.isOpen ? this.codecContext : null;
401
534
  }
402
535
  /**
403
- * Receive a frame from the decoder (internal).
536
+ * Receive frame from decoder.
537
+ *
538
+ * Internal method to get decoded frames from codec.
539
+ * Handles frame cloning and error checking.
540
+ * Hardware frames include hw_frames_ctx reference.
404
541
  *
405
- * Internal method to receive decoded frames without conversion.
542
+ * Direct mapping to avcodec_receive_frame().
406
543
  *
407
- * Uses avcodec_receive_frame() to get decoded frames from the codec.
408
- * Clones the frame for the user to prevent internal buffer corruption.
544
+ * @returns Cloned frame or null
545
+ *
546
+ * @throws {FFmpegError} If receive fails with error other than AVERROR_EAGAIN or AVERROR_EOF
409
547
  *
410
- * @returns Frame or null if no frame available
411
548
  * @internal
549
+ *
412
550
  */
413
551
  async receiveFrameInternal() {
414
552
  // Clear previous frame data
@@ -431,10 +569,20 @@ export class Decoder {
431
569
  }
432
570
  }
433
571
  /**
434
- * Symbol.dispose for automatic cleanup.
572
+ * Dispose of decoder.
573
+ *
574
+ * Implements Disposable interface for automatic cleanup.
575
+ * Equivalent to calling close().
576
+ *
577
+ * @example
578
+ * ```typescript
579
+ * {
580
+ * using decoder = await Decoder.create(stream);
581
+ * // Decode frames...
582
+ * } // Automatically closed
583
+ * ```
435
584
  *
436
- * Implements the Disposable interface for automatic resource management.
437
- * Calls close() to free all resources.
585
+ * @see {@link close} For manual cleanup
438
586
  */
439
587
  [Symbol.dispose]() {
440
588
  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,MAAM,GAAG,IAAI,CAAC;IACd,QAAQ,CAA0B,CAAC,gEAAgE;IAE3G;;;;;;;;O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