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,14 +1,7 @@
1
1
  /**
2
- * Pipeline - Stream-based media processing pipeline
3
- *
4
- * Provides a Node.js-style pipeline function for chaining media processing components.
5
- * Automatically handles type conversions, buffering, and flushing.
6
- *
7
- * Supports two modes:
8
- * 1. Simple: Single stream with variable parameters
9
- * 2. Named: Multiple streams with named routing with variable parameters
10
- *
11
- * @module api/pipeline
2
+ * @module pipeline
3
+ * High-level media processing pipeline for FFmpeg operations.
4
+ * Provides a fluent API for building transcoding, filtering, and stream processing pipelines.
12
5
  */
13
6
  import type { Frame, Packet } from '../lib/index.js';
14
7
  import type { BitStreamFilterAPI } from './bitstream-filter.js';
@@ -17,101 +10,238 @@ import type { Encoder } from './encoder.js';
17
10
  import type { FilterAPI } from './filter.js';
18
11
  import type { MediaInput } from './media-input.js';
19
12
  import type { MediaOutput } from './media-output.js';
20
- type StreamName = 'video' | 'audio';
21
- type NamedInputs<K extends StreamName = StreamName> = Pick<Record<StreamName, MediaInput>, K>;
22
- type NamedStages<K extends StreamName = StreamName> = Pick<Record<StreamName, (Decoder | FilterAPI | FilterAPI[] | Encoder | BitStreamFilterAPI | BitStreamFilterAPI[])[] | 'passthrough'>, K>;
23
- type NamedOutputs<K extends StreamName = StreamName> = Pick<Record<StreamName, MediaOutput>, K>;
13
+ export type StreamName = 'video' | 'audio';
14
+ export type NamedInputs<K extends StreamName = StreamName> = Pick<Record<StreamName, MediaInput>, K>;
15
+ export type NamedStages<K extends StreamName = StreamName> = Pick<Record<StreamName, (Decoder | FilterAPI | FilterAPI[] | Encoder | BitStreamFilterAPI | BitStreamFilterAPI[])[] | 'passthrough'>, K>;
16
+ export type NamedOutputs<K extends StreamName = StreamName> = Pick<Record<StreamName, MediaOutput>, K>;
24
17
  /**
25
- * Pipeline control interface for managing pipeline execution
18
+ * Pipeline control interface for managing pipeline execution.
19
+ * Allows graceful stopping and completion tracking of running pipelines.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const control = pipeline(input, decoder, encoder, output);
24
+ *
25
+ * // Stop after 10 seconds
26
+ * setTimeout(() => control.stop(), 10000);
27
+ *
28
+ * // Wait for completion
29
+ * await control.completion;
30
+ * ```
26
31
  */
27
32
  export interface PipelineControl {
28
33
  /**
29
- * Stop the pipeline gracefully
34
+ * Stop the pipeline gracefully.
35
+ * The pipeline will stop processing after the current operation completes.
30
36
  */
31
37
  stop(): void;
32
38
  /**
33
- * Check if the pipeline has been stopped
39
+ * Check if the pipeline has been stopped.
40
+ *
41
+ * @returns True if stop() has been called
34
42
  */
35
43
  isStopped(): boolean;
36
44
  /**
37
- * Promise that resolves when the pipeline completes
45
+ * Promise that resolves when the pipeline completes.
46
+ * Resolves when all processing is finished or the pipeline is stopped.
38
47
  */
39
48
  readonly completion: Promise<void>;
40
49
  }
41
50
  /**
42
- * Full transcoding pipeline: input → decoder → encoder → output
51
+ * Full transcoding pipeline: input → decoder → encoder → output.
52
+ *
53
+ * @param source - Media input source
54
+ * @param decoder - Decoder for decoding packets to frames
55
+ * @param encoder - Encoder for encoding frames to packets
56
+ * @param output - Media output destination
57
+ * @returns Pipeline control for managing execution
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * const control = pipeline(input, decoder, encoder, output);
62
+ * await control.completion;
63
+ * ```
43
64
  */
44
65
  export declare function pipeline(source: MediaInput, decoder: Decoder, encoder: Encoder, output: MediaOutput): PipelineControl;
45
66
  /**
46
- * Full transcoding pipeline with filter: input → decoder → filter → encoder → output
67
+ * Full transcoding pipeline with filter: input → decoder → filter → encoder → output.
68
+ *
69
+ * @param source - Media input source
70
+ * @param decoder - Decoder for decoding packets to frames
71
+ * @param filter - Filter or filter chain for processing frames
72
+ * @param encoder - Encoder for encoding frames to packets
73
+ * @param output - Media output destination
74
+ * @returns Pipeline control for managing execution
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * const control = pipeline(input, decoder, scaleFilter, encoder, output);
79
+ * await control.completion;
80
+ * ```
47
81
  */
48
82
  export declare function pipeline(source: MediaInput, decoder: Decoder, filter: FilterAPI | FilterAPI[], encoder: Encoder, output: MediaOutput): PipelineControl;
