node-av 1.0.3 → 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 (162) hide show
  1. package/README.md +56 -41
  2. package/dist/api/bitstream-filter.d.ts +180 -123
  3. package/dist/api/bitstream-filter.js +182 -126
  4. package/dist/api/bitstream-filter.js.map +1 -1
  5. package/dist/api/decoder.d.ts +286 -130
  6. package/dist/api/decoder.js +321 -159
  7. package/dist/api/decoder.js.map +1 -1
  8. package/dist/api/encoder.d.ts +254 -158
  9. package/dist/api/encoder.js +326 -298
  10. package/dist/api/encoder.js.map +1 -1
  11. package/dist/api/filter-presets.d.ts +912 -0
  12. package/dist/api/filter-presets.js +1407 -0
  13. package/dist/api/filter-presets.js.map +1 -0
  14. package/dist/api/filter.d.ts +280 -284
  15. package/dist/api/filter.js +435 -509
  16. package/dist/api/filter.js.map +1 -1
  17. package/dist/api/hardware.d.ts +226 -159
  18. package/dist/api/hardware.js +405 -287
  19. package/dist/api/hardware.js.map +1 -1
  20. package/dist/api/index.d.ts +3 -2
  21. package/dist/api/index.js +1 -0
  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 +45 -47
  25. package/dist/api/io-stream.js.map +1 -1
  26. package/dist/api/media-input.d.ts +244 -141
  27. package/dist/api/media-input.js +207 -104
  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 +212 -129
  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 +22 -182
  36. package/dist/api/utilities/audio-sample.d.ts +1 -1
  37. package/dist/api/utilities/image.d.ts +1 -1
  38. package/dist/api/utilities/media-type.d.ts +1 -1
  39. package/dist/api/utilities/pixel-format.d.ts +1 -1
  40. package/dist/api/utilities/sample-format.d.ts +1 -1
  41. package/dist/api/utilities/timestamp.d.ts +1 -1
  42. package/dist/api/utils.d.ts +1 -2
  43. package/dist/api/utils.js +9 -0
  44. package/dist/api/utils.js.map +1 -1
  45. package/dist/{lib → constants}/channel-layouts.d.ts +1 -1
  46. package/dist/constants/channel-layouts.js.map +1 -0
  47. package/dist/{lib → constants}/constants.d.ts +19 -4
  48. package/dist/{lib → constants}/constants.js +15 -1
  49. package/dist/constants/constants.js.map +1 -0
  50. package/dist/constants/decoders.d.ts +609 -0
  51. package/dist/constants/decoders.js +617 -0
  52. package/dist/constants/decoders.js.map +1 -0
  53. package/dist/constants/encoders.d.ts +285 -0
  54. package/dist/constants/encoders.js +298 -0
  55. package/dist/constants/encoders.js.map +1 -0
  56. package/dist/constants/index.d.ts +4 -0
  57. package/dist/constants/index.js +5 -0
  58. package/dist/constants/index.js.map +1 -0
  59. package/dist/index.d.ts +1 -0
  60. package/dist/index.js +2 -0
  61. package/dist/index.js.map +1 -1
  62. package/dist/lib/audio-fifo.d.ts +128 -171
  63. package/dist/lib/audio-fifo.js +130 -173
  64. package/dist/lib/audio-fifo.js.map +1 -1
  65. package/dist/lib/binding.d.ts +7 -5
  66. package/dist/lib/binding.js +5 -0
  67. package/dist/lib/binding.js.map +1 -1
  68. package/dist/lib/bitstream-filter-context.d.ts +139 -184
  69. package/dist/lib/bitstream-filter-context.js +139 -188
  70. package/dist/lib/bitstream-filter-context.js.map +1 -1
  71. package/dist/lib/bitstream-filter.d.ts +69 -55
  72. package/dist/lib/bitstream-filter.js +68 -54
  73. package/dist/lib/bitstream-filter.js.map +1 -1
  74. package/dist/lib/codec-context.d.ts +317 -381
  75. package/dist/lib/codec-context.js +316 -381
  76. package/dist/lib/codec-context.js.map +1 -1
  77. package/dist/lib/codec-parameters.d.ts +161 -171
  78. package/dist/lib/codec-parameters.js +162 -172
  79. package/dist/lib/codec-parameters.js.map +1 -1
  80. package/dist/lib/codec-parser.d.ts +92 -105
  81. package/dist/lib/codec-parser.js +92 -103
  82. package/dist/lib/codec-parser.js.map +1 -1
  83. package/dist/lib/codec.d.ts +328 -217
  84. package/dist/lib/codec.js +392 -218
  85. package/dist/lib/codec.js.map +1 -1
  86. package/dist/lib/dictionary.d.ts +150 -204
  87. package/dist/lib/dictionary.js +159 -213
  88. package/dist/lib/dictionary.js.map +1 -1
  89. package/dist/lib/error.d.ts +97 -131
  90. package/dist/lib/error.js +98 -128
  91. package/dist/lib/error.js.map +1 -1
  92. package/dist/lib/filter-context.d.ts +317 -194
  93. package/dist/lib/filter-context.js +335 -200
  94. package/dist/lib/filter-context.js.map +1 -1
  95. package/dist/lib/filter-graph.d.ts +252 -293
  96. package/dist/lib/filter-graph.js +253 -294
  97. package/dist/lib/filter-graph.js.map +1 -1
  98. package/dist/lib/filter-inout.d.ts +87 -95
  99. package/dist/lib/filter-inout.js +87 -95
  100. package/dist/lib/filter-inout.js.map +1 -1
  101. package/dist/lib/filter.d.ts +93 -111
  102. package/dist/lib/filter.js +94 -112
  103. package/dist/lib/filter.js.map +1 -1
  104. package/dist/lib/format-context.d.ts +321 -429
  105. package/dist/lib/format-context.js +314 -386
  106. package/dist/lib/format-context.js.map +1 -1
  107. package/dist/lib/frame.d.ts +263 -406
  108. package/dist/lib/frame.js +263 -408
  109. package/dist/lib/frame.js.map +1 -1
  110. package/dist/lib/hardware-device-context.d.ts +150 -204
  111. package/dist/lib/hardware-device-context.js +149 -203
  112. package/dist/lib/hardware-device-context.js.map +1 -1
  113. package/dist/lib/hardware-frames-context.d.ts +171 -181
  114. package/dist/lib/hardware-frames-context.js +171 -181
  115. package/dist/lib/hardware-frames-context.js.map +1 -1
  116. package/dist/lib/index.d.ts +2 -3
  117. package/dist/lib/index.js +2 -5
  118. package/dist/lib/index.js.map +1 -1
  119. package/dist/lib/input-format.d.ts +90 -118
  120. package/dist/lib/input-format.js +89 -117
  121. package/dist/lib/input-format.js.map +1 -1
  122. package/dist/lib/io-context.d.ts +210 -242
  123. package/dist/lib/io-context.js +221 -253
  124. package/dist/lib/io-context.js.map +1 -1
  125. package/dist/lib/log.d.ts +86 -120
  126. package/dist/lib/log.js +85 -122
  127. package/dist/lib/log.js.map +1 -1
  128. package/dist/lib/native-types.d.ts +127 -112
  129. package/dist/lib/native-types.js +9 -0
  130. package/dist/lib/native-types.js.map +1 -1
  131. package/dist/lib/option.d.ts +285 -242
  132. package/dist/lib/option.js +310 -250
  133. package/dist/lib/option.js.map +1 -1
  134. package/dist/lib/output-format.d.ts +78 -102
  135. package/dist/lib/output-format.js +77 -101
  136. package/dist/lib/output-format.js.map +1 -1
  137. package/dist/lib/packet.d.ts +173 -241
  138. package/dist/lib/packet.js +172 -241
  139. package/dist/lib/packet.js.map +1 -1
  140. package/dist/lib/rational.d.ts +0 -2
  141. package/dist/lib/rational.js +0 -2
  142. package/dist/lib/rational.js.map +1 -1
  143. package/dist/lib/software-resample-context.d.ts +242 -326
  144. package/dist/lib/software-resample-context.js +242 -326
  145. package/dist/lib/software-resample-context.js.map +1 -1
  146. package/dist/lib/software-scale-context.d.ts +130 -174
  147. package/dist/lib/software-scale-context.js +132 -176
  148. package/dist/lib/software-scale-context.js.map +1 -1
  149. package/dist/lib/stream.d.ts +88 -198
  150. package/dist/lib/stream.js +87 -197
  151. package/dist/lib/stream.js.map +1 -1
  152. package/dist/lib/types.d.ts +1 -1
  153. package/dist/lib/utilities.d.ts +372 -181
  154. package/dist/lib/utilities.js +373 -182
  155. package/dist/lib/utilities.js.map +1 -1
  156. package/install/check.js +0 -1
  157. package/package.json +32 -24
  158. package/release_notes.md +43 -13
  159. package/CHANGELOG.md +0 -8
  160. package/dist/lib/channel-layouts.js.map +0 -1
  161. package/dist/lib/constants.js.map +0 -1
  162. /package/dist/{lib → constants}/channel-layouts.js +0 -0
@@ -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 {};