bare-ffmpeg 1.0.0-2 → 1.0.0-21
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.
- package/CMakeLists.txt +10 -3
- package/README.md +1097 -0
- package/binding.cc +3330 -0
- package/cmake/ports/ffmpeg/port.cmake +513 -0
- package/cmake/ports/opus/patches/01-windows-clang.patch +52 -0
- package/cmake/ports/opus/port.cmake +42 -0
- package/cmake/ports/svt-av1/port.cmake +42 -0
- package/cmake/ports/x264/patches/01-windows-clang.patch +33 -0
- package/cmake/ports/x264/port.cmake +157 -0
- package/index.js +14 -4
- package/lib/audio-fifo.js +47 -0
- package/lib/channel-layout.js +35 -0
- package/lib/codec-context.js +92 -15
- package/lib/codec-parameters.js +230 -8
- package/lib/codec.js +19 -0
- package/lib/constants.js +163 -8
- package/lib/dictionary.js +18 -15
- package/lib/errors.js +38 -0
- package/lib/format-context.js +62 -31
- package/lib/frame.js +87 -16
- package/lib/image.js +22 -0
- package/lib/input-format.js +8 -3
- package/lib/io-context.js +29 -6
- package/lib/log.js +16 -0
- package/lib/output-format.js +4 -0
- package/lib/packet.js +88 -13
- package/lib/rational.js +35 -1
- package/lib/resampler.js +63 -0
- package/lib/samples.js +49 -0
- package/lib/scaler.js +8 -7
- package/lib/stream.js +37 -12
- package/package.json +7 -4
- package/prebuilds/android-arm/bare-ffmpeg.bare +0 -0
- package/prebuilds/android-arm64/bare-ffmpeg.bare +0 -0
- package/prebuilds/android-ia32/bare-ffmpeg.bare +0 -0
- package/prebuilds/android-x64/bare-ffmpeg.bare +0 -0
- package/prebuilds/darwin-arm64/bare-ffmpeg.bare +0 -0
- package/prebuilds/darwin-x64/bare-ffmpeg.bare +0 -0
- package/prebuilds/ios-arm64/bare-ffmpeg.bare +0 -0
- package/prebuilds/ios-arm64-simulator/bare-ffmpeg.bare +0 -0
- package/prebuilds/ios-x64-simulator/bare-ffmpeg.bare +0 -0
- package/prebuilds/linux-arm64/bare-ffmpeg.bare +0 -0
- package/prebuilds/linux-x64/bare-ffmpeg.bare +0 -0
- package/prebuilds/win32-arm64/bare-ffmpeg.bare +0 -0
- package/prebuilds/win32-x64/bare-ffmpeg.bare +0 -0
- package/binding.c +0 -2128
- package/lib/reference-counted.js +0 -39
package/README.md
CHANGED
|
@@ -6,6 +6,1103 @@ Low-level FFmpeg bindings for Bare.
|
|
|
6
6
|
npm i bare-ffmpeg
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
+
## API
|
|
10
|
+
|
|
11
|
+
### `IOContext`
|
|
12
|
+
|
|
13
|
+
The `IOContext` API provides functionality to create input/output contexts for media files.
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
const io = new ffmpeg.IOContext(buffer)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Parameters:
|
|
20
|
+
|
|
21
|
+
- `buffer` (`Buffer`): The media data buffer
|
|
22
|
+
|
|
23
|
+
**Returns**: A new `IOContext` instance
|
|
24
|
+
|
|
25
|
+
Example:
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
const image = require('./fixtures/image/sample.jpeg', {
|
|
29
|
+
with: { type: 'binary' }
|
|
30
|
+
})
|
|
31
|
+
const io = new ffmpeg.IOContext(image)
|
|
32
|
+
io.destroy()
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
#### Methods
|
|
36
|
+
|
|
37
|
+
##### `IOContext.destroy()`
|
|
38
|
+
|
|
39
|
+
Destroys the `IOContext` and frees all associated resources. Automatically called when the object is managed by a `using` declaration.
|
|
40
|
+
|
|
41
|
+
**Returns**: `void`
|
|
42
|
+
|
|
43
|
+
### `Dictionary`
|
|
44
|
+
|
|
45
|
+
The `Dictionary` API provides functionality to store and retrieve key-value pairs, commonly used for passing options to various FFmpeg components.
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
const dict = new ffmpeg.Dictionary()
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Returns**: A new `Dictionary` instance
|
|
52
|
+
|
|
53
|
+
Example:
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
const dict = new ffmpeg.Dictionary()
|
|
57
|
+
dict.set('video_codec', 'h264')
|
|
58
|
+
dict.set('audio_codec', 'aac')
|
|
59
|
+
dict.set('bitrate', '1000k')
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
#### Methods
|
|
63
|
+
|
|
64
|
+
##### `Dictionary.set(key, value)`
|
|
65
|
+
|
|
66
|
+
Sets a key-value pair in the dictionary. Non-string values are automatically converted to strings.
|
|
67
|
+
|
|
68
|
+
Parameters:
|
|
69
|
+
|
|
70
|
+
- `key` (`string`): The dictionary key
|
|
71
|
+
- `value` (`string` | `number`): The value to store
|
|
72
|
+
|
|
73
|
+
**Returns**: `void`
|
|
74
|
+
|
|
75
|
+
##### `Dictionary.get(key)`
|
|
76
|
+
|
|
77
|
+
Retrieves a value from the dictionary by key.
|
|
78
|
+
|
|
79
|
+
Parameters:
|
|
80
|
+
|
|
81
|
+
- `key` (`string`): The dictionary key
|
|
82
|
+
|
|
83
|
+
**Returns**: `string` value or `null` if the key doesn't exist
|
|
84
|
+
|
|
85
|
+
##### `Dictionary.entries()`
|
|
86
|
+
|
|
87
|
+
Retrieves all keys and values.
|
|
88
|
+
|
|
89
|
+
**Returns**: `Array<[string, string]>` value
|
|
90
|
+
|
|
91
|
+
##### `Dictionary.destroy()`
|
|
92
|
+
|
|
93
|
+
Destroys the `Dictionary` and frees all associated resources. Automatically called when the object is managed by a `using` declaration.
|
|
94
|
+
|
|
95
|
+
**Returns**: `void`
|
|
96
|
+
|
|
97
|
+
#### Iteration
|
|
98
|
+
|
|
99
|
+
The `Dictionary` class implements the iterator protocol, allowing you to iterate over all key-value pairs:
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
const dict = new ffmpeg.Dictionary()
|
|
103
|
+
dict.set('foo', 'bar')
|
|
104
|
+
dict.set('baz', 'qux')
|
|
105
|
+
|
|
106
|
+
for (const [key, value] of dict) {
|
|
107
|
+
console.log(`${key}: ${value}`)
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### `FormatContext`
|
|
112
|
+
|
|
113
|
+
The `FormatContext` API provides the base functionality for reading and writing media files.
|
|
114
|
+
|
|
115
|
+
> This is the base class that `InputFormatContext` and `OutputFormatContext` extend.
|
|
116
|
+
|
|
117
|
+
#### Properties
|
|
118
|
+
|
|
119
|
+
##### `FormatContext.io`
|
|
120
|
+
|
|
121
|
+
Gets the IO context associated with this format context.
|
|
122
|
+
|
|
123
|
+
**Returns**: `IOContext` instance or `null`
|
|
124
|
+
|
|
125
|
+
##### `FormatContext.streams`
|
|
126
|
+
|
|
127
|
+
Gets the array of media streams.
|
|
128
|
+
|
|
129
|
+
**Returns**: Array of `Stream` instances
|
|
130
|
+
|
|
131
|
+
#### Methods
|
|
132
|
+
|
|
133
|
+
##### `FormatContext.readFrame(packet)`
|
|
134
|
+
|
|
135
|
+
Reads the next frame from the media file into a packet.
|
|
136
|
+
|
|
137
|
+
Parameters:
|
|
138
|
+
|
|
139
|
+
- `packet` (`Packet`): The packet to store the frame data
|
|
140
|
+
|
|
141
|
+
**Returns**: `boolean` indicating if a frame was read
|
|
142
|
+
|
|
143
|
+
##### `FormatContext.getBestStream(type)`
|
|
144
|
+
|
|
145
|
+
Gets the best stream of the specified media type.
|
|
146
|
+
|
|
147
|
+
Parameters:
|
|
148
|
+
|
|
149
|
+
- `type` (`number`): The media type from `ffmpeg.constants.mediaTypes`
|
|
150
|
+
|
|
151
|
+
**Returns**: `Stream` instance or `null` if not found
|
|
152
|
+
|
|
153
|
+
##### `FormatContext.destroy()`
|
|
154
|
+
|
|
155
|
+
Destroys the `FormatContext` and frees all associated resources including streams. Automatically called when the object is managed by a `using` declaration.
|
|
156
|
+
|
|
157
|
+
**Returns**: `void`
|
|
158
|
+
|
|
159
|
+
### `InputFormatContext`
|
|
160
|
+
|
|
161
|
+
The `InputFormatContext` API extends `FormatContext` to provide functionality for reading media files.
|
|
162
|
+
|
|
163
|
+
```js
|
|
164
|
+
const format = new ffmpeg.InputFormatContext(io, options[, url])
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Parameters:
|
|
168
|
+
|
|
169
|
+
- `io` (`IOContext` | `InputFormat`): The IO context or input format. The ownership of `io` is transferred.
|
|
170
|
+
- `options` (`Dictionary`): Format options. Required when using `InputFormat`, ignored when using `IOContext`. The ownership of `options` is transferred.
|
|
171
|
+
- `url` (`string`, optional): Media source URL. Defaults to a platform-specific value
|
|
172
|
+
|
|
173
|
+
**Returns**: A new `InputFormatContext` instance
|
|
174
|
+
|
|
175
|
+
#### Methods
|
|
176
|
+
|
|
177
|
+
##### `InputFormatContext.destroy()`
|
|
178
|
+
|
|
179
|
+
Destroys the `InputFormatContext` and closes the input format. Automatically called when the object is managed by a `using` declaration.
|
|
180
|
+
|
|
181
|
+
**Returns**: void
|
|
182
|
+
|
|
183
|
+
### `OutputFormatContext`
|
|
184
|
+
|
|
185
|
+
The `OutputFormatContext` API extends `FormatContext` to provide functionality for writing media files.
|
|
186
|
+
|
|
187
|
+
```js
|
|
188
|
+
const format = new ffmpeg.OutputFormatContext(formatName, io)
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Parameters:
|
|
192
|
+
|
|
193
|
+
- `formatName` (`string`): The output format name (e.g., `'mp4'`, `'avi'`)
|
|
194
|
+
- `io` (`IOContext`): The IO context for writing. The ownership of `io` is transferred.
|
|
195
|
+
|
|
196
|
+
**Returns**: A new `OutputFormatContext` instance
|
|
197
|
+
|
|
198
|
+
#### Methods
|
|
199
|
+
|
|
200
|
+
##### `OutputFormatContext.createStream(codec)`
|
|
201
|
+
|
|
202
|
+
Creates a new stream in the output format.
|
|
203
|
+
|
|
204
|
+
Parameters:
|
|
205
|
+
|
|
206
|
+
- `codec` (`Codec`): The codec to use for the stream
|
|
207
|
+
|
|
208
|
+
**Returns**: A new `Stream` instance
|
|
209
|
+
|
|
210
|
+
##### `OutputFormatContext.destroy()`
|
|
211
|
+
|
|
212
|
+
Destroys the `OutputFormatContext` and closes the output format. Automatically called when the object is managed by a `using` declaration.
|
|
213
|
+
|
|
214
|
+
**Returns**: `void`
|
|
215
|
+
|
|
216
|
+
### `Codec`
|
|
217
|
+
|
|
218
|
+
The `Codec` API provides access to FFmpeg codecs for encoding and decoding.
|
|
219
|
+
|
|
220
|
+
#### Static properties
|
|
221
|
+
|
|
222
|
+
##### `Codec.H264`
|
|
223
|
+
|
|
224
|
+
H.264 video codec.
|
|
225
|
+
|
|
226
|
+
**Returns**: `Codec` instance
|
|
227
|
+
|
|
228
|
+
##### `Codec.MJPEG`
|
|
229
|
+
|
|
230
|
+
Motion JPEG video codec.
|
|
231
|
+
|
|
232
|
+
**Returns**: `Codec` instance
|
|
233
|
+
|
|
234
|
+
##### `Codec.AAC`
|
|
235
|
+
|
|
236
|
+
AAC audio codec.
|
|
237
|
+
|
|
238
|
+
**Returns**: `Codec` instance
|
|
239
|
+
|
|
240
|
+
##### `Codec.AV1`
|
|
241
|
+
|
|
242
|
+
AV1 video codec.
|
|
243
|
+
|
|
244
|
+
**Returns**: `Codec` instance
|
|
245
|
+
|
|
246
|
+
#### Properties
|
|
247
|
+
|
|
248
|
+
##### `Codec.id`
|
|
249
|
+
|
|
250
|
+
Gets the codec ID.
|
|
251
|
+
|
|
252
|
+
**Returns**: `number`
|
|
253
|
+
|
|
254
|
+
##### `Codec.encoder`
|
|
255
|
+
|
|
256
|
+
Gets the encoder for this codec.
|
|
257
|
+
|
|
258
|
+
**Returns**: `Encoder` instance
|
|
259
|
+
|
|
260
|
+
##### `Codec.decoder`
|
|
261
|
+
|
|
262
|
+
Gets the decoder for this codec.
|
|
263
|
+
|
|
264
|
+
**Returns**: `Decoder` instance
|
|
265
|
+
|
|
266
|
+
#### Methods
|
|
267
|
+
|
|
268
|
+
##### `Codec.for(id)`
|
|
269
|
+
|
|
270
|
+
Gets a codec by ID.
|
|
271
|
+
|
|
272
|
+
Parameters:
|
|
273
|
+
|
|
274
|
+
- `id` (`number`): The codec ID
|
|
275
|
+
|
|
276
|
+
**Returns**: `Codec` instance
|
|
277
|
+
|
|
278
|
+
### `CodecContext`
|
|
279
|
+
|
|
280
|
+
The `CodecContext` API provides functionality to encode or decode media frames.
|
|
281
|
+
|
|
282
|
+
```js
|
|
283
|
+
const codecCtx = new ffmpeg.CodecContext(codec)
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Parameters:
|
|
287
|
+
|
|
288
|
+
- `codec` (Codec): The codec to use (e.g., `ffmpeg.Codec.H264.encoder`)
|
|
289
|
+
|
|
290
|
+
**Returns**: A new `CodecContext` instance
|
|
291
|
+
|
|
292
|
+
#### Properties
|
|
293
|
+
|
|
294
|
+
##### `CodecContext.timeBase`
|
|
295
|
+
|
|
296
|
+
Gets or sets the time base for the codec context.
|
|
297
|
+
|
|
298
|
+
**Returns**: `Rational` instance
|
|
299
|
+
|
|
300
|
+
##### `CodecContext.pixelFormat`
|
|
301
|
+
|
|
302
|
+
Gets or sets the pixel format for video codecs.
|
|
303
|
+
|
|
304
|
+
**Returns**: `number` (pixel format constant)
|
|
305
|
+
|
|
306
|
+
##### `CodecContext.width`
|
|
307
|
+
|
|
308
|
+
Gets or sets the frame width for video codecs.
|
|
309
|
+
|
|
310
|
+
**Returns**: `number`
|
|
311
|
+
|
|
312
|
+
##### `CodecContext.height`
|
|
313
|
+
|
|
314
|
+
Gets or sets the frame height for video codecs.
|
|
315
|
+
|
|
316
|
+
**Returns**: `number`
|
|
317
|
+
|
|
318
|
+
#### Methods
|
|
319
|
+
|
|
320
|
+
##### `CodecContext.open([options])`
|
|
321
|
+
|
|
322
|
+
Opens the codec context for encoding/decoding.
|
|
323
|
+
|
|
324
|
+
Parameters:
|
|
325
|
+
|
|
326
|
+
- `options` (`Dictionary`, optional): Codec-specific options
|
|
327
|
+
|
|
328
|
+
**Returns**: `CodecContext` instance (for chaining)
|
|
329
|
+
|
|
330
|
+
##### `CodecContext.sendFrame(frame)`
|
|
331
|
+
|
|
332
|
+
Sends a frame to the encoder.
|
|
333
|
+
|
|
334
|
+
Parameters:
|
|
335
|
+
|
|
336
|
+
- `frame` (`Frame`): The frame to encode
|
|
337
|
+
|
|
338
|
+
**Returns**: `boolean` indicating if the frame was sent
|
|
339
|
+
|
|
340
|
+
##### `CodecContext.receiveFrame(frame)`
|
|
341
|
+
|
|
342
|
+
Receives a decoded frame from the decoder.
|
|
343
|
+
|
|
344
|
+
Parameters:
|
|
345
|
+
|
|
346
|
+
- `frame` (`Frame`): The frame to store the decoded data
|
|
347
|
+
|
|
348
|
+
**Returns**: `boolean` indicating if a frame was received
|
|
349
|
+
|
|
350
|
+
##### `CodecContext.sendPacket(packet)`
|
|
351
|
+
|
|
352
|
+
Sends a packet to the decoder.
|
|
353
|
+
|
|
354
|
+
Parameters:
|
|
355
|
+
|
|
356
|
+
- `packet` (`Packet`): The packet to decode
|
|
357
|
+
|
|
358
|
+
**Returns**: `boolean` indicating if the packet was sent
|
|
359
|
+
|
|
360
|
+
##### `CodecContext.receivePacket(packet)`
|
|
361
|
+
|
|
362
|
+
Receives an encoded packet from the encoder.
|
|
363
|
+
|
|
364
|
+
Parameters:
|
|
365
|
+
|
|
366
|
+
- `packet` (`Packet`): The packet to store the encoded data
|
|
367
|
+
|
|
368
|
+
**Returns**: `boolean` indicating if a packet was received
|
|
369
|
+
|
|
370
|
+
##### `CodecContext.destroy()`
|
|
371
|
+
|
|
372
|
+
Destroys the `CodecContext` and frees all associated resources. Automatically called when the object is managed by a `using` declaration.
|
|
373
|
+
|
|
374
|
+
**Returns**: `void`
|
|
375
|
+
|
|
376
|
+
### `CodecParameters`
|
|
377
|
+
|
|
378
|
+
The `CodecParameters` API provides functionality to access codec parameters from streams.
|
|
379
|
+
|
|
380
|
+
```js
|
|
381
|
+
const params = stream.codecParameters // Get from stream
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
#### Properties
|
|
385
|
+
|
|
386
|
+
##### `CodecParameters.type`
|
|
387
|
+
|
|
388
|
+
General type of the encoded data.
|
|
389
|
+
|
|
390
|
+
**Returns**: `number`
|
|
391
|
+
|
|
392
|
+
##### `CodecParameters.id`
|
|
393
|
+
|
|
394
|
+
Specific type of the encoded data (the codec used).
|
|
395
|
+
|
|
396
|
+
**Returns**: `number`
|
|
397
|
+
|
|
398
|
+
##### `CodecParameters.tag`
|
|
399
|
+
|
|
400
|
+
Additional information about the codec (corresponds to the AVI FOURCC).
|
|
401
|
+
|
|
402
|
+
**Returns**: `number`
|
|
403
|
+
|
|
404
|
+
##### `CodecParameters.bitRate`
|
|
405
|
+
|
|
406
|
+
Gets the bit rate.
|
|
407
|
+
|
|
408
|
+
**Returns**: `number`
|
|
409
|
+
|
|
410
|
+
##### `CodecParameters.bitsPerCodedSample`
|
|
411
|
+
|
|
412
|
+
Gets the bits per coded sample.
|
|
413
|
+
|
|
414
|
+
**Returns**: `number`
|
|
415
|
+
|
|
416
|
+
##### `CodecParameters.bitsPerRawSample`
|
|
417
|
+
|
|
418
|
+
Gets the bits per raw sample.
|
|
419
|
+
|
|
420
|
+
**Returns**: `number`
|
|
421
|
+
|
|
422
|
+
##### `CodecParameters.sampleRate`
|
|
423
|
+
|
|
424
|
+
Gets the sample rate for audio codecs.
|
|
425
|
+
|
|
426
|
+
**Returns**: `number`
|
|
427
|
+
|
|
428
|
+
##### `CodecParameters.frameRate`
|
|
429
|
+
|
|
430
|
+
Gets the frame rate for video codecs.
|
|
431
|
+
|
|
432
|
+
**Returns**: `Rational`
|
|
433
|
+
|
|
434
|
+
##### `CodecParameters.extraData`
|
|
435
|
+
|
|
436
|
+
Out-of-band global headers that may be used by some codecs.
|
|
437
|
+
|
|
438
|
+
**Returns**: `Buffer`
|
|
439
|
+
|
|
440
|
+
##### `CodecParameters.profile`
|
|
441
|
+
|
|
442
|
+
Codec-specific bitstream restrictions that the stream conforms to.
|
|
443
|
+
|
|
444
|
+
**Returns**: `number`
|
|
445
|
+
|
|
446
|
+
##### `CodecParameters.level`
|
|
447
|
+
|
|
448
|
+
Codec-specific bitstream restrictions that the stream conforms to.
|
|
449
|
+
|
|
450
|
+
**Returns**: `number`
|
|
451
|
+
|
|
452
|
+
##### `CodecParameters.format`
|
|
453
|
+
|
|
454
|
+
Video: the pixel format, the value corresponds to AVPixelFormat.
|
|
455
|
+
Audio: the sample format, the value corresponds to AVSampleFormat.
|
|
456
|
+
|
|
457
|
+
**Returns**: `number`
|
|
458
|
+
|
|
459
|
+
##### `CodecParameters.nbChannels`
|
|
460
|
+
|
|
461
|
+
Number of channels in the layout.
|
|
462
|
+
|
|
463
|
+
**Returns**: `number`
|
|
464
|
+
|
|
465
|
+
##### `CodecParameters.channelLayout`
|
|
466
|
+
|
|
467
|
+
Gets or sets the channel layout, see `ffmpeg.constants.channelLayouts`
|
|
468
|
+
|
|
469
|
+
**Returns**: `ChannelLayout`
|
|
470
|
+
|
|
471
|
+
##### `CodecParameters.blockAlign`
|
|
472
|
+
|
|
473
|
+
Audio only. The number of bytes per coded audio frame, required by some
|
|
474
|
+
formats.
|
|
475
|
+
|
|
476
|
+
Corresponds to `nBlockAlign` in `WAVEFORMATEX`.
|
|
477
|
+
|
|
478
|
+
**Returns**: `number`
|
|
479
|
+
|
|
480
|
+
##### `CodecParameters.initalPadding`
|
|
481
|
+
|
|
482
|
+
Audio only. The amount of padding (in samples) inserted by the encoder at the beginning of the audio. I.e. this number of leading decoded samples must be discarded by the caller to get the original audio without leading padding.
|
|
483
|
+
|
|
484
|
+
**Returns**: `number`
|
|
485
|
+
|
|
486
|
+
##### `CodecParameters.trailingPadding`
|
|
487
|
+
|
|
488
|
+
Audio only. The amount of padding (in samples) appended by the encoder to the end of the audio. I.e. this number of decoded samples must be discarded by the caller from the end of the stream to get the original audio without any trailing padding.
|
|
489
|
+
|
|
490
|
+
##### `CodecParameters.seekPreroll`
|
|
491
|
+
|
|
492
|
+
Audio only. Number of samples to skip after a discontinuity.
|
|
493
|
+
|
|
494
|
+
**Returns**: `number`
|
|
495
|
+
|
|
496
|
+
##### `CodecParameters.sampleAspectRatio`
|
|
497
|
+
|
|
498
|
+
Video only. The aspect ratio (width / height) which a single pixel should have when displayed.
|
|
499
|
+
|
|
500
|
+
When the aspect ratio is unknown / undefined, the numerator should be set to 0 (the denominator may have any value).
|
|
501
|
+
|
|
502
|
+
**Returns**: `number`
|
|
503
|
+
|
|
504
|
+
##### `CodecParameters.videoDelay`
|
|
505
|
+
|
|
506
|
+
Video only. Number of delayed frames.
|
|
507
|
+
|
|
508
|
+
**Returns**: `number`
|
|
509
|
+
|
|
510
|
+
#### Methods
|
|
511
|
+
|
|
512
|
+
##### `CodecParameters.fromContext(context)`
|
|
513
|
+
|
|
514
|
+
Copies parameters from a codec context.
|
|
515
|
+
|
|
516
|
+
Parameters:
|
|
517
|
+
|
|
518
|
+
- `context` (`CodecContext`): The codec context
|
|
519
|
+
|
|
520
|
+
**Returns**: `void`
|
|
521
|
+
|
|
522
|
+
##### `CodecParameters.toContext(context)`
|
|
523
|
+
|
|
524
|
+
Copies parameters to a codec context.
|
|
525
|
+
|
|
526
|
+
Parameters:
|
|
527
|
+
|
|
528
|
+
- `context` (`CodecContext`): The codec context
|
|
529
|
+
|
|
530
|
+
**Returns**: `void`
|
|
531
|
+
|
|
532
|
+
### `InputFormat`
|
|
533
|
+
|
|
534
|
+
The `InputFormat` API provides functionality to specify input format for media sources.
|
|
535
|
+
|
|
536
|
+
```js
|
|
537
|
+
const format = new ffmpeg.InputFormat([name])
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
Parameters:
|
|
541
|
+
|
|
542
|
+
- `name` (`string`, optional): The input format name. Defaults to a platform-specific value:
|
|
543
|
+
- `darwin`, `ios`: ``'avfoundation'`
|
|
544
|
+
- `linux`: `'v4l2'`
|
|
545
|
+
- `win32`: `'dshow'`
|
|
546
|
+
|
|
547
|
+
**Returns**: A new `InputFormat` instance
|
|
548
|
+
|
|
549
|
+
#### Methods
|
|
550
|
+
|
|
551
|
+
##### `InputFormat.destroy()`
|
|
552
|
+
|
|
553
|
+
Destroys the `InputFormat` and frees all associated resources. Automatically called when the object is managed by a `using` declaration.
|
|
554
|
+
|
|
555
|
+
**Returns**: `void`
|
|
556
|
+
|
|
557
|
+
### `OutputFormat`
|
|
558
|
+
|
|
559
|
+
The `OutputFormat` API provides functionality to specify output format for media files.
|
|
560
|
+
|
|
561
|
+
```js
|
|
562
|
+
const format = new ffmpeg.OutputFormat(name)
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
Parameters:
|
|
566
|
+
|
|
567
|
+
- `name` (`string`): The output format name (e.g., `'mp4'`, `'avi'`, `'mov'`)
|
|
568
|
+
|
|
569
|
+
**Returns**: A new `OutputFormat` instance
|
|
570
|
+
|
|
571
|
+
#### Methods
|
|
572
|
+
|
|
573
|
+
##### `OutputFormat.destroy()`
|
|
574
|
+
|
|
575
|
+
Destroys the `OutputFormat` and frees all associated resources. Automatically called when the object is managed by a `using` declaration.
|
|
576
|
+
|
|
577
|
+
**Returns**: `void`
|
|
578
|
+
|
|
579
|
+
### `Frame`
|
|
580
|
+
|
|
581
|
+
This structure describes decoded (raw) audio or video data.
|
|
582
|
+
|
|
583
|
+
```js
|
|
584
|
+
const frame = new ffmpeg.Frame()
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
**Returns**: A new `Frame` instance
|
|
588
|
+
|
|
589
|
+
#### Properties
|
|
590
|
+
|
|
591
|
+
##### `Frame.width`
|
|
592
|
+
|
|
593
|
+
Gets or sets the frame width.
|
|
594
|
+
|
|
595
|
+
**Returns**: `number`
|
|
596
|
+
|
|
597
|
+
##### `Frame.height`
|
|
598
|
+
|
|
599
|
+
Gets or sets the frame height.
|
|
600
|
+
|
|
601
|
+
**Returns**: `number`
|
|
602
|
+
|
|
603
|
+
##### `Frame.pixelFormat`
|
|
604
|
+
|
|
605
|
+
Gets or sets the pixel format.
|
|
606
|
+
|
|
607
|
+
**Returns**: `number` (pixel format constant)
|
|
608
|
+
|
|
609
|
+
##### `Frame.format`
|
|
610
|
+
|
|
611
|
+
Gets or sets the sample format for audio frames.
|
|
612
|
+
|
|
613
|
+
**Returns**: `number` (sample format constant)
|
|
614
|
+
|
|
615
|
+
##### `Frame.channelLayout`
|
|
616
|
+
|
|
617
|
+
Gets or sets the channel layout for audio frames.
|
|
618
|
+
|
|
619
|
+
**Returns**: `number` (channel layout constant)
|
|
620
|
+
|
|
621
|
+
##### `Frame.nbSamples`
|
|
622
|
+
|
|
623
|
+
Gets or sets the number of audio samples.
|
|
624
|
+
|
|
625
|
+
**Returns**: `number`
|
|
626
|
+
|
|
627
|
+
#### Methods
|
|
628
|
+
|
|
629
|
+
##### `Frame.alloc()`
|
|
630
|
+
|
|
631
|
+
Allocates memory for the frame data.
|
|
632
|
+
|
|
633
|
+
**Returns**: `void`
|
|
634
|
+
|
|
635
|
+
##### `Frame.destroy()`
|
|
636
|
+
|
|
637
|
+
Destroys the `Frame` and frees all associated resources. Automatically called when the object is managed by a `using` declaration.
|
|
638
|
+
|
|
639
|
+
**Returns**: `void`
|
|
640
|
+
|
|
641
|
+
### `Packet`
|
|
642
|
+
|
|
643
|
+
This structure stores compressed data. It is typically exported by demuxers and then passed as input to decoders, or received as output from encoders and then passed to muxers.
|
|
644
|
+
|
|
645
|
+
```js
|
|
646
|
+
const packet = new ffmpeg.Packet([buffer])
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
Parameters:
|
|
650
|
+
|
|
651
|
+
- `buffer` (`Buffer`, optional): Initial packet data
|
|
652
|
+
|
|
653
|
+
**Returns**: A new `Packet` instance
|
|
654
|
+
|
|
655
|
+
#### Properties
|
|
656
|
+
|
|
657
|
+
##### `Packet.data`
|
|
658
|
+
|
|
659
|
+
Gets the packet data buffer.
|
|
660
|
+
|
|
661
|
+
**Returns**: `Buffer`
|
|
662
|
+
|
|
663
|
+
##### `Packet.streamIndex`
|
|
664
|
+
|
|
665
|
+
Gets the stream index this packet belongs to.
|
|
666
|
+
|
|
667
|
+
**Returns**: `number`
|
|
668
|
+
|
|
669
|
+
#### Methods
|
|
670
|
+
|
|
671
|
+
##### `Packet.unref()`
|
|
672
|
+
|
|
673
|
+
Decrements the reference count and unreferences the packet.
|
|
674
|
+
|
|
675
|
+
**Returns**: `void`
|
|
676
|
+
|
|
677
|
+
##### `Packet.destroy()`
|
|
678
|
+
|
|
679
|
+
Destroys the `Packet` and frees all associated resources. Automatically called when the object is managed by a `using` declaration.
|
|
680
|
+
|
|
681
|
+
**Returns**: `void`
|
|
682
|
+
|
|
683
|
+
### `Image`
|
|
684
|
+
|
|
685
|
+
The `Image` API provides functionality to create and manage image buffers.
|
|
686
|
+
|
|
687
|
+
```js
|
|
688
|
+
const image = new ffmpeg.Image(pixelFormat, width, height[, align])
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
Parameters:
|
|
692
|
+
|
|
693
|
+
- `pixelFormat` (`number` | `string`): The pixel format
|
|
694
|
+
- `width` (`number`): The image width in pixels
|
|
695
|
+
- `height` (`number`): The image height in pixels
|
|
696
|
+
- `align` (`number`, optional): Memory alignment. Defaults to 1
|
|
697
|
+
|
|
698
|
+
**Returns**: A new `Image` instance
|
|
699
|
+
|
|
700
|
+
#### Properties
|
|
701
|
+
|
|
702
|
+
##### `Image.pixelFormat`
|
|
703
|
+
|
|
704
|
+
Gets the pixel format.
|
|
705
|
+
|
|
706
|
+
**Returns**: `number`
|
|
707
|
+
|
|
708
|
+
##### `Image.width`
|
|
709
|
+
|
|
710
|
+
Gets the image width.
|
|
711
|
+
|
|
712
|
+
**Returns**: `number`
|
|
713
|
+
|
|
714
|
+
##### `Image.height`
|
|
715
|
+
|
|
716
|
+
Gets the image height.
|
|
717
|
+
|
|
718
|
+
**Returns**: `number`
|
|
719
|
+
|
|
720
|
+
##### `Image.align`
|
|
721
|
+
|
|
722
|
+
Gets the memory alignment.
|
|
723
|
+
|
|
724
|
+
**Returns**: `number`
|
|
725
|
+
|
|
726
|
+
##### `Image.data`
|
|
727
|
+
|
|
728
|
+
Gets the image data buffer.
|
|
729
|
+
|
|
730
|
+
**Returns**: `Buffer`
|
|
731
|
+
|
|
732
|
+
#### Methods
|
|
733
|
+
|
|
734
|
+
##### `Image.fill(frame)`
|
|
735
|
+
|
|
736
|
+
Fills a frame with the image data.
|
|
737
|
+
|
|
738
|
+
Parameters:
|
|
739
|
+
|
|
740
|
+
- `frame` (`Frame`): The frame to fill
|
|
741
|
+
|
|
742
|
+
**Returns**: void
|
|
743
|
+
|
|
744
|
+
##### `Image.read(frame)`
|
|
745
|
+
|
|
746
|
+
Reads image data from a frame into the image buffer.
|
|
747
|
+
|
|
748
|
+
Parameters:
|
|
749
|
+
|
|
750
|
+
- `frame` (`Frame`): The frame to read from
|
|
751
|
+
|
|
752
|
+
**Returns**: `void`
|
|
753
|
+
|
|
754
|
+
##### `Image.lineSize([plane])`
|
|
755
|
+
|
|
756
|
+
Gets the line size for a specific plane.
|
|
757
|
+
|
|
758
|
+
Parameters:
|
|
759
|
+
|
|
760
|
+
- `plane` (`number`, optional): Plane index. Defaults to 0
|
|
761
|
+
|
|
762
|
+
**Returns**: `number`
|
|
763
|
+
|
|
764
|
+
#### Static methods
|
|
765
|
+
|
|
766
|
+
##### `Image.lineSize(pixelFormat, width[, plane])`
|
|
767
|
+
|
|
768
|
+
Static method to get line size for a pixel format.
|
|
769
|
+
|
|
770
|
+
Parameters:
|
|
771
|
+
|
|
772
|
+
- `pixelFormat` (`number` | `string`): The pixel format
|
|
773
|
+
- `width` (`number`): The image width
|
|
774
|
+
- `plane` (`number`, optional): Plane index. Defaults to 0
|
|
775
|
+
|
|
776
|
+
**Returns**: `number`
|
|
777
|
+
|
|
778
|
+
### `Rational`
|
|
779
|
+
|
|
780
|
+
The `Rational` API provides functionality to represent rational numbers (fractions).
|
|
781
|
+
|
|
782
|
+
```js
|
|
783
|
+
const rational = new ffmpeg.Rational(numerator, denominator)
|
|
784
|
+
```
|
|
785
|
+
|
|
786
|
+
Parameters:
|
|
787
|
+
|
|
788
|
+
- `numerator` (`number`): The numerator
|
|
789
|
+
- `denominator` (`number`): The denominator
|
|
790
|
+
|
|
791
|
+
**Returns**: A new `Rational` instance
|
|
792
|
+
|
|
793
|
+
#### Properties
|
|
794
|
+
|
|
795
|
+
##### `Rational.numerator`
|
|
796
|
+
|
|
797
|
+
Gets the numerator.
|
|
798
|
+
|
|
799
|
+
**Returns**: `number`
|
|
800
|
+
|
|
801
|
+
##### `Rational.denominator`
|
|
802
|
+
|
|
803
|
+
Gets the denominator.
|
|
804
|
+
|
|
805
|
+
**Returns**: `number`
|
|
806
|
+
|
|
807
|
+
##### `Rational.valid`
|
|
808
|
+
|
|
809
|
+
Returns if true if rational describes a non-zero & non-negative quantity.
|
|
810
|
+
|
|
811
|
+
**Returns**: `number`
|
|
812
|
+
|
|
813
|
+
##### `Rational.uninitialized`
|
|
814
|
+
|
|
815
|
+
Returns if true when is not set.
|
|
816
|
+
|
|
817
|
+
**Returns**: `number`
|
|
818
|
+
|
|
819
|
+
##### `Rational.toNumber()`
|
|
820
|
+
|
|
821
|
+
see `av_q2d()`
|
|
822
|
+
|
|
823
|
+
**Returns**: `number`
|
|
824
|
+
|
|
825
|
+
##### `static Rational.from(number)`
|
|
826
|
+
|
|
827
|
+
see `av_d2q()`
|
|
828
|
+
|
|
829
|
+
**Returns**: `Rational`
|
|
830
|
+
|
|
831
|
+
##### `Rational.rescaleQ(number, timebaseA, timebaseB)`
|
|
832
|
+
|
|
833
|
+
see `av_rescale_q()`
|
|
834
|
+
|
|
835
|
+
**Returns**: `number`
|
|
836
|
+
|
|
837
|
+
### `Stream`
|
|
838
|
+
|
|
839
|
+
The `Stream` API provides functionality to access media stream information and create decoders/encoders.
|
|
840
|
+
|
|
841
|
+
```js
|
|
842
|
+
const stream = new ffmpeg.Stream(handle)
|
|
843
|
+
```
|
|
844
|
+
|
|
845
|
+
Parameters:
|
|
846
|
+
|
|
847
|
+
- `handle` (`ArrayBuffer`): Internal stream handle
|
|
848
|
+
|
|
849
|
+
**Returns**: A new `Stream` instance
|
|
850
|
+
|
|
851
|
+
> Streams are typically obtained from format contexts: `const stream = format.streams[0]`
|
|
852
|
+
|
|
853
|
+
#### Properties
|
|
854
|
+
|
|
855
|
+
##### `Stream.codecParameters`
|
|
856
|
+
|
|
857
|
+
Gets the codec parameters for this stream.
|
|
858
|
+
|
|
859
|
+
**Returns**: `CodecParameters` instance
|
|
860
|
+
|
|
861
|
+
##### `Stream.codec`
|
|
862
|
+
|
|
863
|
+
Gets the codec for this stream
|
|
864
|
+
|
|
865
|
+
**Returns**: `Codec` instance
|
|
866
|
+
|
|
867
|
+
#### Methods
|
|
868
|
+
|
|
869
|
+
##### `Stream.decoder()`
|
|
870
|
+
|
|
871
|
+
Creates and opens a decoder for this stream.
|
|
872
|
+
|
|
873
|
+
**Returns**: `CodecContext` instance
|
|
874
|
+
|
|
875
|
+
##### `Stream.encoder()`
|
|
876
|
+
|
|
877
|
+
Creates and opens an encoder for this stream.
|
|
878
|
+
|
|
879
|
+
**Returns**: `CodecContext` instance
|
|
880
|
+
|
|
881
|
+
### `Resampler`
|
|
882
|
+
|
|
883
|
+
The `Resampler` API provides functionality to convert audio between different sample rates, channel layouts, and sample formats.
|
|
884
|
+
|
|
885
|
+
```js
|
|
886
|
+
const resampler = new ffmpeg.Resampler(
|
|
887
|
+
inputSampleRate,
|
|
888
|
+
inputChannelLayout,
|
|
889
|
+
inputSampleFormat,
|
|
890
|
+
outputSampleRate,
|
|
891
|
+
outputChannelLayout,
|
|
892
|
+
outputSampleFormat
|
|
893
|
+
)
|
|
894
|
+
```
|
|
895
|
+
|
|
896
|
+
Parameters:
|
|
897
|
+
|
|
898
|
+
- `inputSampleRate` (`number`): Input sample rate in Hz
|
|
899
|
+
- `inputChannelLayout` (`number`): Input channel layout constant
|
|
900
|
+
- `inputSampleFormat` (`number`): Input sample format constant
|
|
901
|
+
- `outputSampleRate` (`number`): Output sample rate in Hz
|
|
902
|
+
- `outputChannelLayout` (`number`): Output channel layout constant
|
|
903
|
+
- `outputSampleFormat` (`number`): Output sample format constant
|
|
904
|
+
|
|
905
|
+
**Returns**: A new `Resampler` instance
|
|
906
|
+
|
|
907
|
+
#### Properties
|
|
908
|
+
|
|
909
|
+
##### `Resampler.inputSampleRate`
|
|
910
|
+
|
|
911
|
+
Gets the input sample rate.
|
|
912
|
+
|
|
913
|
+
**Returns**: `number`
|
|
914
|
+
|
|
915
|
+
##### `Resampler.outputSampleRate`
|
|
916
|
+
|
|
917
|
+
Gets the output sample rate.
|
|
918
|
+
|
|
919
|
+
**Returns**: `number`
|
|
920
|
+
|
|
921
|
+
##### `Resampler.delay`
|
|
922
|
+
|
|
923
|
+
Gets the resampler delay in samples.
|
|
924
|
+
|
|
925
|
+
**Returns**: `number`
|
|
926
|
+
|
|
927
|
+
#### Methods
|
|
928
|
+
|
|
929
|
+
##### `Resampler.convert(inputFrame, outputFrame)`
|
|
930
|
+
|
|
931
|
+
Converts audio data from input frame to output frame.
|
|
932
|
+
|
|
933
|
+
Parameters:
|
|
934
|
+
|
|
935
|
+
- `inputFrame` (`Frame`): The input audio frame
|
|
936
|
+
- `outputFrame` (`Frame`): The output audio frame
|
|
937
|
+
|
|
938
|
+
**Returns**: `number` of samples converted
|
|
939
|
+
|
|
940
|
+
##### `Resampler.flush(outputFrame)`
|
|
941
|
+
|
|
942
|
+
Flushes any remaining samples in the resampler.
|
|
943
|
+
|
|
944
|
+
Parameters:
|
|
945
|
+
|
|
946
|
+
- `outputFrame` (`Frame`): The output audio frame
|
|
947
|
+
|
|
948
|
+
**Returns**: `number` of samples flushed
|
|
949
|
+
|
|
950
|
+
##### `Resampler.destroy()`
|
|
951
|
+
|
|
952
|
+
Destroys the `Resampler` and frees all associated resources. Automatically called when the object is managed by a `using` declaration.
|
|
953
|
+
|
|
954
|
+
**Returns**: `void`
|
|
955
|
+
|
|
956
|
+
### `Scaler`
|
|
957
|
+
|
|
958
|
+
The `Scaler` API provides functionality to scale and convert video frames between different pixel formats and resolutions.
|
|
959
|
+
|
|
960
|
+
```js
|
|
961
|
+
const scaler = new ffmpeg.Scaler(
|
|
962
|
+
sourcePixelFormat,
|
|
963
|
+
sourceWidth,
|
|
964
|
+
sourceHeight,
|
|
965
|
+
targetPixelFormat,
|
|
966
|
+
targetWidth,
|
|
967
|
+
targetHeight
|
|
968
|
+
)
|
|
969
|
+
```
|
|
970
|
+
|
|
971
|
+
Parameters:
|
|
972
|
+
|
|
973
|
+
- `sourcePixelFormat` (`number` | `string`): Source pixel format
|
|
974
|
+
- `sourceWidth` (`number`): Source width in pixels
|
|
975
|
+
- `sourceHeight` (`number`): Source height in pixels
|
|
976
|
+
- `targetPixelFormat` (`number` | `string`): Target pixel format
|
|
977
|
+
- `targetWidth` (`number`): Target width in pixels
|
|
978
|
+
- `targetHeight` (`number`): Target height in pixels
|
|
979
|
+
|
|
980
|
+
**Returns**: A new `Scaler` instance
|
|
981
|
+
|
|
982
|
+
#### Methods
|
|
983
|
+
|
|
984
|
+
##### `Scaler.scale(source, target)`
|
|
985
|
+
|
|
986
|
+
Scales a source frame to a target frame.
|
|
987
|
+
|
|
988
|
+
Parameters:
|
|
989
|
+
|
|
990
|
+
- `source` (`Frame`): The source frame
|
|
991
|
+
- `target` (`Frame`): The target frame
|
|
992
|
+
|
|
993
|
+
**Returns**: `boolean` indicating success
|
|
994
|
+
|
|
995
|
+
##### `Scaler.scale(source, y, height, target)`
|
|
996
|
+
|
|
997
|
+
Scales a portion of a source frame to a target frame.
|
|
998
|
+
|
|
999
|
+
Parameters:
|
|
1000
|
+
|
|
1001
|
+
- `source` (`Frame`): The source frame
|
|
1002
|
+
- `y` (`number`): Starting Y coordinate
|
|
1003
|
+
- `height` (`number`): Height to scale
|
|
1004
|
+
- `target` (`Frame`): The target frame
|
|
1005
|
+
|
|
1006
|
+
**Returns**: `boolean` indicating success
|
|
1007
|
+
|
|
1008
|
+
##### `Scaler.destroy()`
|
|
1009
|
+
|
|
1010
|
+
Destroys the `Scaler` and frees all associated resources. Automatically called when the object is managed by a `using` declaration.
|
|
1011
|
+
|
|
1012
|
+
**Returns**: `void`
|
|
1013
|
+
|
|
1014
|
+
### `AudioFIFO`
|
|
1015
|
+
|
|
1016
|
+
The `AudioFIFO` API provides a first in first out buffer for audio samples. This is useful for buffering audio data between different processing stages.
|
|
1017
|
+
|
|
1018
|
+
```js
|
|
1019
|
+
const fifo = new ffmpeg.AudioFIFO(sampleFormat, channels, nbSamples)
|
|
1020
|
+
```
|
|
1021
|
+
|
|
1022
|
+
Parameters:
|
|
1023
|
+
|
|
1024
|
+
- `sampleFormat` (`number` | `string`): The audio sample format
|
|
1025
|
+
- `channels` (`number`): Number of audio channels
|
|
1026
|
+
- `nbSamples` (`number`): Initial buffer size in samples
|
|
1027
|
+
|
|
1028
|
+
**Returns**: A new `AudioFIFO` instance
|
|
1029
|
+
|
|
1030
|
+
Example:
|
|
1031
|
+
|
|
1032
|
+
```js
|
|
1033
|
+
const fifo = new ffmpeg.AudioFIFO(ffmpeg.constants.sampleFormats.S16, 2, 1024)
|
|
1034
|
+
```
|
|
1035
|
+
|
|
1036
|
+
#### Properties
|
|
1037
|
+
|
|
1038
|
+
##### `AudioFIFO.size`
|
|
1039
|
+
|
|
1040
|
+
Gets the number of samples currently in the FIFO.
|
|
1041
|
+
|
|
1042
|
+
**Returns**: `number`
|
|
1043
|
+
|
|
1044
|
+
##### `AudioFIFO.space`
|
|
1045
|
+
|
|
1046
|
+
Gets the number of samples that can be written to the FIFO.
|
|
1047
|
+
|
|
1048
|
+
**Returns**: `number`
|
|
1049
|
+
|
|
1050
|
+
#### Methods
|
|
1051
|
+
|
|
1052
|
+
##### `AudioFIFO.write(frame)`
|
|
1053
|
+
|
|
1054
|
+
Writes samples from a frame to the FIFO. The FIFO will automatically grow if needed.
|
|
1055
|
+
|
|
1056
|
+
Parameters:
|
|
1057
|
+
|
|
1058
|
+
- `frame` (`Frame`): The audio frame containing samples to write
|
|
1059
|
+
|
|
1060
|
+
**Returns**: `number` of samples written
|
|
1061
|
+
|
|
1062
|
+
##### `AudioFIFO.read(frame, nbSamples)`
|
|
1063
|
+
|
|
1064
|
+
Reads samples from the FIFO into a frame.
|
|
1065
|
+
|
|
1066
|
+
Parameters:
|
|
1067
|
+
|
|
1068
|
+
- `frame` (`Frame`): The frame to read samples into
|
|
1069
|
+
- `nbSamples` (`number`): Number of samples to read
|
|
1070
|
+
|
|
1071
|
+
**Returns**: `number` of samples actually read
|
|
1072
|
+
|
|
1073
|
+
##### `AudioFIFO.peek(frame, nbSamples)`
|
|
1074
|
+
|
|
1075
|
+
Reads samples from the FIFO without removing them.
|
|
1076
|
+
|
|
1077
|
+
Parameters:
|
|
1078
|
+
|
|
1079
|
+
- `frame` (`Frame`): The frame to read samples into
|
|
1080
|
+
- `nbSamples` (`number`): Number of samples to peek
|
|
1081
|
+
|
|
1082
|
+
**Returns**: `number` of samples peeked
|
|
1083
|
+
|
|
1084
|
+
##### `AudioFIFO.drain(nbSamples)`
|
|
1085
|
+
|
|
1086
|
+
Removes samples from the FIFO without reading them.
|
|
1087
|
+
|
|
1088
|
+
Parameters:
|
|
1089
|
+
|
|
1090
|
+
- `nbSamples` (`number`): Number of samples to drain
|
|
1091
|
+
|
|
1092
|
+
**Returns**: `void`
|
|
1093
|
+
|
|
1094
|
+
##### `AudioFIFO.reset()`
|
|
1095
|
+
|
|
1096
|
+
Resets the FIFO to empty state.
|
|
1097
|
+
|
|
1098
|
+
**Returns**: `void`
|
|
1099
|
+
|
|
1100
|
+
##### `AudioFIFO.destroy()`
|
|
1101
|
+
|
|
1102
|
+
Destroys the `AudioFIFO` and frees all associated resources. Automatically called when the object is managed by a `using` declaration.
|
|
1103
|
+
|
|
1104
|
+
**Returns**: `void`
|
|
1105
|
+
|
|
9
1106
|
## License
|
|
10
1107
|
|
|
11
1108
|
Apache-2.0
|