bare-ffmpeg 1.0.0-26 → 1.0.0-27

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/README.md CHANGED
@@ -407,6 +407,20 @@ Gets or sets the frame height for video codecs.
407
407
 
408
408
  **Returns**: `number`
409
409
 
410
+ ##### `CodecContext.frameSize`
411
+
412
+ Gets the number of samples per channel in an audio frame.
413
+
414
+ **Returns**: `number`
415
+
416
+ ##### `CodecContext.frameNum`
417
+
418
+ When encoding this gets the total number of frames passed to the encoder so far.
419
+
420
+ When decoding this gets the total number of frames returned from the decoder so far.
421
+
422
+ **Returns**: `number`
423
+
410
424
  #### Methods
411
425
 
412
426
  ##### `CodecContext.open([options])`
@@ -459,6 +473,52 @@ Parameters:
459
473
 
460
474
  **Returns**: `boolean` indicating if a packet was received
461
475
 
476
+ ##### `CodecContext.getSupportedConfig(config)`
477
+
478
+ Gets the supported values for a codec configuration option.
479
+
480
+ Parameters:
481
+
482
+ - `config` (`number`): The configuration type from `ffmpeg.constants.codecConfig`
483
+
484
+ **Returns**:
485
+
486
+ - For `PIX_FORMAT`, `SAMPLE_FORMAT`, `COLOR_RANGE`, `COLOR_SPACE`: `Int32Array` of supported values (all valid values are included if the codec has no restrictions)
487
+ - For `SAMPLE_RATE`: `Int32Array` of supported sample rates or `null` if the codec accepts any valid sample rate
488
+ - For `FRAME_RATE`: Array of `Rational` instances or `null` if the codec accepts any valid frame rate
489
+ - For `CHANNEL_LAYOUT`: Array of `ChannelLayout` instances or `null` if the codec accepts any valid channel layout
490
+
491
+ **Throws**: Error if the config type is not applicable to this codec (e.g., asking for pixel formats from an audio codec)
492
+
493
+ Examples:
494
+
495
+ ```js
496
+ const codecCtx = new ffmpeg.CodecContext(ffmpeg.Codec.AV1.encoder)
497
+
498
+ const pixelFormats = codecCtx.getSupportedConfig(
499
+ ffmpeg.constants.codecConfig.PIX_FORMAT
500
+ )
501
+ if (pixelFormats) {
502
+ console.log('Supported pixel formats:', pixelFormats)
503
+ }
504
+
505
+ const frameRates = codecCtx.getSupportedConfig(
506
+ ffmpeg.constants.codecConfig.FRAME_RATE
507
+ )
508
+ if (frameRates) {
509
+ frameRates.forEach((rate) => {
510
+ console.log(`${rate.toNumber()} fps`)
511
+ })
512
+ }
513
+
514
+ const layouts = codecCtx.getSupportedConfig(
515
+ ffmpeg.constants.codecConfig.CHANNEL_LAYOUT
516
+ )
517
+ if (layouts) {
518
+ console.log('Supported channel layouts:', layouts)
519
+ }
520
+ ```
521
+
462
522
  ##### `CodecContext.destroy()`
463
523
 
464
524
  Destroys the `CodecContext` and frees all associated resources. Automatically called when the object is managed by a `using` declaration.
@@ -1200,6 +1260,94 @@ Destroys the `Scaler` and frees all associated resources. Automatically called w
1200
1260
 
1201
1261
  **Returns**: `void`
1202
1262
 
1263
+ ### `Filter`
1264
+
1265
+ The `Filter` API provides access to FFmpeg filters by name.
1266
+
1267
+ ```js
1268
+ const filter = new ffmpeg.Filter(name)
1269
+ ```
1270
+
1271
+ Parameters:
1272
+
1273
+ - `name` (`string`): The filter name (e.g., `'scale'`, `'buffer'`, `'overlay'`)
1274
+
1275
+ **Returns**: A new `Filter` instance
1276
+
1277
+ #### Example
1278
+
1279
+ ```js
1280
+ const filter = new ffmpeg.Filter('buffer')
1281
+ ```
1282
+
1283
+ ### `FilterGraph`
1284
+
1285
+ The `FilterGraph` API provides functionality to create and manage complex filter chains for audio and video processing.
1286
+
1287
+ ```js
1288
+ const graph = new ffmpeg.FilterGraph()
1289
+ ```
1290
+
1291
+ **Returns**: A new `FilterGraph` instance
1292
+
1293
+ #### Methods
1294
+
1295
+ ##### `FilterGraph.createFilter(context, filter, name, args)`
1296
+
1297
+ Creates a filter within the filter graph with the specified parameters.
1298
+
1299
+ Parameters:
1300
+
1301
+ - `context` (`FilterContext`): The filter context to associate with this filter
1302
+ - `filter` (`Filter`): The filter to create (e.g., `new ffmpeg.Filter('buffer')`)
1303
+ - `name` (`string`): A unique name for this filter instance
1304
+ - `args` (`object` | `undefined`): Filter-specific arguments
1305
+ - `width` (`number`): Video width in pixels
1306
+ - `height` (`number`): Video height in pixels
1307
+ - `pixelFormat` (`number`): Pixel format constant
1308
+ - `timeBase` (`Rational`): Time base for the filter
1309
+ - `aspectRatio` (`Rational`): Pixel aspect ratio
1310
+
1311
+ **Returns**: `void`
1312
+
1313
+ ```js
1314
+ using graph = new ffmpeg.FilterGraph()
1315
+ const context = new ffmpeg.FilterContext()
1316
+ const filter = new ffmpeg.Filter('buffer')
1317
+
1318
+ graph.createFilter(context, filter, 'in', {
1319
+ width: 1920,
1320
+ height: 1080,
1321
+ pixelFormat: ffmpeg.constants.pixelFormats.RGB24,
1322
+ timeBase: new ffmpeg.Rational(1, 30),
1323
+ aspectRatio: new ffmpeg.Rational(1, 1)
1324
+ })
1325
+ ```
1326
+
1327
+ ##### `FilterGraph.parse(filterDescription, inputs, outputs)`
1328
+
1329
+ Parses a filter description string and applies it to the filter graph.
1330
+
1331
+ Parameters:
1332
+
1333
+ - `filterDescription` (`string`): The filter description (e.g., `'negate'`, `'scale=640:480'`)
1334
+ - `inputs` (`FilterInOut`): Input filter endpoints
1335
+ - `outputs` (`FilterInOut`): Output filter endpoints
1336
+
1337
+ **Returns**: `void`
1338
+
1339
+ ##### `FilterGraph.configure()`
1340
+
1341
+ Configures the filter graph and validates all connections.
1342
+
1343
+ **Returns**: `void`
1344
+
1345
+ ##### `FilterGraph.destroy()`
1346
+
1347
+ Destroys the `FilterGraph` and frees all associated resources including any created filters. Automatically called when the object is managed by a `using` declaration.
1348
+
1349
+ **Returns**: `void`
1350
+
1203
1351
  ### `AudioFIFO`
