node-av 5.2.0-beta.2 → 5.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 (105) hide show
  1. package/README.md +120 -66
  2. package/build_mac_local.sh +69 -0
  3. package/dist/api/bitstream-filter.d.ts +20 -1
  4. package/dist/api/bitstream-filter.js +11 -1
  5. package/dist/api/bitstream-filter.js.map +1 -1
  6. package/dist/api/decoder.d.ts +98 -2
  7. package/dist/api/decoder.js +17 -2
  8. package/dist/api/decoder.js.map +1 -1
  9. package/dist/api/demuxer.d.ts +233 -4
  10. package/dist/api/demuxer.js +184 -21
  11. package/dist/api/demuxer.js.map +1 -1
  12. package/dist/api/device.d.ts +586 -0
  13. package/dist/api/device.js +961 -0
  14. package/dist/api/device.js.map +1 -0
  15. package/dist/api/encoder.d.ts +101 -2
  16. package/dist/api/encoder.js +17 -2
  17. package/dist/api/encoder.js.map +1 -1
  18. package/dist/api/filter-complex.d.ts +54 -2
  19. package/dist/api/filter-complex.js +1 -1
  20. package/dist/api/filter-complex.js.map +1 -1
  21. package/dist/api/filter.d.ts +95 -1
  22. package/dist/api/filter.js +12 -2
  23. package/dist/api/filter.js.map +1 -1
  24. package/dist/api/fmp4-stream.d.ts +5 -4
  25. package/dist/api/fmp4-stream.js +19 -7
  26. package/dist/api/fmp4-stream.js.map +1 -1
  27. package/dist/api/hardware.d.ts +17 -1
  28. package/dist/api/hardware.js +3 -4
  29. package/dist/api/hardware.js.map +1 -1
  30. package/dist/api/index.d.ts +12 -12
  31. package/dist/api/index.js +2 -0
  32. package/dist/api/index.js.map +1 -1
  33. package/dist/api/io-stream.d.ts +188 -6
  34. package/dist/api/io-stream.js +167 -16
  35. package/dist/api/io-stream.js.map +1 -1
  36. package/dist/api/muxer.d.ts +184 -26
  37. package/dist/api/muxer.js +79 -15
  38. package/dist/api/muxer.js.map +1 -1
  39. package/dist/api/pipeline.d.ts +75 -21
  40. package/dist/api/pipeline.js +40 -12
  41. package/dist/api/pipeline.js.map +1 -1
  42. package/dist/api/rtp-stream.d.ts +15 -4
  43. package/dist/api/rtp-stream.js +29 -7
  44. package/dist/api/rtp-stream.js.map +1 -1
  45. package/dist/api/utilities/index.d.ts +2 -2
  46. package/dist/api/utilities/index.js +2 -2
  47. package/dist/api/utilities/index.js.map +1 -1
  48. package/dist/api/webrtc-stream.d.ts +9 -9
  49. package/dist/api/webrtc-stream.js +26 -12
  50. package/dist/api/webrtc-stream.js.map +1 -1
  51. package/dist/constants/channel-layouts.d.ts +2 -0
  52. package/dist/constants/channel-layouts.js +22 -20
  53. package/dist/constants/channel-layouts.js.map +1 -1
  54. package/dist/constants/constants.d.ts +10 -5
  55. package/dist/constants/constants.js +13 -8
  56. package/dist/constants/constants.js.map +1 -1
  57. package/dist/constants/decoders.d.ts +1 -0
  58. package/dist/constants/decoders.js +2 -1
  59. package/dist/constants/decoders.js.map +1 -1
  60. package/dist/constants/encoders.d.ts +4 -2
  61. package/dist/constants/encoders.js +6 -4
  62. package/dist/constants/encoders.js.map +1 -1
  63. package/dist/ffmpeg/index.js +3 -4
  64. package/dist/ffmpeg/index.js.map +1 -1
  65. package/dist/lib/binding.d.ts +2 -1
  66. package/dist/lib/binding.js +3 -4
  67. package/dist/lib/binding.js.map +1 -1
  68. package/dist/lib/codec.d.ts +10 -1
  69. package/dist/lib/codec.js.map +1 -1
  70. package/dist/lib/device.d.ts +291 -0
  71. package/dist/lib/device.js +324 -0
  72. package/dist/lib/device.js.map +1 -0
  73. package/dist/lib/filter.d.ts +8 -1
  74. package/dist/lib/filter.js.map +1 -1
  75. package/dist/lib/format-context.d.ts +17 -2
  76. package/dist/lib/format-context.js.map +1 -1
  77. package/dist/lib/frame-utils.d.ts +34 -1
  78. package/dist/lib/frame-utils.js.map +1 -1
  79. package/dist/lib/frame.d.ts +23 -1
  80. package/dist/lib/frame.js.map +1 -1
  81. package/dist/lib/index.d.ts +7 -6
  82. package/dist/lib/index.js +3 -1
  83. package/dist/lib/index.js.map +1 -1
  84. package/dist/lib/io-context.d.ts +16 -1
  85. package/dist/lib/io-context.js +17 -0
  86. package/dist/lib/io-context.js.map +1 -1
  87. package/dist/lib/log.d.ts +6 -1
  88. package/dist/lib/log.js.map +1 -1
  89. package/dist/lib/native-types.d.ts +62 -11
  90. package/dist/lib/native-types.js +0 -9
  91. package/dist/lib/native-types.js.map +1 -1
  92. package/dist/lib/types.d.ts +2 -118
  93. package/dist/lib/types.js +0 -6
  94. package/dist/lib/types.js.map +1 -1
  95. package/dist/utils/electron.d.ts +49 -0
  96. package/dist/utils/electron.js +63 -0
  97. package/dist/utils/electron.js.map +1 -0
  98. package/dist/utils/index.d.ts +4 -0
  99. package/dist/utils/index.js +5 -0
  100. package/dist/utils/index.js.map +1 -0
  101. package/package.json +14 -14
  102. package/BENCHMARK.md +0 -113
  103. package/dist/api/types.d.ts +0 -829
  104. package/dist/api/types.js +0 -2
  105. package/dist/api/types.js.map +0 -1
