node-av 2.0.0 → 2.4.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 (124) hide show
  1. package/README.md +18 -5
  2. package/binding.gyp +12 -0
  3. package/dist/api/bitstream-filter.d.ts +132 -0
  4. package/dist/api/bitstream-filter.js +198 -0
  5. package/dist/api/bitstream-filter.js.map +1 -1
  6. package/dist/api/decoder.d.ts +194 -0
  7. package/dist/api/decoder.js +313 -0
  8. package/dist/api/decoder.js.map +1 -1
  9. package/dist/api/encoder.d.ts +263 -0
  10. package/dist/api/encoder.js +427 -0
  11. package/dist/api/encoder.js.map +1 -1
  12. package/dist/api/filter-presets.d.ts +92 -0
  13. package/dist/api/filter-presets.js +92 -0
  14. package/dist/api/filter-presets.js.map +1 -1
  15. package/dist/api/filter.d.ts +234 -9
  16. package/dist/api/filter.js +372 -9
  17. package/dist/api/filter.js.map +1 -1
  18. package/dist/api/hardware.d.ts +17 -0
  19. package/dist/api/hardware.js +28 -17
  20. package/dist/api/hardware.js.map +1 -1
  21. package/dist/api/io-stream.d.ts +6 -0
  22. package/dist/api/io-stream.js +2 -0
  23. package/dist/api/io-stream.js.map +1 -1
  24. package/dist/api/media-input.d.ts +214 -1
  25. package/dist/api/media-input.js +341 -0
  26. package/dist/api/media-input.js.map +1 -1
  27. package/dist/api/media-output.d.ts +132 -1
  28. package/dist/api/media-output.js +339 -0
  29. package/dist/api/media-output.js.map +1 -1
  30. package/dist/api/pipeline.d.ts +73 -8
  31. package/dist/api/pipeline.js +61 -0
  32. package/dist/api/pipeline.js.map +1 -1
  33. package/dist/api/types.d.ts +7 -0
  34. package/dist/api/utils.js +2 -0
  35. package/dist/api/utils.js.map +1 -1
  36. package/dist/lib/audio-fifo.d.ts +103 -0
  37. package/dist/lib/audio-fifo.js +109 -0
  38. package/dist/lib/audio-fifo.js.map +1 -1
  39. package/dist/lib/binding.d.ts +1 -0
  40. package/dist/lib/binding.js +32 -7
  41. package/dist/lib/binding.js.map +1 -1
  42. package/dist/lib/bitstream-filter-context.d.ts +79 -0
  43. package/dist/lib/bitstream-filter-context.js +83 -0
  44. package/dist/lib/bitstream-filter-context.js.map +1 -1
  45. package/dist/lib/bitstream-filter.d.ts +2 -0
  46. package/dist/lib/bitstream-filter.js +2 -0
  47. package/dist/lib/bitstream-filter.js.map +1 -1
  48. package/dist/lib/codec-context.d.ts +168 -0
  49. package/dist/lib/codec-context.js +178 -0
  50. package/dist/lib/codec-context.js.map +1 -1
  51. package/dist/lib/codec-parameters.d.ts +3 -0
  52. package/dist/lib/codec-parameters.js +3 -0
  53. package/dist/lib/codec-parameters.js.map +1 -1
  54. package/dist/lib/codec-parser.d.ts +6 -0
  55. package/dist/lib/codec-parser.js +6 -0
  56. package/dist/lib/codec-parser.js.map +1 -1
  57. package/dist/lib/codec.d.ts +12 -0
  58. package/dist/lib/codec.js +12 -0
  59. package/dist/lib/codec.js.map +1 -1
  60. package/dist/lib/dictionary.d.ts +16 -0
  61. package/dist/lib/dictionary.js +16 -0
  62. package/dist/lib/dictionary.js.map +1 -1
  63. package/dist/lib/error.d.ts +8 -0
  64. package/dist/lib/error.js +9 -0
  65. package/dist/lib/error.js.map +1 -1
  66. package/dist/lib/filter-context.d.ts +100 -0
  67. package/dist/lib/filter-context.js +104 -0
  68. package/dist/lib/filter-context.js.map +1 -1
  69. package/dist/lib/filter-graph.d.ts +80 -0
  70. package/dist/lib/filter-graph.js +84 -0
  71. package/dist/lib/filter-graph.js.map +1 -1
  72. package/dist/lib/filter-inout.d.ts +1 -0
  73. package/dist/lib/filter-inout.js +1 -0
  74. package/dist/lib/filter-inout.js.map +1 -1
  75. package/dist/lib/filter.d.ts +2 -0
  76. package/dist/lib/filter.js +2 -0
  77. package/dist/lib/filter.js.map +1 -1
  78. package/dist/lib/format-context.d.ts +338 -2
  79. package/dist/lib/format-context.js +355 -3
  80. package/dist/lib/format-context.js.map +1 -1
  81. package/dist/lib/frame.d.ts +41 -0
  82. package/dist/lib/frame.js +43 -0
  83. package/dist/lib/frame.js.map +1 -1
  84. package/dist/lib/hardware-device-context.d.ts +8 -0
  85. package/dist/lib/hardware-device-context.js +8 -0
  86. package/dist/lib/hardware-device-context.js.map +1 -1
  87. package/dist/lib/hardware-frames-context.d.ts +55 -0
  88. package/dist/lib/hardware-frames-context.js +57 -0
  89. package/dist/lib/hardware-frames-context.js.map +1 -1
  90. package/dist/lib/input-format.d.ts +43 -3
  91. package/dist/lib/input-format.js +48 -0
  92. package/dist/lib/input-format.js.map +1 -1
  93. package/dist/lib/io-context.d.ts +218 -0
  94. package/dist/lib/io-context.js +234 -0
  95. package/dist/lib/io-context.js.map +1 -1
  96. package/dist/lib/log.d.ts +2 -0
  97. package/dist/lib/log.js +2 -0
  98. package/dist/lib/log.js.map +1 -1
  99. package/dist/lib/native-types.d.ts +39 -1
  100. package/dist/lib/option.d.ts +90 -0
  101. package/dist/lib/option.js +97 -0
  102. package/dist/lib/option.js.map +1 -1
  103. package/dist/lib/output-format.d.ts +4 -0
  104. package/dist/lib/output-format.js +4 -0
  105. package/dist/lib/output-format.js.map +1 -1
  106. package/dist/lib/packet.d.ts +7 -0
  107. package/dist/lib/packet.js +7 -0
  108. package/dist/lib/packet.js.map +1 -1
  109. package/dist/lib/rational.d.ts +1 -0
  110. package/dist/lib/rational.js +1 -0
  111. package/dist/lib/rational.js.map +1 -1
  112. package/dist/lib/software-resample-context.d.ts +64 -0
  113. package/dist/lib/software-resample-context.js +66 -0
  114. package/dist/lib/software-resample-context.js.map +1 -1
  115. package/dist/lib/software-scale-context.d.ts +98 -0
  116. package/dist/lib/software-scale-context.js +102 -0
  117. package/dist/lib/software-scale-context.js.map +1 -1
  118. package/dist/lib/stream.d.ts +1 -0
  119. package/dist/lib/stream.js +1 -0
  120. package/dist/lib/stream.js.map +1 -1
  121. package/dist/lib/utilities.d.ts +60 -0
  122. package/dist/lib/utilities.js +60 -0
  123. package/dist/lib/utilities.js.map +1 -1
  124. package/package.json +19 -17