49
83
  /**
50
- * Transcoding with bitstream filter: input → decoder → encoder → bsf → output
84
+ * Transcoding with bitstream filter: input → decoder → encoder → bsf → output.
85
+ *
86
+ * @param source - Media input source
87
+ * @param decoder - Decoder for decoding packets
88
+ * @param encoder - Encoder for encoding frames
89
+ * @param bsf - Bitstream filter for packet processing
90
+ * @param output - Media output destination
91
+ * @returns Pipeline control for managing execution
51
92
  */
52
93
  export declare function pipeline(source: MediaInput, decoder: Decoder, encoder: Encoder, bsf: BitStreamFilterAPI | BitStreamFilterAPI[], output: MediaOutput): PipelineControl;
53
94
  /**
54
- * Full pipeline with filter and bsf: input → decoder → filter → encoder → bsf → output
95
+ * Full pipeline with filter and bsf: input → decoder → filter → encoder → bsf → output.
96
+ *
97
+ * @param source - Media input source
98
+ * @param decoder - Decoder for decoding packets
99
+ * @param filter - Filter or filter chain
100
+ * @param encoder - Encoder for encoding frames
101
+ * @param bsf - Bitstream filter
102
+ * @param output - Media output destination
103
+ * @returns Pipeline control for managing execution
55
104
  */
56
105
  export declare function pipeline(source: MediaInput, decoder: Decoder, filter: FilterAPI | FilterAPI[], encoder: Encoder, bsf: BitStreamFilterAPI | BitStreamFilterAPI[], output: MediaOutput): PipelineControl;
57
106
  /**
58
- * Decode + multiple filters + encode: input → decoder → filter1 → filter2 → encoder → output
107
+ * Decode + multiple filters + encode: input → decoder → filter1 → filter2 → encoder → output.
108
+ *
109
+ * @param source - Media input source
110
+ * @param decoder - Decoder for decoding packets
111
+ * @param filter1 - First filter
112
+ * @param filter2 - Second filter
113
+ * @param encoder - Encoder for encoding frames
114
+ * @param output - Media output destination
115
+ * @returns Pipeline control for managing execution
59
116
  */
60
117
  export declare function pipeline(source: MediaInput, decoder: Decoder, filter1: FilterAPI, filter2: FilterAPI, encoder: Encoder, output: MediaOutput): PipelineControl;
61
118
  /**
62
- * Stream copy pipeline: input → output (copies all streams)
119
+ * Stream copy pipeline: input → output (copies all streams).
120
+ *
121
+ * @param source - Media input source
122
+ * @param output - Media output destination
123
+ * @returns Pipeline control for managing execution
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * // Copy all streams without re-encoding
128
+ * const control = pipeline(input, output);
129
+ * await control.completion;
130
+ * ```
63
131
  */
64
132
  export declare function pipeline(source: MediaInput, output: MediaOutput): PipelineControl;
65
133
  /**
66
- * Stream copy with bitstream filter: input → bsf → output
134
+ * Stream copy with bitstream filter: input → bsf → output.
135
+ *
136
+ * @param source - Media input source
137
+ * @param bsf - Bitstream filter for packet processing
138
+ * @param output - Media output destination
139
+ * @returns Pipeline control for managing execution
67
140
  */
68
141
  export declare function pipeline(source: MediaInput, bsf: BitStreamFilterAPI | BitStreamFilterAPI[], output: MediaOutput): PipelineControl;
69
142
  /**
70
- * Filter + encode + output: frames → filter → encoder → output
143
+ * Filter + encode + output: frames → filter → encoder → output.
144
+ *
145
+ * @param source - Frame source (async iterable)
146
+ * @param filter - Filter or filter chain
147
+ * @param encoder - Encoder for encoding frames
148
+ * @param output - Media output destination
149
+ * @returns Pipeline control for managing execution
71
150
  */
72
151
  export declare function pipeline(source: AsyncIterable<Frame>, filter: FilterAPI | FilterAPI[], encoder: Encoder, output: MediaOutput): PipelineControl;
73
152
  /**
74
- * Encode + output: frames → encoder → output
153
+ * Encode + output: frames → encoder → output.
154
+ *
155
+ * @param source - Frame source (async iterable)
156
+ * @param encoder - Encoder for encoding frames
157
+ * @param output - Media output destination
158
+ * @returns Pipeline control for managing execution
75
159
  */
76
160
  export declare function pipeline(source: AsyncIterable<Frame>, encoder: Encoder, output: MediaOutput): PipelineControl;
77
161
  /**
78
- * Partial pipeline: input → decoder (returns frames)
162
+ * Partial pipeline: input → decoder (returns frames).
163
+ *
164
+ * @param source - Media input source
165
+ * @param decoder - Decoder for decoding packets
166
+ * @returns Async generator of frames
79
167
  */