package/README.md CHANGED
@@ -22,22 +22,23 @@ Native Node.js bindings for FFmpeg with full TypeScript support. Provides direct
22
22
  - [Low-Level API](#low-level-api)
23
23
  - [High-Level API](#high-level-api)
24
24
  - [Pipeline API](#pipeline-api)
25
- - [Key Features](#key-features)
26
25
  - [Hardware Acceleration](#hardware-acceleration)
27
26
  - [Auto-Detection](#auto-detection)
28
27
  - [Specific Hardware](#specific-hardware)
29
- - [Imports and Tree Shaking](#imports-and-tree-shaking)
30
28
  - [Stream Processing](#stream-processing)
31
- - [From Files](#from-files)
32
- - [From Network](#from-network)
29
+ - [From Files or Network](#from-files-or-network)
33
30
  - [From Buffers](#from-buffers)
34
31
  - [Raw Media Processing](#raw-media-processing)
35
- - [Resource Management](#resource-management)
32
+ - [Device Capture](#device-capture)
36
33
  - [FFmpeg Binary Access](#ffmpeg-binary-access)
34
+ - [Resource Management](#resource-management)
35
+ - [Imports and Tree Shaking](#imports-and-tree-shaking)
36
+ - [Key Features](#key-features)
37
37
  - [Performance](#performance)
38
38
  - [Benchmarks](#benchmarks)
39
39
  - [Sync vs Async Operations](#sync-vs-async-operations)
40
40
  - [Memory Safety Considerations](#memory-safety-considerations)
41
+ - [Electron](#electron)
41
42
  - [Examples](#examples)
42
43
  - [Prebuilt Binaries](#prebuilt-binaries)
43
44
  - [Troubleshooting](#troubleshooting)
@@ -221,24 +222,6 @@ const control = pipeline(input, decoder, encoder, output);
221
222
  await control.completion;
222
223
  ```
223
224
 
224
- ## Key Features
225
-
226
- Beyond basic transcoding, NodeAV provides advanced media processing capabilities:
227
-
228
- **Speech Recognition with Whisper**
229
- Integrate automatic speech-to-text transcription using OpenAI's Whisper model through the whisper.cpp implementation. The library handles automatic model downloading from HuggingFace, supports multiple model sizes (tiny, base, small, medium, large) for different accuracy/performance tradeoffs, and provides hardware-accelerated inference through Metal (macOS), Vulkan (cross-platform), or OpenCL backends. Transcription results include precise timestamps and can be processed in real-time from any audio source.
230
-
231
- **Advanced Video Filtering with FilterComplexAPI**
232
- Build sophisticated video processing pipelines using FFmpeg's complete filter ecosystem. The FilterComplexAPI provides direct access to complex filtergraphs with multiple inputs and outputs, enabling advanced operations like picture-in-picture overlays, multi-stream composition (side-by-side, grid layouts), real-time video effects, and custom processing chains. All filters support hardware acceleration where available, and filter configurations can be dynamically constructed based on runtime requirements.
233
-
234
- **Browser Streaming**
235
- Stream any media source directly to web browsers through fragmented MP4 (fMP4) or WebRTC protocols. The library can process inputs from RTSP cameras, local files, network streams, or custom sources and package them for browser consumption with minimal latency. Complete examples demonstrate both Media Source Extensions (MSE) based playback for on-demand content and WebRTC integration for real-time streaming scenarios.
236
-
237
- **RTSP Backchannel / Talkback**
238
- Implements bidirectional RTSP communication for IP camera integration. The library provides native support for RTSP backchannel streams, enabling audio transmission to camera devices. Transport is handled automatically with support for both TCP (interleaved mode) and UDP protocols, with proper RTP packet formatting and stream synchronization.
239
-
240
- See the [Examples](#examples) section for complete implementations.
241
-
242
225
  ## Hardware Acceleration
243
226
 
244
227
  The library supports all hardware acceleration methods available in FFmpeg. The specific hardware types available depend on your FFmpeg build and system configuration.
@@ -275,37 +258,16 @@ const cuda = HardwareContext.create(AV_HWDEVICE_TYPE_CUDA);
275
258
  const vaapi = HardwareContext.create(AV_HWDEVICE_TYPE_VAAPI, '/dev/dri/renderD128');
276
259
  ```
277
260
 
278
- ## Imports and Tree Shaking
279
-
280
- The library provides multiple entry points for optimal tree shaking:
281
-
282
- ```typescript
283
- // High-Level API only - Recommended for most use cases
284
- import { Muxer, Muxer, Decoder, Encoder } from 'node-av/api';
285
-
286
- // Low-Level API only - Direct FFmpeg bindings
287
- import { FormatContext, CodecContext, Frame, Packet } from 'node-av/lib';
288
-
289
- // Constants only - When you just need FFmpeg constants
290
- import { AV_PIX_FMT_YUV420P, AV_CODEC_ID_H264 } from 'node-av/constants';
291
-
292
- // Channel layouts only - For audio channel configurations
293
- import { AV_CHANNEL_LAYOUT_STEREO, AV_CHANNEL_LAYOUT_5POINT1 } from 'node-av/layouts';
294
-
295
- // Default export - Includes everything
296
- import * as ffmpeg from 'node-av';
297
- ```
298
-
299
261
  ## Stream Processing
300
262
 
301
263
  ### From Files or Network
302
264
 
303
265
  ```typescript
304
- const media = await Muxer.open('input.mp4');
266
+ const media = await Demuxer.open('input.mp4');
305
267
 
306
268
  // or
307
269
 
308
- const media = await Muxer.open('rtsp://example.com/stream');
270
+ const media = await Demuxer.open('rtsp://example.com/stream');
309
271
  ```
310
272
 
311
273
  ### From Buffers
@@ -314,7 +276,7 @@ const media = await Muxer.open('rtsp://example.com/stream');
314
276
  import { readFile } from 'fs/promises';
315
277
 
316
278
  const buffer = await readFile('input.mp4');
317
- const media = await Muxer.open(buffer);
279
+ const media = await Demuxer.open(buffer);
318
280
  ```
319
281
 
320
282
  ### Custom I/O Callbacks
@@ -334,7 +296,7 @@ const inputCallbacks: IOInputCallbacks = {
334
296
  }
335
297
  };
336
298
 
337
- await using input = await Muxer.open(inputCallbacks, {
299
+ await using input = await Demuxer.open(inputCallbacks, {
338
300
  format: 'mp4'
339
301
  });
340
302
  ```
@@ -343,7 +305,7 @@ await using input = await Muxer.open(inputCallbacks, {
343
305
 
344
306
  ```typescript
345
307
  // Raw video input
346
- const rawVideo = await Muxer.open({
308
+ const rawVideo = await Demuxer.open({
347
309
  type: 'video',
348
310
  input: 'input.yuv',
349
311
  width: 1280,
@@ -353,7 +315,7 @@ const rawVideo = await Muxer.open({
353
315
  });
354
316
 
355
317
  // Raw audio input
356
- const rawAudio = await Muxer.open({
318
+ const rawAudio = await Demuxer.open({
357
319
  type: 'audio',
358
320
  input: 'input.pcm',
359
321
  sampleRate: 48000,
@@ -364,27 +326,42 @@ const rawAudio = await Muxer.open({
364
326
  });
365
327
  ```
366
328
 
367
- ## Resource Management
329
+ ## Device Capture
368
330
 
369
- The library supports automatic resource cleanup using the Disposable pattern:
331
+ Capture video, audio, and screen content directly from system devices. Platform-specific formats are handled automatically.
370
332
 
371
333
  ```typescript
372
- // Automatic cleanup with 'using'
373
- {
374
- await using media = await Muxer.open('input.mp4');
375
- using decoder = await Decoder.create(media.video());
376
- // Resources automatically cleaned up at end of scope
377
- }
334
+ import { DeviceAPI } from 'node-av/api';
378
335
 
379
- // Manual cleanup
380
- const media = await Muxer.open('input.mp4');
381
- try {
382
- // Process media
383
- } finally {
384
- await media.close();
385
- }
336
+ // List devices and query capabilities
337
+ const devices = await DeviceAPI.list();
338
+ const modes = await DeviceAPI.modes(devices.find(d => d.type === 'video')!.name);
339
+
340
+ // Camera
341
+ await using camera = await DeviceAPI.openCamera({ videoDevice: 0, width: 1280, height: 720, frameRate: 30 });
342
+
343
+ // Microphone
344
+ await using mic = await DeviceAPI.openMicrophone({ audioDevice: 0, sampleRate: 48000, channels: 2 });
345
+
346
+ // Combined video + audio (macOS/Windows)
347
+ await using device = await DeviceAPI.openDevice({ videoDevice: 0, audioDevice: 0, width: 1280, height: 720, frameRate: 30 });
348
+
349
+ // Screen capture
350
+ await using screen = await DeviceAPI.openScreen({ frameRate: 30, drawMouse: true });
351
+
352
+ // Screen capture with system audio (macOS 13.0+)
353
+ await using screen2 = await DeviceAPI.openScreen({
354
+ frameRate: 30,
355
+ avfoundation: { captureSystemAudio: true, audioSampleRate: 48000, audioChannels: 2 },
356
+ });
386
357
  ```
387
358
 
359
+ | Platform | Video | Audio | Screen |
360
+ |----------|-------|-------|--------|
361
+ | macOS | AVFoundation | AVFoundation | AVFoundation (ScreenCaptureKit) |
362
+ | Linux | V4L2 | ALSA | x11grab |
363
+ | Windows | DirectShow | DirectShow | GDIGrab |
364
+
388
365
  ## FFmpeg Binary Access
389
366
 
390
367
  Need direct access to the FFmpeg binary? The library provides an easy way to get FFmpeg binaries that automatically downloads and manages platform-specific builds.
@@ -423,6 +400,66 @@ async function convertVideo(input: string, output: string) {
423
400
 
424
401
  The FFmpeg binary is automatically downloaded during installation from GitHub releases and matches the same build used by the native bindings.
425
402
 
403
+ ## Resource Management
404
+
405
+ The library supports automatic resource cleanup using the Disposable pattern:
406
+
407
+ ```typescript
408
+ // Automatic cleanup with 'using'
409
+ {
410
+ await using media = await Demuxer.open('input.mp4');
411
+ using decoder = await Decoder.create(media.video());
412
+ // Resources automatically cleaned up at end of scope
413
+ }
414
+
415
+ // Manual cleanup
416
+ const media = await Demuxer.open('input.mp4');
417
+ try {
418
+ // Process media
419
+ } finally {
420
+ await media.close();
421
+ }
422
+ ```
423
+
424
+ ## Imports and Tree Shaking
425
+
426
+ The library provides multiple entry points for optimal tree shaking:
427
+
428
+ ```typescript
429
+ // High-Level API only - Recommended for most use cases
430
+ import { Demuxer, Muxer, Decoder, Encoder } from 'node-av/api';
431
+
432
+ // Low-Level API only - Direct FFmpeg bindings
433
+ import { FormatContext, CodecContext, Frame, Packet } from 'node-av/lib';
434
+
435
+ // Constants only - When you just need FFmpeg constants
436
+ import { AV_PIX_FMT_YUV420P, AV_CODEC_ID_H264 } from 'node-av/constants';
437
+
438
+ // Channel layouts only - For audio channel configurations
439
+ import { AV_CHANNEL_LAYOUT_STEREO, AV_CHANNEL_LAYOUT_5POINT1 } from 'node-av/layouts';
440
+
441
+ // Default export - Includes everything
442
+ import * as ffmpeg from 'node-av';
443
+ ```
444
+
445
+ ## Key Features
446
+
447
+ Beyond basic transcoding, NodeAV provides advanced media processing capabilities:
448
+
449
+ **Speech Recognition with Whisper**
450
+ Integrate automatic speech-to-text transcription using OpenAI's Whisper model through the whisper.cpp implementation. The library handles automatic model downloading from HuggingFace, supports multiple model sizes (tiny, base, small, medium, large) for different accuracy/performance tradeoffs, and provides hardware-accelerated inference through Metal (macOS), Vulkan (cross-platform), or OpenCL backends. Transcription results include precise timestamps and can be processed in real-time from any audio source.
451
+
452
+ **Advanced Video Filtering with FilterComplexAPI**
453
+ Build sophisticated video processing pipelines using FFmpeg's complete filter ecosystem. The FilterComplexAPI provides direct access to complex filtergraphs with multiple inputs and outputs, enabling advanced operations like picture-in-picture overlays, multi-stream composition (side-by-side, grid layouts), real-time video effects, and custom processing chains. All filters support hardware acceleration where available, and filter configurations can be dynamically constructed based on runtime requirements.
454
+
455
+ **Browser Streaming**
456
+ Stream any media source directly to web browsers through fragmented MP4 (fMP4) or WebRTC protocols. The library can process inputs from RTSP cameras, local files, network streams, or custom sources and package them for browser consumption with minimal latency. Complete examples demonstrate both Media Source Extensions (MSE) based playback for on-demand content and WebRTC integration for real-time streaming scenarios.
457
+
458
+ **RTSP Backchannel / Talkback**
459
+ Implements bidirectional RTSP communication for IP camera integration. The library provides native support for RTSP backchannel streams, enabling audio transmission to camera devices. Transport is handled automatically with support for both TCP (interleaved mode) and UDP protocols, with proper RTP packet formatting and stream synchronization.
460
+
461
+ See the [Examples](#examples) section for complete implementations.
462
+
426
463
  ## Performance
427
464
 
428
465
  NodeAV executes all media operations directly through FFmpeg's native C libraries. The Node.js bindings add minimal overhead - mostly just the JavaScript-to-C boundary crossings. During typical operations like transcoding or filtering, most processing time is spent in FFmpeg's optimized C code.
@@ -460,13 +497,31 @@ The key difference: Async methods don't block the Node.js event loop, allowing o
460
497
 
461
498
  NodeAV provides direct bindings to FFmpeg's C APIs, which work with raw memory pointers. The high-level API adds safety abstractions and automatic resource management, but incorrect usage can still cause crashes. Common issues include mismatched video dimensions, incompatible pixel formats, or improper frame buffer handling. The library validates parameters where possible, but can't guarantee complete memory safety without limiting functionality. When using the low-level API, pay attention to parameter consistency, resource cleanup, and format compatibility. Following the documented patterns helps avoid memory-related issues.
462
499
 
500
+ ## Electron
501
+
502
+ NodeAV fully supports Electron applications. The prebuilt binaries are ABI-compatible with Electron, so no native rebuild is required during packaging. Both the native bindings and the bundled FFmpeg CLI binaries work seamlessly within Electron's main process.
503
+
504
+ Two complete examples are available: one using [Electron Forge](https://github.com/seydx/node-av/tree/main/examples/electron/forge) and one using [Electron Builder](https://github.com/seydx/node-av/tree/main/examples/electron/builder).
505
+
506
+ If you encounter module resolution errors like `Cannot find module 'lib/binary-stream'`, add this override to your project's `package.json`:
507
+
508
+ ```json
509
+ {
510
+ "overrides": {
511
+ "@shinyoshiaki/binary-data": "npm:@seydx/binary-data@0.6.2"
512
+ }
513
+ }
514
+ ```
515
+
463
516
  ## Examples
464
517
 
465
518
  | Example | FFmpeg | Low-Level API | High-Level API |
466
519
  |---------|--------|---------------|----------------|
467
520
  | `browser-fmp4` | | | [✓](https://github.com/seydx/node-av/tree/main/examples/browser/fmp4) |
468
521
  | `browser-webrtc` | | | [✓](https://github.com/seydx/node-av/tree/main/examples/browser/webrtc) |
522
+ | `api-abort-signal` | | | [✓](https://github.com/seydx/node-av/tree/main/examples/api-abort-signal.ts) |
469
523
  | `api-dash` | | | [✓](https://github.com/seydx/node-av/tree/main/examples/api-dash.ts) |
524
+ | `api-device-capture` | | | [✓](https://github.com/seydx/node-av/tree/main/examples/api-device-capture.ts) |
470
525
  | `api-encode-decode` | | | [✓](https://github.com/seydx/node-av/tree/main/examples/api-encode-decode.ts) |
471
526
  | `api-filter-complex` | | | [✓](https://github.com/seydx/node-av/tree/main/examples/api-filter-complex.ts) |
472
527
  | `api-filter-complex-grid` | | | [✓](https://github.com/seydx/node-av/tree/main/examples/api-filter-complex-grid.ts) |
@@ -519,7 +574,6 @@ NodeAV provides direct bindings to FFmpeg's C APIs, which work with raw memory p
519
574
  | `transcode-aac` | [✓](https://github.com/FFmpeg/FFmpeg/tree/master/doc/examples/transcode_aac.c) | [✓](https://github.com/seydx/node-av/tree/main/examples/transcode-aac.ts) | |
520
575
  | `transcode` | [✓](https://github.com/FFmpeg/FFmpeg/tree/master/doc/examples/transcode.c) | [✓](https://github.com/seydx/node-av/tree/main/examples/transcode.ts) | |
521
576
 
522
-
523
577
  ## Prebuilt Binaries
524
578
 
525
579
  Prebuilt binaries are available for multiple platforms:
@@ -0,0 +1,69 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
5
+ BUILDER_DIR="$SCRIPT_DIR/externals/jellyfin-ffmpeg/builder"
6
+ BUILD_DIR="$BUILDER_DIR/build"
7
+
8
+ echo ""
9
+ echo "=== FFmpeg Local Build ==="
10
+ echo ""
11
+ echo " 1) Full build (clean + dependencies + FFmpeg)"
12
+ echo " 2) FFmpeg only (skip dependency builds)"
13
+ echo ""
14
+ read -rp "Choose [1/2]: " choice
15
+
16
+ case "$choice" in
17
+ 1)
18
+ echo ""
19
+ echo "=> Full build selected. Cleaning build + prefix directories..."
20
+ rm -rf "$BUILD_DIR"
21
+ sudo rm -rf /opt/ffbuild/prefix
22
+ SKIP_BUILD=""
23
+ ;;
24
+ 2)
25
+ echo ""
26
+ echo "=> FFmpeg-only build selected. Skipping dependencies..."
27
+ SKIP_BUILD="--skip-build"
28
+ ;;
29
+ *)
30
+ echo "Invalid choice."
31
+ exit 1
32
+ ;;
33
+ esac
34
+
35
+ # Ensure submodules are initialized
36
+ if [ ! -f "$SCRIPT_DIR/externals/jellyfin-ffmpeg/configure" ]; then
37
+ echo "=> Initializing git submodules..."
38
+ git -C "$SCRIPT_DIR" submodule update --init --recursive
39
+ fi
40
+
41
+ # Log everything to terminal and file
42
+ LOG_FILE="$SCRIPT_DIR/ffmpeg_build.log"
43
+ exec > >(tee "$LOG_FILE") 2>&1
44
+
45
+ # Ensure /opt/ffbuild exists with correct permissions
46
+ sudo mkdir -p /opt/ffbuild/prefix
47
+ sudo chown -R "$(whoami):staff" /opt/ffbuild
48
+ sudo chmod -R 755 /opt/ffbuild
49
+
50
+ cd "$SCRIPT_DIR"
51
+
52
+ # Apply FFmpeg patches (skips if already applied)
53
+ node scripts/patch-ffmpeg.js
54
+
55
+ cd "$BUILDER_DIR"
56
+
57
+ # Run Jellyfin build script
58
+ ./buildmac.sh arm64 $SKIP_BUILD
59
+
60
+ # The build script uses /ffbuild/prefix but we need /opt/ffbuild/prefix
61
+ cd ..
62
+ make install DESTDIR="" prefix="/opt/ffbuild/prefix"
63
+
64
+ # Fix permissions after install
65
+ sudo chown -R "$(whoami):staff" /opt/ffbuild
66
+
67
+ cd "$SCRIPT_DIR"
68
+
69
+ # npm run build:native
@@ -2,7 +2,25 @@ import { Packet } from '../lib/packet.js';
2
2
  import { Muxer } from './muxer.js';
3
3
  import { Scheduler, SchedulerControl } from './utilities/scheduler.js';
4
4
  import type { Stream } from '../lib/stream.js';
5
- import type { BitstreamFilterOptions } from './types.js';
5
+ /**
6
+ * Options for bitstream filter creation.
7
+ */
8
+ export interface BitstreamFilterOptions {
9
+ /**
10
+ * Filter-specific options.
11
+ *
12
+ * Key-value pairs of FFmpeg bitstream filter options.
13
+ * These are passed directly to the filter via av_opt_set().
14
+ * Available options depend on the specific filter being used.
15
+ */
16
+ options?: Record<string, string | number | boolean | bigint | undefined | null>;
17
+ /**
18
+ * AbortSignal for cancellation.
19
+ *
20
+ * When aborted, async generators stop yielding and async methods throw AbortError.
21
+ */
22
+ signal?: AbortSignal;
23
+ }
6
24
  /**
7
25
  * High-level bitstream filter for packet processing.
8
26
  *
@@ -53,6 +71,7 @@ export declare class BitStreamFilterAPI implements Disposable {
53
71
  private workerPromise;
54
72
  private nextComponent;
55
73
  private pipeToPromise;
74
+ private signal?;
56
75
  /**
57
76
  * @param bsf - Bitstream filter
58
77
  *
@@ -110,6 +110,7 @@ export class BitStreamFilterAPI {
110
110
  workerPromise = null;
111
111
  nextComponent = null;
112
112
  pipeToPromise = null;
113
+ signal;
113
114
  /**
114
115
  * @param bsf - Bitstream filter
115
116
  *
@@ -210,7 +211,12 @@ export class BitStreamFilterAPI {
210
211
  // Initialize the filter
211
212
  const initRet = ctx.init();
212
213
  FFmpegError.throwIfError(initRet, 'Failed to initialize bitstream filter');
213
- return new BitStreamFilterAPI(filter, ctx, stream);
214
+ const bsfApi = new BitStreamFilterAPI(filter, ctx, stream);
215
+ if (filterOptions?.signal) {
216
+ filterOptions.signal.throwIfAborted();
217
+ bsfApi.signal = filterOptions.signal;
218
+ }
219
+ return bsfApi;
214
220
  }
215
221
  catch (error) {
216
222
  // Clean up on error
@@ -324,6 +330,7 @@ export class BitStreamFilterAPI {
324
330
  * @see {@link filterSync} For synchronous version
325
331
  */
326
332
  async filter(packet) {
333
+ this.signal?.throwIfAborted();
327
334
  if (this.isClosed) {
328
335
  return;
329
336
  }
@@ -437,6 +444,7 @@ export class BitStreamFilterAPI {
437
444
  * @see {@link filterAllSync} For synchronous version
438
445
  */
439
446
  async filterAll(packet) {
447
+ this.signal?.throwIfAborted();
440
448
  await this.filter(packet);
441
449
  // Receive all output packets
442
450
  const outputPackets = [];
@@ -589,6 +597,7 @@ export class BitStreamFilterAPI {
589
597
  const env_1 = { stack: [], error: void 0, hasError: false };
590
598
  try {
591
599
  const packet = __addDisposableResource(env_1, packet_1, false);
600
+ this.signal?.throwIfAborted();
592
601
  if (packet === null) {
593
602
  yield* finalize();
594
603
  return;
@@ -738,6 +747,7 @@ export class BitStreamFilterAPI {
738
747
  * @see {@link flushSync} For synchronous version
739
748
  */
740
749
  async flush() {
750
+ this.signal?.throwIfAborted();
741
751
  if (this.isClosed) {
742
752
  return;
743
753
  }
@@ -1 +1 @@
1
- {"version":3,"file":"bitstream-filter.js","sourceRoot":"","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BAC7C,IAAI,CAAC,MAAM;wBAAE,MAAM;oBACnB,MAAM,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;gBAC9B,CAAC;YACH,CAAC,CAAC,EAAE,CAAC;YAEL,mEAAmE;YACnE,OAAO,IAAI,SAAS,CAAS,IAA+C,EAAE,CAAC,CAAC,CAAC;QACnF,CAAC;IACH,CAAC;CACF"}
@@ -3,11 +3,106 @@ import { Codec } from '../lib/codec.js';
3
3
  import { Frame } from '../lib/frame.js';
4
4
  import { Packet } from '../lib/packet.js';
5
5
  import { Scheduler } from './utilities/scheduler.js';
6
- import type { AVCodecID, EOFSignal, FFDecoderCodec } from '../constants/index.js';
6
+ import type { AVCodecID, AVPixelFormat, AVThreadType, EOFSignal, FFDecoderCodec } from '../constants/index.js';
7
7
  import type { Stream } from '../lib/stream.js';
8
+ import type { IRational } from '../lib/types.js';
8
9
  import type { Encoder } from './encoder.js';
9
10
  import type { FilterAPI } from './filter.js';
10
- import type { DecoderOptions } from './types.js';
11
+ import type { HardwareContext } from './hardware.js';
12
+ /**
13
+ * Options for decoder creation.
14
+ */
15
+ export interface DecoderOptions {
16
+ /**
17
+ * Exit immediately on first decode error.
18
+ *
19
+ * When enabled, the decoder will terminate on the first decode error.
20
+ * When disabled, errors are logged but decoding continues with next packet.
21
+ *
22
+ * @default true
23
+ */
24
+ exitOnError?: boolean;
25
+ /**
26
+ * Hardware acceleration context.
27
+ *
28
+ * Pass a HardwareContext instance to enable hardware-accelerated decoding.
29
+ * Set to null to disable hardware acceleration.
30
+ */
31
+ hardware?: HardwareContext | null;
32
+ /**
33
+ * Number of extra hardware frames to allocate.
34
+ *
35
+ * Useful for hardware decoders requiring additional frame buffering.
36
+ * Some hardware decoders need extra frames for reference or look-ahead.
37
+ */
38
+ extraHWFrames?: number;
39
+ /**
40
+ * Hardware frame output format.
41
+ *
42
+ * When set, hardware frames will be automatically transferred to this software pixel format.
43
+ * Useful when you need software frames for further processing but want to use hardware decoding.
44
+ */
45
+ hwaccelOutputFormat?: AVPixelFormat;
46
+ /**
47
+ * Force constant framerate mode.
48
+ *
49
+ * When set, ignores all timestamps and generates frames at a constant rate.
50
+ * Sets frame PTS to AV_NOPTS_VALUE, duration to 1, and time_base to 1/framerate.
51
+ * Matches FFmpeg CLI's DECODER_FLAG_FRAMERATE_FORCED behavior.
52
+ */
53
+ forcedFramerate?: IRational;
54
+ /**
55
+ * Override sample aspect ratio.
56
+ *
57
+ * When set, overrides the frame's sample_aspect_ratio with this value.
58
+ * Useful for fixing incorrect SAR in source material.
59
+ */
60
+ sarOverride?: IRational;
61
+ /**
62
+ * Apply cropping from frame metadata.
63
+ *
64
+ * When true, automatically crops frames based on their crop metadata.
65
+ * Uses av_frame_apply_cropping() with AV_FRAME_CROP_UNALIGNED flag.
66
+ * Useful for streams with letterboxing/pillarboxing metadata.
67
+ *
68
+ * @default false
69
+ */
70
+ applyCropping?: boolean;
71
+ /**
72
+ * Number of threads to use for decoding.
73
+ *
74
+ * Set to 0 to auto-detect based on CPU cores.
75
+ *
76
+ * @default 1
77
+ */
78
+ threadCount?: number;
79
+ /**
80
+ * Type of threading to use for decoding.
81
+ *
82
+ * - `FF_THREAD_FRAME` (1): Decode multiple frames in parallel.
83
+ * Higher throughput but adds latency (1 frame delay per thread).
84
+ * Not recommended for live streaming where future frames are unavailable.
85
+ *
86
+ * - `FF_THREAD_SLICE` (2): Decode parts of a single frame in parallel.
87
+ * No additional latency, suitable for real-time/live streaming.
88
+ *
89
+ * @default FFmpeg default (both methods, codec chooses best)
90
+ */
91
+ threadType?: AVThreadType;
92
+ /**
93
+ * Additional codec-specific options.
94
+ *
95
+ * Key-value pairs of FFmpeg AVCodecContext options.
96
+ * These are passed directly to the decoder.
97
+ */
98
+ options?: Record<string, string | number | boolean | undefined | null>;
99
+ /**
100
+ * AbortSignal for cancellation.
101
+ *
102
+ * When aborted, async generators stop yielding and async methods throw AbortError.
103
+ */
104
+ signal?: AbortSignal;
105
+ }
11
106
  /**
12
107
  * High-level decoder for audio and video streams.
13
108
  *
@@ -68,6 +163,7 @@ export declare class Decoder implements Disposable {
68
163
  private workerPromise;
69
164
  private nextComponent;
70
165
  private pipeToPromise;
166
+ private signal?;
71
167
  /**
72
168
  * @param codecContext - Configured codec context
73
169
  *