1204
1352
 
1205
1353
  The `AudioFIFO` API provides a first in first out buffer for audio samples. This is useful for buffering audio data between different processing stages.
@@ -1292,6 +1440,84 @@ Destroys the `AudioFIFO` and frees all associated resources. Automatically calle
1292
1440
 
1293
1441
  **Returns**: `void`
1294
1442
 
1443
+ ### `FilterInOut`
1444
+
1445
+ The `FilterInOut` API provides functionality to represent input and output pads for FFmpeg filter graphs.
1446
+
1447
+ ```js
1448
+ const filterInOut = new ffmpeg.FilterInOut()
1449
+ ```
1450
+
1451
+ **Returns**: A new `FilterInOut` instance
1452
+
1453
+ > **Note**: FilterInOut objects form a linked list structure in FFmpeg. When destroying a FilterInOut that has a `next` reference, the entire chain is automatically freed. Only destroy the head of the chain to avoid double-free errors.
1454
+
1455
+ #### Properties
1456
+
1457
+ ##### `FilterInOut.name`
1458
+
1459
+ Gets or sets the name identifier for this input/output pad.
1460
+
1461
+ **Returns**: `string` or `undefined` if not set
1462
+
1463
+ ```js
1464
+ const filterInOut = new ffmpeg.FilterInOut()
1465
+ filterInOut.name = 'input'
1466
+ console.log(filterInOut.name) // 'input'
1467
+ ```
1468
+
1469
+ ##### `FilterInOut.padIdx`
1470
+
1471
+ Gets or sets the pad index within the filter context.
1472
+
1473
+ **Returns**: `number`
1474
+
1475
+ ```js
1476
+ filterInOut.padIdx = 0
1477
+ console.log(filterInOut.padIdx) // 0
1478
+ ```
1479
+
1480
+ ##### `FilterInOut.filterContext`
1481
+
1482
+ Gets or sets the filter context associated with this input/output pad.
1483
+
1484
+ **Returns**: `FilterContext` instance or `null` if not set
1485
+
1486
+ > **Note**: FilterContext must be created through FilterGraph operations before it can be used effectively.
1487
+
1488
+ ##### `FilterInOut.next`
1489
+
1490
+ Gets or sets the next FilterInOut in the linked list chain.
1491
+
1492
+ **Returns**: `FilterInOut` instance or `null` if this is the last in the chain
1493
+
1494
+ ```js
1495
+ const input = new ffmpeg.FilterInOut()
1496
+ const output = new ffmpeg.FilterInOut()
1497
+ output.name = 'output'
1498
+
1499
+ input.next = output
1500
+ console.log(input.next.name) // 'output'
1501
+ ```
1502
+
1503
+ #### Methods
1504
+
1505
+ ##### `FilterInOut.destroy()`
1506
+
1507
+ Destroys the `FilterInOut` and frees all associated resources. **Important**: This automatically frees the entire linked list chain via FFmpeg's `avfilter_inout_free()`.
1508
+
1509
+ **Returns**: `void`
1510
+
1511
+ ```js
1512
+ const head = new ffmpeg.FilterInOut()
1513
+ const next = new ffmpeg.FilterInOut()
1514
+ head.next = next
1515
+
1516
+ // Only destroy the head - 'next' is automatically freed
1517
+ head.destroy()
1518
+ // DO NOT call next.destroy() - causes double-free error
1519
+ ```
1520
+
1295
1521
  ## License
1296
1522
 
1297
1523
  Apache-2.0