80
168
  export declare function pipeline(source: MediaInput, decoder: Decoder): AsyncGenerator<Frame>;
81
169
  /**
82
- * Partial pipeline: input → decoder → filter (returns frames)
170
+ * Partial pipeline: input → decoder → filter (returns frames).
171
+ *
172
+ * @param source - Media input source
173
+ * @param decoder - Decoder for decoding packets
174
+ * @param filter - Filter or filter chain
175
+ * @returns Async generator of frames
83
176
  */
84
177
  export declare function pipeline(source: MediaInput, decoder: Decoder, filter: FilterAPI | FilterAPI[]): AsyncGenerator<Frame>;
85
178
  /**
86
- * Partial pipeline: input → decoder → filter → encoder (returns packets)
179
+ * Partial pipeline: input → decoder → filter → encoder (returns packets).
180
+ *
181
+ * @param source - Media input source
182
+ * @param decoder - Decoder for decoding packets
183
+ * @param filter - Filter or filter chain
184
+ * @param encoder - Encoder for encoding frames
185
+ * @returns Async generator of packets
87
186
  */
88
187
  export declare function pipeline(source: MediaInput, decoder: Decoder, filter: FilterAPI | FilterAPI[], encoder: Encoder): AsyncGenerator<Packet>;
89
188
  /**
90
- * Partial pipeline: input → decoder → encoder (returns packets)
189
+ * Partial pipeline: input → decoder → encoder (returns packets).
190
+ *
191
+ * @param source - Media input source
192
+ * @param decoder - Decoder for decoding packets
193
+ * @param encoder - Encoder for encoding frames
194
+ * @returns Async generator of packets
91
195
  */
92
196
  export declare function pipeline(source: MediaInput, decoder: Decoder, encoder: Encoder): AsyncGenerator<Packet>;
93
197
  /**
94
- * Partial pipeline: frames → filter (returns frames)
198
+ * Partial pipeline: frames → filter (returns frames).
199
+ *
200
+ * @param source - Frame source (async iterable)
201
+ * @param filter - Filter or filter chain
202
+ * @returns Async generator of filtered frames
95
203
  */
96
204
  export declare function pipeline(source: AsyncIterable<Frame>, filter: FilterAPI | FilterAPI[]): AsyncGenerator<Frame>;
97
205
  /**
98
- * Partial pipeline: frames → encoder (returns packets)
206
+ * Partial pipeline: frames → encoder (returns packets).
207
+ *
208
+ * @param source - Frame source (async iterable)
209
+ * @param encoder - Encoder for encoding frames
210
+ * @returns Async generator of packets
99
211
  */
100
212
  export declare function pipeline(source: AsyncIterable<Frame>, encoder: Encoder): AsyncGenerator<Packet>;
101
213
  /**
102
- * Partial pipeline: frames → filter → encoder (returns packets)
214
+ * Partial pipeline: frames → filter → encoder (returns packets).
215
+ *
216
+ * @param source - Frame source (async iterable)
217
+ * @param filter - Filter or filter chain
218
+ * @param encoder - Encoder for encoding frames
219
+ * @returns Async generator of packets
103
220
  */
104
221
  export declare function pipeline(source: AsyncIterable<Frame>, filter: FilterAPI | FilterAPI[], encoder: Encoder): AsyncGenerator<Packet>;
105
222
  /**
106
- * Named pipeline with single output - all streams go to the same output
223
+ * Named pipeline with single output - all streams go to the same output.
224
+ *
225
+ * @param inputs - Named input sources (video/audio)
226
+ * @param stages - Named processing stages for each stream
227
+ * @param output - Single output destination for all streams
228
+ * @returns Pipeline control for managing execution
107
229
  */
108
230
  export declare function pipeline<K extends StreamName>(inputs: NamedInputs<K>, stages: NamedStages<K>, output: MediaOutput): PipelineControl;
109
231
  /**
110
- * Named pipeline with multiple outputs - each stream has its own output
232
+ * Named pipeline with multiple outputs - each stream has its own output.
233
+ *
234
+ * @param inputs - Named input sources (video/audio)
235
+ * @param stages - Named processing stages for each stream
236
+ * @param outputs - Named output destinations
237
+ * @returns Pipeline control for managing execution
111
238
  */
112
239
  export declare function pipeline<K extends StreamName>(inputs: NamedInputs<K>, stages: NamedStages<K>, outputs: NamedOutputs<K>): PipelineControl;
113
240
  /**
114
- * Partial named pipeline (returns generators for further processing)
241
+ * Partial named pipeline (returns generators for further processing).
242
+ *
243
+ * @param inputs - Named input sources
244
+ * @param stages - Named processing stages
245
+ * @returns Record of async generators for each stream
115
246
  */
116
247
  export declare function pipeline<K extends StreamName, T extends Packet | Frame = Packet | Frame>(inputs: NamedInputs<K>, stages: NamedStages<K>): Record<K, AsyncGenerator<T>>;
117
- export {};