@@ -53,8 +53,11 @@ export declare class Decoder implements Disposable {
53
53
  private hardware?;
54
54
  /**
55
55
  * @param codecContext - Configured codec context
56
+ *
56
57
  * @param codec - Codec being used
58
+ *
57
59
  * @param stream - Media stream being decoded
60
+ *
58
61
  * @param hardware - Optional hardware context
59
62
  * Use {@link create} factory method
60
63
  *
@@ -69,7 +72,9 @@ export declare class Decoder implements Disposable {
69
72
  * Applies custom codec options and threading configuration.
70
73
  *
71
74
  * @param stream - Media stream to decode
75
+ *
72
76
  * @param options - Decoder configuration options
77
+ *
73
78
  * @returns Configured decoder instance
74
79
  *
75
80
  * @throws {Error} If decoder not found for codec
@@ -108,6 +113,55 @@ export declare class Decoder implements Disposable {
108
113
  * @see {@link DecoderOptions} For configuration options
109
114
  */
110
115
  static create(stream: Stream, options?: DecoderOptions): Promise<Decoder>;
116
+ /**
117
+ * Create a decoder for a media stream synchronously.
118
+ * Synchronous version of create.
119
+ *
120
+ * Initializes a decoder with the appropriate codec and configuration.
121
+ * Automatically detects and configures hardware acceleration if provided.
122
+ * Applies custom codec options and threading configuration.
123
+ *
124
+ * @param stream - Media stream to decode
125
+ *
126
+ * @param options - Decoder configuration options
127
+ *
128
+ * @returns Configured decoder instance
129
+ *
130
+ * @throws {Error} If decoder not found for codec
131
+ *
132
+ * @throws {FFmpegError} If codec initialization fails
133
+ *
134
+ * @example
135
+ * ```typescript
136
+ * import { MediaInput, Decoder } from 'node-av/api';
137
+ *
138
+ * await using input = await MediaInput.open('video.mp4');
139
+ * using decoder = await Decoder.create(input.video());
140
+ * ```
141
+ *
142
+ * @example
143
+ * ```typescript
144
+ * using decoder = await Decoder.create(stream, {
145
+ * threads: 4,
146
+ * options: {
147
+ * 'refcounted_frames': '1',
148
+ * 'skip_frame': 'nonkey' // Only decode keyframes
149
+ * }
150
+ * });
151
+ * ```
152
+ *
153
+ * @example
154
+ * ```typescript
155
+ * const hw = HardwareContext.auto();
156
+ * using decoder = await Decoder.create(stream, {
157
+ * hardware: hw,
158
+ * threads: 0 // Auto-detect thread count
159
+ * });
160
+ * ```
161
+ *
162
+ * @see {@link create} For async version
163
+ */
164
+ static createSync(stream: Stream, options?: DecoderOptions): Decoder;
111
165
  /**
112
166
  * Check if decoder is open.
113
167
  *
@@ -175,6 +229,7 @@ export declare class Decoder implements Disposable {
175
229
  * Direct mapping to avcodec_send_packet() and avcodec_receive_frame().
176
230
  *
177
231
  * @param packet - Compressed packet to decode
232
+ *
178
233
  * @returns Decoded frame or null if more data needed
179
234
  *
180
235
  * @throws {Error} If decoder is closed
@@ -208,6 +263,33 @@ export declare class Decoder implements Disposable {
208
263
  * @see {@link flush} For end-of-stream handling
209
264
  */
210
265
  decode(packet: Packet): Promise<Frame | null>;
266
+ /**
267
+ * Decode a packet to frame synchronously.
268
+ * Synchronous version of decode.
269
+ *
270
+ * Send packet to decoder and attempt to receive frame.
271
+ * Handles decoder buffering and error conditions.
272
+ * May return null if decoder needs more data.
273
+ *
274
+ * @param packet - Compressed packet to decode
275
+ *
276
+ * @returns Decoded frame or null
277
+ *
278
+ * @throws {Error} If decoder is closed
279
+ *
280
+ * @throws {FFmpegError} If decoding fails
281
+ *
282
+ * @example
283
+ * ```typescript
284
+ * const frame = decoder.decodeSync(packet);
285
+ * if (frame) {
286
+ * console.log(`Decoded: ${frame.width}x${frame.height}`);
287
+ * }
288
+ * ```
289
+ *
290
+ * @see {@link decode} For async version
291
+ */
292
+ decodeSync(packet: Packet): Frame | null;
211
293
  /**
212
294
  * Decode packet stream to frame stream.
213
295
  *
@@ -217,7 +299,9 @@ export declare class Decoder implements Disposable {
217
299
  * Primary interface for stream-based decoding.
218
300
  *
219
301
  * @param packets - Async iterable of packets
302
+ *
220
303
  * @yields {Frame} Decoded frames
304
+ *
221
305
  * @throws {Error} If decoder is closed
222
306
  *
223
307
  * @throws {FFmpegError} If decoding fails
@@ -261,6 +345,33 @@ export declare class Decoder implements Disposable {
261
345
  * @see {@link MediaInput.packets} For packet source
262
346
  */
263
347
  frames(packets: AsyncIterable<Packet>): AsyncGenerator<Frame>;
348
+ /**
349
+ * Decode packet stream to frame stream synchronously.
350
+ * Synchronous version of frames.
351
+ *
352
+ * High-level sync generator for complete decoding pipeline.
353
+ * Automatically filters packets for this stream, manages memory,
354
+ * and flushes buffered frames at end.
355
+ *
356
+ * @param packets - Iterable of packets
357
+ *
358
+ * @yields {Frame} Decoded frames
359
+ *
360
+ * @throws {Error} If decoder is closed
361
+ *
362
+ * @throws {FFmpegError} If decoding fails
363
+ *
364
+ * @example
365
+ * ```typescript
366
+ * for (const frame of decoder.framesSync(packets)) {
367
+ * console.log(`Frame: ${frame.width}x${frame.height}`);
368
+ * // Process frame...
369
+ * }
370
+ * ```
371
+ *
372
+ * @see {@link frames} For async version
373
+ */
374
+ framesSync(packets: Iterable<Packet>): Generator<Frame>;
264
375
  /**
265
376
  * Flush decoder and signal end-of-stream.
266
377
  *
@@ -289,6 +400,29 @@ export declare class Decoder implements Disposable {
289
400
  * @see {@link receive} For getting buffered frames
290
401
  */
291
402
  flush(): Promise<void>;
403
+ /**
404
+ * Flush decoder and signal end-of-stream synchronously.
405
+ * Synchronous version of flush.
406
+ *
407
+ * Send null packet to signal end of input stream.
408
+ * Decoder may still have buffered frames.
409
+ * Call receiveSync() repeatedly to get remaining frames.
410
+ *
411
+ * @throws {FFmpegError} If flush fails
412
+ *
413
+ * @example
414
+ * ```typescript
415
+ * decoder.flushSync();
416
+ * // Get remaining frames
417
+ * let frame;
418
+ * while ((frame = decoder.receiveSync()) !== null) {
419
+ * console.log('Buffered frame');
420
+ * }
421
+ * ```
422
+ *
423
+ * @see {@link flush} For async version
424
+ */
425
+ flushSync(): void;
292
426
  /**
293
427
  * Flush all buffered frames as async generator.
294
428
  *
@@ -312,6 +446,29 @@ export declare class Decoder implements Disposable {
312
446
  * @see {@link frames} For complete pipeline
313
447
  */
314
448
  flushFrames(): AsyncGenerator<Frame>;
449
+ /**
450
+ * Flush all buffered frames as generator synchronously.
451
+ * Synchronous version of flushFrames.
452
+ *
453
+ * Convenient sync iteration over remaining frames.
454
+ * Automatically sends flush signal and retrieves buffered frames.
455
+ * Useful for end-of-stream processing.
456
+ *
457
+ * @yields {Frame} Buffered frames
458
+ *
459
+ * @example
460
+ * ```typescript
461
+ * // Flush at end of decoding
462
+ * for (const frame of decoder.flushFramesSync()) {
463
+ * console.log('Processing buffered frame');
464
+ * encoder.encodeSync(frame);
465
+ * frame.free();
466
+ * }
467
+ * ```
468
+ *
469
+ * @see {@link flushFrames} For async version
470
+ */
471
+ flushFramesSync(): Generator<Frame>;
315
472
  /**
316
473
  * Receive frame from decoder.
317
474
  *
@@ -349,6 +506,43 @@ export declare class Decoder implements Disposable {
349
506
  * @see {@link flush} For signaling end-of-stream
350
507
  */
351
508
  receive(): Promise<Frame | null>;
509
+ /**
510
+ * Receive frame from decoder synchronously.
511
+ * Synchronous version of receive.
512
+ *
513
+ * Gets decoded frames from the codec's internal buffer.
514
+ * Handles frame cloning and error checking.
515
+ * Hardware frames include hw_frames_ctx reference.
516
+ * Call repeatedly until null to drain all buffered frames.
517
+ *
518
+ * Direct mapping to avcodec_receive_frame().
519
+ *
520
+ * @returns Cloned frame or null if no frames available
521
+ *
522
+ * @throws {FFmpegError} If receive fails with error other than AVERROR_EAGAIN or AVERROR_EOF
523
+ *
524
+ * @example
525
+ * ```typescript
526
+ * const frame = decoder.receiveSync();
527
+ * if (frame) {
528
+ * console.log('Got decoded frame');
529
+ * frame.free();
530
+ * }
531
+ * ```
532
+ *
533
+ * @example
534
+ * ```typescript
535
+ * // Drain all buffered frames
536
+ * let frame;
537
+ * while ((frame = decoder.receiveSync()) !== null) {
538
+ * console.log(`Frame PTS: ${frame.pts}`);
539
+ * frame.free();
540
+ * }
541
+ * ```
542
+ *
543
+ * @see {@link receive} For async version
544
+ */
545
+ receiveSync(): Frame | null;
352
546
  /**
353
547
  * Close decoder and free resources.
354
548
  *
@@ -52,8 +52,11 @@ export class Decoder {
52
52
  hardware;
53
53
  /**
54
54
  * @param codecContext - Configured codec context
55
+ *
55
56
  * @param codec - Codec being used
57
+ *
56
58
  * @param stream - Media stream being decoded
59
+ *
57
60
  * @param hardware - Optional hardware context
58
61
  * Use {@link create} factory method
59
62
  *
@@ -75,7 +78,9 @@ export class Decoder {
75
78
  * Applies custom codec options and threading configuration.
76
79
  *
77
80
  * @param stream - Media stream to decode
81
+ *
78
82
  * @param options - Decoder configuration options
83
+ *
79
84
  * @returns Configured decoder instance
80
85
  *
81
86
  * @throws {Error} If decoder not found for codec
@@ -153,6 +158,94 @@ export class Decoder {
153
158
  }
154
159
  return new Decoder(codecContext, codec, stream, isHWDecoder ? options.hardware : undefined);
155
160
  }
161
+ /**
162
+ * Create a decoder for a media stream synchronously.
163
+ * Synchronous version of create.
164
+ *
165
+ * Initializes a decoder with the appropriate codec and configuration.
166
+ * Automatically detects and configures hardware acceleration if provided.
167
+ * Applies custom codec options and threading configuration.
168
+ *
169
+ * @param stream - Media stream to decode
170
+ *
171
+ * @param options - Decoder configuration options
172
+ *
173
+ * @returns Configured decoder instance
174
+ *
175
+ * @throws {Error} If decoder not found for codec
176
+ *
177
+ * @throws {FFmpegError} If codec initialization fails
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * import { MediaInput, Decoder } from 'node-av/api';
182
+ *
183
+ * await using input = await MediaInput.open('video.mp4');
184
+ * using decoder = await Decoder.create(input.video());
185
+ * ```
186
+ *
187
+ * @example
188
+ * ```typescript
189
+ * using decoder = await Decoder.create(stream, {
190
+ * threads: 4,
191
+ * options: {
192
+ * 'refcounted_frames': '1',
193
+ * 'skip_frame': 'nonkey' // Only decode keyframes
194
+ * }
195
+ * });
196
+ * ```
197
+ *
198
+ * @example
199
+ * ```typescript
200
+ * const hw = HardwareContext.auto();
201
+ * using decoder = await Decoder.create(stream, {
202
+ * hardware: hw,
203
+ * threads: 0 // Auto-detect thread count
204
+ * });
205
+ * ```
206
+ *
207
+ * @see {@link create} For async version
208
+ */
209
+ static createSync(stream, options = {}) {
210
+ if (!stream) {
211
+ throw new Error('Stream is required');
212
+ }
213
+ // Find decoder for this codec
214
+ const codec = Codec.findDecoder(stream.codecpar.codecId);
215
+ if (!codec) {
216
+ throw new Error(`Decoder not found for codec ${stream.codecpar.codecId}`);
217
+ }
218
+ // Allocate and configure codec context
219
+ const codecContext = new CodecContext();
220
+ codecContext.allocContext3(codec);
221
+ // Copy codec parameters to context
222
+ const ret = codecContext.parametersToContext(stream.codecpar);
223
+ if (ret < 0) {
224
+ codecContext.freeContext();
225
+ FFmpegError.throwIfError(ret, 'Failed to copy codec parameters');
226
+ }
227
+ // Set packet time base
228
+ codecContext.pktTimebase = stream.timeBase;
229
+ // Apply options
230
+ if (options.threads !== undefined) {
231
+ codecContext.threadCount = options.threads;
232
+ }
233
+ // Check if this decoder supports hardware acceleration
234
+ // Only apply hardware acceleration if the decoder supports it
235
+ // Silently ignore hardware for software decoders
236
+ const isHWDecoder = codec.isHardwareAcceleratedDecoder();
237
+ if (isHWDecoder && options.hardware) {
238
+ codecContext.hwDeviceCtx = options.hardware.deviceContext;
239
+ }
240
+ const opts = options.options ? Dictionary.fromObject(options.options) : undefined;
241
+ // Open codec synchronously
242
+ const openRet = codecContext.open2Sync(codec, opts);
243
+ if (openRet < 0) {
244
+ codecContext.freeContext();
245
+ FFmpegError.throwIfError(openRet, 'Failed to open codec');
246
+ }
247
+ return new Decoder(codecContext, codec, stream, isHWDecoder ? options.hardware : undefined);
248
+ }
156
249
  /**
157
250
  * Check if decoder is open.
158
251
  *
@@ -228,6 +321,7 @@ export class Decoder {
228
321
  * Direct mapping to avcodec_send_packet() and avcodec_receive_frame().
229
322
  *
230
323
  * @param packet - Compressed packet to decode
324
+ *
231
325
  * @returns Decoded frame or null if more data needed
232
326
  *
233
327
  * @throws {Error} If decoder is closed
@@ -281,6 +375,53 @@ export class Decoder {
281
375
  const frame = await this.receive();
282
376
  return frame;
283
377
  }
378
+ /**
379
+ * Decode a packet to frame synchronously.
380
+ * Synchronous version of decode.
381
+ *
382
+ * Send packet to decoder and attempt to receive frame.
383
+ * Handles decoder buffering and error conditions.
384
+ * May return null if decoder needs more data.
385
+ *
386
+ * @param packet - Compressed packet to decode
387
+ *
388
+ * @returns Decoded frame or null
389
+ *
390
+ * @throws {Error} If decoder is closed
391
+ *
392
+ * @throws {FFmpegError} If decoding fails
393
+ *
394
+ * @example
395
+ * ```typescript
396
+ * const frame = decoder.decodeSync(packet);
397
+ * if (frame) {
398
+ * console.log(`Decoded: ${frame.width}x${frame.height}`);
399
+ * }
400
+ * ```
401
+ *
402
+ * @see {@link decode} For async version
403
+ */
404
+ decodeSync(packet) {
405
+ if (this.isClosed) {
406
+ throw new Error('Decoder is closed');
407
+ }
408
+ // Send packet to decoder
409
+ const sendRet = this.codecContext.sendPacketSync(packet);
410
+ if (sendRet < 0 && sendRet !== AVERROR_EOF) {
411
+ // Decoder might be full, try to receive first
412
+ const frame = this.receiveSync();
413
+ if (frame) {
414
+ return frame;
415
+ }
416
+ // If still failing, it's an error
417
+ if (sendRet !== AVERROR_EAGAIN) {
418
+ FFmpegError.throwIfError(sendRet, 'Failed to send packet');
419
+ }
420
+ }
421
+ // Try to receive frame
422
+ const frame = this.receiveSync();
423
+ return frame;
424
+ }
284
425
  /**
285
426
  * Decode packet stream to frame stream.
286
427
  *
@@ -290,7 +431,9 @@ export class Decoder {
290
431
  * Primary interface for stream-based decoding.
291
432
  *
292
433
  * @param packets - Async iterable of packets
434
+ *
293
435
  * @yields {Frame} Decoded frames
436
+ *
294
437
  * @throws {Error} If decoder is closed
295
438
  *
296
439
  * @throws {FFmpegError} If decoding fails
@@ -359,6 +502,58 @@ export class Decoder {
359
502
  yield remaining;
360
503
  }
361
504
  }
505
+ /**
506
+ * Decode packet stream to frame stream synchronously.
507
+ * Synchronous version of frames.
508
+ *
509
+ * High-level sync generator for complete decoding pipeline.
510
+ * Automatically filters packets for this stream, manages memory,
511
+ * and flushes buffered frames at end.
512
+ *
513
+ * @param packets - Iterable of packets
514
+ *
515
+ * @yields {Frame} Decoded frames
516
+ *
517
+ * @throws {Error} If decoder is closed
518
+ *
519
+ * @throws {FFmpegError} If decoding fails
520
+ *
521
+ * @example
522
+ * ```typescript
523
+ * for (const frame of decoder.framesSync(packets)) {
524
+ * console.log(`Frame: ${frame.width}x${frame.height}`);
525
+ * // Process frame...
526
+ * }
527
+ * ```
528
+ *
529
+ * @see {@link frames} For async version
530
+ */
531
+ *framesSync(packets) {
532
+ // Process packets
533
+ for (const packet of packets) {
534
+ try {
535
+ // Only process packets for our stream
536
+ if (packet.streamIndex === this.stream.index) {
537
+ const frame = this.decodeSync(packet);
538
+ if (frame) {
539
+ yield frame;
540
+ }
541
+ }
542
+ }
543
+ finally {
544
+ // Free the input packet after processing
545
+ packet.free();
546
+ }
547
+ }
548
+ // Flush decoder after all packets
549
+ this.flushSync();
550
+ while (true) {
551
+ const remaining = this.receiveSync();
552
+ if (!remaining)
553
+ break;
554
+ yield remaining;
555
+ }
556
+ }
362
557
  /**
363
558
  * Flush decoder and signal end-of-stream.
364
559
  *
@@ -398,6 +593,40 @@ export class Decoder {
398
593
  }
399
594
  }
400
595
  }
596
+ /**
597
+ * Flush decoder and signal end-of-stream synchronously.
598
+ * Synchronous version of flush.
599
+ *
600
+ * Send null packet to signal end of input stream.
601
+ * Decoder may still have buffered frames.
602
+ * Call receiveSync() repeatedly to get remaining frames.
603
+ *
604
+ * @throws {FFmpegError} If flush fails
605
+ *
606
+ * @example
607
+ * ```typescript
608
+ * decoder.flushSync();
609
+ * // Get remaining frames
610
+ * let frame;
611
+ * while ((frame = decoder.receiveSync()) !== null) {
612
+ * console.log('Buffered frame');
613
+ * }
614
+ * ```
615
+ *
616
+ * @see {@link flush} For async version
617
+ */
618
+ flushSync() {
619
+ if (this.isClosed) {
620
+ return;
621
+ }
622
+ // Send flush packet (null)
623
+ const ret = this.codecContext.sendPacketSync(null);
624
+ if (ret < 0 && ret !== AVERROR_EOF) {
625
+ if (ret !== AVERROR_EAGAIN) {
626
+ FFmpegError.throwIfError(ret, 'Failed to flush decoder');
627
+ }
628
+ }
629
+ }
401
630
  /**
402
631
  * Flush all buffered frames as async generator.
403
632
  *
@@ -428,6 +657,36 @@ export class Decoder {
428
657
  yield frame;
429
658
  }
430
659
  }
660
+ /**
661
+ * Flush all buffered frames as generator synchronously.
662
+ * Synchronous version of flushFrames.
663
+ *
664
+ * Convenient sync iteration over remaining frames.
665
+ * Automatically sends flush signal and retrieves buffered frames.
666
+ * Useful for end-of-stream processing.
667
+ *
668
+ * @yields {Frame} Buffered frames
669
+ *
670
+ * @example
671
+ * ```typescript
672
+ * // Flush at end of decoding
673
+ * for (const frame of decoder.flushFramesSync()) {
674
+ * console.log('Processing buffered frame');
675
+ * encoder.encodeSync(frame);
676
+ * frame.free();
677
+ * }
678
+ * ```
679
+ *
680
+ * @see {@link flushFrames} For async version
681
+ */
682
+ *flushFramesSync() {
683
+ // Send flush signal
684
+ this.flushSync();
685
+ let frame;
686
+ while ((frame = this.receiveSync()) !== null) {
687
+ yield frame;
688
+ }
689
+ }
431
690
  /**
432
691
  * Receive frame from decoder.
433
692
  *
@@ -482,6 +741,60 @@ export class Decoder {
482
741
  return null;
483
742
  }
484
743
  }
744
+ /**
745
+ * Receive frame from decoder synchronously.
746
+ * Synchronous version of receive.
747
+ *
748
+ * Gets decoded frames from the codec's internal buffer.
749
+ * Handles frame cloning and error checking.
750
+ * Hardware frames include hw_frames_ctx reference.
751
+ * Call repeatedly until null to drain all buffered frames.
752
+ *
753
+ * Direct mapping to avcodec_receive_frame().
754
+ *
755
+ * @returns Cloned frame or null if no frames available
756
+ *
757
+ * @throws {FFmpegError} If receive fails with error other than AVERROR_EAGAIN or AVERROR_EOF
758
+ *
759
+ * @example
760
+ * ```typescript
761
+ * const frame = decoder.receiveSync();
762
+ * if (frame) {
763
+ * console.log('Got decoded frame');
764
+ * frame.free();
765
+ * }
766
+ * ```
767
+ *
768
+ * @example
769
+ * ```typescript
770
+ * // Drain all buffered frames
771
+ * let frame;
772
+ * while ((frame = decoder.receiveSync()) !== null) {
773
+ * console.log(`Frame PTS: ${frame.pts}`);
774
+ * frame.free();
775
+ * }
776
+ * ```
777
+ *
778
+ * @see {@link receive} For async version
779
+ */
780
+ receiveSync() {
781
+ // Clear previous frame data
782
+ this.frame.unref();
783
+ const ret = this.codecContext.receiveFrameSync(this.frame);
784
+ if (ret === 0) {
785
+ // Got a frame, clone it for the user
786
+ return this.frame.clone();
787
+ }
788
+ else if (ret === AVERROR_EAGAIN || ret === AVERROR_EOF) {
789
+ // Need more data or end of stream
790
+ return null;
791
+ }
792
+ else {
793
+ // Error
794
+ FFmpegError.throwIfError(ret, 'Failed to receive frame');
795
+ return null;
796
+ }
797
+ }
485
798
  /**
486
799
  * Close decoder and free resources.
487
800
  *
@@ -1 +1 @@
1
- {"version":3,"file":"decoder.js","sourceRoot":"","sources":["../../src/api/decoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAMtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,OAAO,OAAO;IACV,YAAY,CAAe;IAC3B,KAAK,CAAQ;IACb,KAAK,CAAQ;IACb,MAAM,CAAS;IACf,WAAW,GAAG,IAAI,CAAC;IACnB,QAAQ,GAAG,KAAK,CAAC;IACjB,QAAQ,CAA0B;IAE1C;;;;;;;;OAQG;IACH,YAAoB,YAA0B,EAAE,KAAY,EAAE,MAAc,EAAE,QAAiC;QAC7G,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,IAAI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