node-av-light 0.0.0-stage → 7.1.0-beta.1
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/LICENSE.md +22 -0
- package/README.md +710 -2
- package/dist/api/audio-frame-buffer.d.ts +636 -0
- package/dist/api/audio-frame-buffer.js +1027 -0
- package/dist/api/audio-frame-buffer.js.map +1 -0
- package/dist/api/bitstream-filter.d.ts +938 -0
- package/dist/api/bitstream-filter.js +1427 -0
- package/dist/api/bitstream-filter.js.map +1 -0
- package/dist/api/constants.d.ts +44 -0
- package/dist/api/constants.js +45 -0
- package/dist/api/constants.js.map +1 -0
- package/dist/api/data/test_av1.ivf +0 -0
- package/dist/api/data/test_h264.h264 +0 -0
- package/dist/api/data/test_hevc.h265 +0 -0
- package/dist/api/data/test_mjpeg.mjpeg +0 -0
- package/dist/api/data/test_vp8.ivf +0 -0
- package/dist/api/data/test_vp9.ivf +0 -0
- package/dist/api/decoder.d.ts +1413 -0
- package/dist/api/decoder.js +2367 -0
- package/dist/api/decoder.js.map +1 -0
- package/dist/api/demuxer.d.ts +1295 -0
- package/dist/api/demuxer.js +2344 -0
- package/dist/api/demuxer.js.map +1 -0
- package/dist/api/device.d.ts +589 -0
- package/dist/api/device.js +964 -0
- package/dist/api/device.js.map +1 -0
- package/dist/api/encoder-pool.d.ts +262 -0
- package/dist/api/encoder-pool.js +397 -0
- package/dist/api/encoder-pool.js.map +1 -0
- package/dist/api/encoder.d.ts +1509 -0
- package/dist/api/encoder.js +2619 -0
- package/dist/api/encoder.js.map +1 -0
- package/dist/api/filter-complex.d.ts +828 -0
- package/dist/api/filter-complex.js +1661 -0
- package/dist/api/filter-complex.js.map +1 -0
- package/dist/api/filter-presets.d.ts +800 -0
- package/dist/api/filter-presets.js +1554 -0
- package/dist/api/filter-presets.js.map +1 -0
- package/dist/api/filter.d.ts +1339 -0
- package/dist/api/filter.js +2075 -0
- package/dist/api/filter.js.map +1 -0
- package/dist/api/fmp4-stream.d.ts +797 -0
- package/dist/api/fmp4-stream.js +1428 -0
- package/dist/api/fmp4-stream.js.map +1 -0
- package/dist/api/hardware.d.ts +677 -0
- package/dist/api/hardware.js +1300 -0
- package/dist/api/hardware.js.map +1 -0
- package/dist/api/index.d.ts +21 -0
- package/dist/api/index.js +38 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/io-stream.d.ts +308 -0
- package/dist/api/io-stream.js +358 -0
- package/dist/api/io-stream.js.map +1 -0
- package/dist/api/muxer.d.ts +1311 -0
- package/dist/api/muxer.js +2672 -0
- package/dist/api/muxer.js.map +1 -0
- package/dist/api/pipeline.d.ts +801 -0
- package/dist/api/pipeline.js +1344 -0
- package/dist/api/pipeline.js.map +1 -0
- package/dist/api/probe.d.ts +128 -0
- package/dist/api/probe.js +227 -0
- package/dist/api/probe.js.map +1 -0
- package/dist/api/rtp-stream.d.ts +497 -0
- package/dist/api/rtp-stream.js +1131 -0
- package/dist/api/rtp-stream.js.map +1 -0
- package/dist/api/scaler.d.ts +561 -0
- package/dist/api/scaler.js +918 -0
- package/dist/api/scaler.js.map +1 -0
- package/dist/api/types.d.ts +17 -0
- package/dist/api/types.js +2 -0
- package/dist/api/types.js.map +1 -0
- package/dist/api/utilities/async-queue.d.ts +149 -0
- package/dist/api/utilities/async-queue.js +254 -0
- package/dist/api/utilities/async-queue.js.map +1 -0
- package/dist/api/utilities/audio-sample.d.ts +117 -0
- package/dist/api/utilities/audio-sample.js +112 -0
- package/dist/api/utilities/audio-sample.js.map +1 -0
- package/dist/api/utilities/audio-transcode.d.ts +20 -0
- package/dist/api/utilities/audio-transcode.js +27 -0
- package/dist/api/utilities/audio-transcode.js.map +1 -0
- package/dist/api/utilities/channel-layout.d.ts +76 -0
- package/dist/api/utilities/channel-layout.js +80 -0
- package/dist/api/utilities/channel-layout.js.map +1 -0
- package/dist/api/utilities/codec-format.d.ts +87 -0
- package/dist/api/utilities/codec-format.js +117 -0
- package/dist/api/utilities/codec-format.js.map +1 -0
- package/dist/api/utilities/context-options.d.ts +25 -0
- package/dist/api/utilities/context-options.js +23 -0
- package/dist/api/utilities/context-options.js.map +1 -0
- package/dist/api/utilities/electron-shared-texture.d.ts +368 -0
- package/dist/api/utilities/electron-shared-texture.js +540 -0
- package/dist/api/utilities/electron-shared-texture.js.map +1 -0
- package/dist/api/utilities/image.d.ts +207 -0
- package/dist/api/utilities/image.js +213 -0
- package/dist/api/utilities/image.js.map +1 -0
- package/dist/api/utilities/index.d.ts +14 -0
- package/dist/api/utilities/index.js +27 -0
- package/dist/api/utilities/index.js.map +1 -0
- package/dist/api/utilities/live-decoding.d.ts +15 -0
- package/dist/api/utilities/live-decoding.js +32 -0
- package/dist/api/utilities/live-decoding.js.map +1 -0
- package/dist/api/utilities/media-type.d.ts +49 -0
- package/dist/api/utilities/media-type.js +53 -0
- package/dist/api/utilities/media-type.js.map +1 -0
- package/dist/api/utilities/packet-age-watchdog.d.ts +198 -0
- package/dist/api/utilities/packet-age-watchdog.js +594 -0
- package/dist/api/utilities/packet-age-watchdog.js.map +1 -0
- package/dist/api/utilities/pixel-format.d.ts +89 -0
- package/dist/api/utilities/pixel-format.js +97 -0
- package/dist/api/utilities/pixel-format.js.map +1 -0
- package/dist/api/utilities/sample-format.d.ts +129 -0
- package/dist/api/utilities/sample-format.js +141 -0
- package/dist/api/utilities/sample-format.js.map +1 -0
- package/dist/api/utilities/scale-size.d.ts +51 -0
- package/dist/api/utilities/scale-size.js +55 -0
- package/dist/api/utilities/scale-size.js.map +1 -0
- package/dist/api/utilities/scheduler.d.ts +138 -0
- package/dist/api/utilities/scheduler.js +98 -0
- package/dist/api/utilities/scheduler.js.map +1 -0
- package/dist/api/utilities/streaming.d.ts +186 -0
- package/dist/api/utilities/streaming.js +309 -0
- package/dist/api/utilities/streaming.js.map +1 -0
- package/dist/api/utilities/timestamp.d.ts +193 -0
- package/dist/api/utilities/timestamp.js +206 -0
- package/dist/api/utilities/timestamp.js.map +1 -0
- package/dist/api/utilities/video-transcode.d.ts +218 -0
- package/dist/api/utilities/video-transcode.js +624 -0
- package/dist/api/utilities/video-transcode.js.map +1 -0
- package/dist/api/utilities/whisper-model.d.ts +330 -0
- package/dist/api/utilities/whisper-model.js +587 -0
- package/dist/api/utilities/whisper-model.js.map +1 -0
- package/dist/api/utils.d.ts +19 -0
- package/dist/api/utils.js +39 -0
- package/dist/api/utils.js.map +1 -0
- package/dist/api/webrtc-stream.d.ts +294 -0
- package/dist/api/webrtc-stream.js +546 -0
- package/dist/api/webrtc-stream.js.map +1 -0
- package/dist/api/whisper.d.ts +326 -0
- package/dist/api/whisper.js +402 -0
- package/dist/api/whisper.js.map +1 -0
- package/dist/constants/bsf-options.d.ts +364 -0
- package/dist/constants/bsf-options.js +7 -0
- package/dist/constants/bsf-options.js.map +1 -0
- package/dist/constants/channel-layouts.d.ts +53 -0
- package/dist/constants/channel-layouts.js +57 -0
- package/dist/constants/channel-layouts.js.map +1 -0
- package/dist/constants/constants.d.ts +2435 -0
- package/dist/constants/constants.js +1989 -0
- package/dist/constants/constants.js.map +1 -0
- package/dist/constants/decoders.d.ts +651 -0
- package/dist/constants/decoders.js +641 -0
- package/dist/constants/decoders.js.map +1 -0
- package/dist/constants/encoders.d.ts +314 -0
- package/dist/constants/encoders.js +309 -0
- package/dist/constants/encoders.js.map +1 -0
- package/dist/constants/filter-options.d.ts +12099 -0
- package/dist/constants/filter-options.js +7 -0
- package/dist/constants/filter-options.js.map +1 -0
- package/dist/constants/format-options.d.ts +4319 -0
- package/dist/constants/format-options.js +7 -0
- package/dist/constants/format-options.js.map +1 -0
- package/dist/constants/formats.d.ts +18 -0
- package/dist/constants/formats.js +7 -0
- package/dist/constants/formats.js.map +1 -0
- package/dist/constants/hardware.d.ts +26 -0
- package/dist/constants/hardware.js +27 -0
- package/dist/constants/hardware.js.map +1 -0
- package/dist/constants/index.d.ts +10 -0
- package/dist/constants/index.js +6 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/options.d.ts +6217 -0
- package/dist/constants/options.js +7 -0
- package/dist/constants/options.js.map +1 -0
- package/dist/ffmpeg/index.d.ts +101 -0
- package/dist/ffmpeg/index.js +161 -0
- package/dist/ffmpeg/index.js.map +1 -0
- package/dist/ffmpeg/version.d.ts +6 -0
- package/dist/ffmpeg/version.js +7 -0
- package/dist/ffmpeg/version.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/audio-fifo.d.ts +399 -0
- package/dist/lib/audio-fifo.js +431 -0
- package/dist/lib/audio-fifo.js.map +1 -0
- package/dist/lib/binding.d.ts +242 -0
- package/dist/lib/binding.js +102 -0
- package/dist/lib/binding.js.map +1 -0
- package/dist/lib/bitstream-filter-context.d.ts +381 -0
- package/dist/lib/bitstream-filter-context.js +443 -0
- package/dist/lib/bitstream-filter-context.js.map +1 -0
- package/dist/lib/bitstream-filter.d.ts +140 -0
- package/dist/lib/bitstream-filter.js +154 -0
- package/dist/lib/bitstream-filter.js.map +1 -0
- package/dist/lib/codec-context.d.ts +1069 -0
- package/dist/lib/codec-context.js +1336 -0
- package/dist/lib/codec-context.js.map +1 -0
- package/dist/lib/codec-parameters.d.ts +664 -0
- package/dist/lib/codec-parameters.js +813 -0
- package/dist/lib/codec-parameters.js.map +1 -0
- package/dist/lib/codec-parser.d.ts +201 -0
- package/dist/lib/codec-parser.js +213 -0
- package/dist/lib/codec-parser.js.map +1 -0
- package/dist/lib/codec.d.ts +617 -0
- package/dist/lib/codec.js +746 -0
- package/dist/lib/codec.js.map +1 -0
- package/dist/lib/device.d.ts +294 -0
- package/dist/lib/device.js +326 -0
- package/dist/lib/device.js.map +1 -0
- package/dist/lib/dictionary.d.ts +333 -0
- package/dist/lib/dictionary.js +372 -0
- package/dist/lib/dictionary.js.map +1 -0
- package/dist/lib/error.d.ts +311 -0
- package/dist/lib/error.js +395 -0
- package/dist/lib/error.js.map +1 -0
- package/dist/lib/fifo.d.ts +416 -0
- package/dist/lib/fifo.js +453 -0
- package/dist/lib/fifo.js.map +1 -0
- package/dist/lib/filter-context.d.ts +714 -0
- package/dist/lib/filter-context.js +783 -0
- package/dist/lib/filter-context.js.map +1 -0
- package/dist/lib/filter-graph-segment.d.ts +161 -0
- package/dist/lib/filter-graph-segment.js +172 -0
- package/dist/lib/filter-graph-segment.js.map +1 -0
- package/dist/lib/filter-graph.d.ts +641 -0
- package/dist/lib/filter-graph.js +704 -0
- package/dist/lib/filter-graph.js.map +1 -0
- package/dist/lib/filter-inout.d.ts +202 -0
- package/dist/lib/filter-inout.js +261 -0
- package/dist/lib/filter-inout.js.map +1 -0
- package/dist/lib/filter.d.ts +243 -0
- package/dist/lib/filter.js +272 -0
- package/dist/lib/filter.js.map +1 -0
- package/dist/lib/format-context.d.ts +1335 -0
- package/dist/lib/format-context.js +1455 -0
- package/dist/lib/format-context.js.map +1 -0
- package/dist/lib/frame-utils.d.ts +116 -0
- package/dist/lib/frame-utils.js +98 -0
- package/dist/lib/frame-utils.js.map +1 -0
- package/dist/lib/frame.d.ts +1315 -0
- package/dist/lib/frame.js +1535 -0
- package/dist/lib/frame.js.map +1 -0
- package/dist/lib/hardware-device-context.d.ts +362 -0
- package/dist/lib/hardware-device-context.js +383 -0
- package/dist/lib/hardware-device-context.js.map +1 -0
- package/dist/lib/hardware-frames-context.d.ts +418 -0
- package/dist/lib/hardware-frames-context.js +471 -0
- package/dist/lib/hardware-frames-context.js.map +1 -0
- package/dist/lib/index.d.ts +35 -0
- package/dist/lib/index.js +60 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/input-format.d.ts +249 -0
- package/dist/lib/input-format.js +306 -0
- package/dist/lib/input-format.js.map +1 -0
- package/dist/lib/io-context.d.ts +698 -0
- package/dist/lib/io-context.js +771 -0
- package/dist/lib/io-context.js.map +1 -0
- package/dist/lib/log.d.ts +174 -0
- package/dist/lib/log.js +184 -0
- package/dist/lib/log.js.map +1 -0
- package/dist/lib/native-types.d.ts +1024 -0
- package/dist/lib/native-types.js +2 -0
- package/dist/lib/native-types.js.map +1 -0
- package/dist/lib/option.d.ts +953 -0
- package/dist/lib/option.js +1607 -0
- package/dist/lib/option.js.map +1 -0
- package/dist/lib/output-format.d.ts +222 -0
- package/dist/lib/output-format.js +259 -0
- package/dist/lib/output-format.js.map +1 -0
- package/dist/lib/packet.d.ts +521 -0
- package/dist/lib/packet.js +613 -0
- package/dist/lib/packet.js.map +1 -0
- package/dist/lib/rational.d.ts +251 -0
- package/dist/lib/rational.js +278 -0
- package/dist/lib/rational.js.map +1 -0
- package/dist/lib/software-resample-context.d.ts +552 -0
- package/dist/lib/software-resample-context.js +592 -0
- package/dist/lib/software-resample-context.js.map +1 -0
- package/dist/lib/software-scale-context.d.ts +344 -0
- package/dist/lib/software-scale-context.js +366 -0
- package/dist/lib/software-scale-context.js.map +1 -0
- package/dist/lib/stream.d.ts +383 -0
- package/dist/lib/stream.js +524 -0
- package/dist/lib/stream.js.map +1 -0
- package/dist/lib/sync-queue.d.ts +179 -0
- package/dist/lib/sync-queue.js +197 -0
- package/dist/lib/sync-queue.js.map +1 -0
- package/dist/lib/types.d.ts +34 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utilities.d.ts +1198 -0
- package/dist/lib/utilities.js +1302 -0
- package/dist/lib/utilities.js.map +1 -0
- package/dist/utils/electron.d.ts +49 -0
- package/dist/utils/electron.js +63 -0
- package/dist/utils/electron.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/libc.d.ts +11 -0
- package/dist/utils/libc.js +35 -0
- package/dist/utils/libc.js.map +1 -0
- package/dist/utils/variant.d.ts +26 -0
- package/dist/utils/variant.js +31 -0
- package/dist/utils/variant.js.map +1 -0
- package/dist/webrtc/index.d.ts +4 -0
- package/dist/webrtc/index.js +7 -0
- package/dist/webrtc/index.js.map +1 -0
- package/install/check.js +124 -0
- package/install/ffmpeg.js +66 -0
- package/package.json +167 -4
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import type { AVPixelFormat } from '../../constants/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Image buffer allocation result.
|
|
4
|
+
*/
|
|
5
|
+
export interface ImageAllocation {
|
|
6
|
+
/** Allocated buffer containing the image data */
|
|
7
|
+
buffer: Buffer;
|
|
8
|
+
/** Total size in bytes */
|
|
9
|
+
size: number;
|
|
10
|
+
/** Line sizes for each plane */
|
|
11
|
+
linesizes: number[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Image buffer utilities.
|
|
15
|
+
*
|
|
16
|
+
* Provides static methods for allocating, copying, and managing image buffers.
|
|
17
|
+
* These utilities handle the low-level memory layout for various pixel formats,
|
|
18
|
+
* including planar formats with multiple buffers.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { ImageUtils } from 'node-av';
|
|
23
|
+
* import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_RGB24 } from 'node-av/constants';
|
|
24
|
+
*
|
|
25
|
+
* // Allocate image buffer
|
|
26
|
+
* const image = ImageUtils.alloc(1920, 1080, AV_PIX_FMT_YUV420P, 32);
|
|
27
|
+
* console.log(`Allocated ${image.size} bytes`);
|
|
28
|
+
*
|
|
29
|
+
* // Get buffer size without allocating
|
|
30
|
+
* const size = ImageUtils.getBufferSize(AV_PIX_FMT_RGB24, 1920, 1080, 1);
|
|
31
|
+
* console.log(`RGB24 1080p needs ${size} bytes`);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare class ImageUtils {
|
|
35
|
+
private constructor();
|
|
36
|
+
/**
|
|
37
|
+
* Allocate an image buffer.
|
|
38
|
+
*
|
|
39
|
+
* Allocates a buffer large enough to hold an image with the specified dimensions
|
|
40
|
+
* and pixel format. Returns the buffer along with line sizes for each plane.
|
|
41
|
+
* Direct mapping to av_image_alloc()
|
|
42
|
+
*
|
|
43
|
+
* @param width - Image width in pixels
|
|
44
|
+
*
|
|
45
|
+
* @param height - Image height in pixels
|
|
46
|
+
*
|
|
47
|
+
* @param pixFmt - Pixel format
|
|
48
|
+
*
|
|
49
|
+
* @param align - Buffer alignment (typically 1, 16, or 32)
|
|
50
|
+
*
|
|
51
|
+
* @returns Allocation result with buffer, size, and line sizes
|
|
52
|
+
*
|
|
53
|
+
* @throws {FFmpegError} On allocation failure
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* import { ImageUtils } from 'node-av';
|
|
58
|
+
* import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
|
|
59
|
+
*
|
|
60
|
+
* // Allocate aligned buffer for YUV420P image
|
|
61
|
+
* const image = ImageUtils.alloc(1920, 1080, AV_PIX_FMT_YUV420P, 32);
|
|
62
|
+
* console.log(`Buffer size: ${image.size} bytes`);
|
|
63
|
+
* console.log(`Y plane line size: ${image.linesizes[0]}`);
|
|
64
|
+
* console.log(`U plane line size: ${image.linesizes[1]}`);
|
|
65
|
+
* console.log(`V plane line size: ${image.linesizes[2]}`);
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
static alloc(width: number, height: number, pixFmt: AVPixelFormat, align: number): ImageAllocation;
|
|
69
|
+
/**
|
|
70
|
+
* Allocate image buffer arrays (alternative interface).
|
|
71
|
+
*
|
|
72
|
+
* Similar to alloc() but with a different return format.
|
|
73
|
+
* This is an alias for compatibility.
|
|
74
|
+
*
|
|
75
|
+
* @param width - Image width in pixels
|
|
76
|
+
*
|
|
77
|
+
* @param height - Image height in pixels
|
|
78
|
+
*
|
|
79
|
+
* @param pixFmt - Pixel format
|
|
80
|
+
*
|
|
81
|
+
* @param align - Buffer alignment
|
|
82
|
+
*
|
|
83
|
+
* @returns Allocation result
|
|
84
|
+
*
|
|
85
|
+
* @throws {FFmpegError} On allocation failure
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* import { ImageUtils } from 'node-av';
|
|
90
|
+
* import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
|
|
91
|
+
*
|
|
92
|
+
* // Allocate image buffer using allocArrays
|
|
93
|
+
* const image = ImageUtils.allocArrays(1920, 1080, AV_PIX_FMT_YUV420P, 32);
|
|
94
|
+
* console.log(`Allocated ${image.size} bytes`);
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
static allocArrays(width: number, height: number, pixFmt: AVPixelFormat, align: number): ImageAllocation;
|
|
98
|
+
/**
|
|
99
|
+
* Copy image data between buffers.
|
|
100
|
+
*
|
|
101
|
+
* Copies image data from source buffers to destination buffers.
|
|
102
|
+
* Direct mapping to av_image_copy2()
|
|
103
|
+
*
|
|
104
|
+
* @param dstData - Destination data buffers (one per plane)
|
|
105
|
+
*
|
|
106
|
+
* @param dstLinesizes - Destination line sizes
|
|
107
|
+
*
|
|
108
|
+
* @param srcData - Source data buffers (one per plane)
|
|
109
|
+
*
|
|
110
|
+
* @param srcLinesizes - Source line sizes
|
|
111
|
+
*
|
|
112
|
+
* @param pixFmt - Pixel format
|
|
113
|
+
*
|
|
114
|
+
* @param width - Image width
|
|
115
|
+
*
|
|
116
|
+
* @param height - Image height
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* import { ImageUtils } from 'node-av';
|
|
121
|
+
* import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
|
|
122
|
+
*
|
|
123
|
+
* // Copy between two image buffers
|
|
124
|
+
* ImageUtils.copy(
|
|
125
|
+
* dstBuffers, dstLinesizes,
|
|
126
|
+
* srcBuffers, srcLinesizes,
|
|
127
|
+
* AV_PIX_FMT_YUV420P, 1920, 1080
|
|
128
|
+
* );
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
static copy(dstData: Buffer[], dstLinesizes: number[], srcData: Buffer[], srcLinesizes: number[], pixFmt: AVPixelFormat, width: number, height: number): void;
|
|
132
|
+
/**
|
|
133
|
+
* Get required buffer size for an image.
|
|
134
|
+
*
|
|
135
|
+
* Calculates the buffer size needed to store an image with the given parameters.
|
|
136
|
+
* Direct mapping to av_image_get_buffer_size()
|
|
137
|
+
*
|
|
138
|
+
* @param pixFmt - Pixel format
|
|
139
|
+
*
|
|
140
|
+
* @param width - Image width
|
|
141
|
+
*
|
|
142
|
+
* @param height - Image height
|
|
143
|
+
*
|
|
144
|
+
* @param align - Buffer alignment
|
|
145
|
+
*
|
|
146
|
+
* @returns Required buffer size in bytes
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* import { ImageUtils } from 'node-av';
|
|
151
|
+
* import { AV_PIX_FMT_RGB24, AV_PIX_FMT_YUV420P } from 'node-av/constants';
|
|
152
|
+
*
|
|
153
|
+
* // Calculate buffer sizes for different formats
|
|
154
|
+
* const rgbSize = ImageUtils.getBufferSize(AV_PIX_FMT_RGB24, 1920, 1080, 1);
|
|
155
|
+
* const yuvSize = ImageUtils.getBufferSize(AV_PIX_FMT_YUV420P, 1920, 1080, 1);
|
|
156
|
+
*
|
|
157
|
+
* console.log(`RGB24: ${rgbSize} bytes`); // 1920*1080*3
|
|
158
|
+
* console.log(`YUV420P: ${yuvSize} bytes`); // 1920*1080*1.5
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
static getBufferSize(pixFmt: AVPixelFormat, width: number, height: number, align: number): number;
|
|
162
|
+
/**
|
|
163
|
+
* Copy image to a single buffer.
|
|
164
|
+
*
|
|
165
|
+
* Copies image data from multiple plane buffers to a single contiguous buffer.
|
|
166
|
+
* Useful for serialization or when a single buffer is required.
|
|
167
|
+
* Direct mapping to av_image_copy_to_buffer()
|
|
168
|
+
*
|
|
169
|
+
* @param dst - Destination buffer
|
|
170
|
+
*
|
|
171
|
+
* @param dstSize - Destination buffer size
|
|
172
|
+
*
|
|
173
|
+
* @param srcData - Source data buffers (one per plane), or null
|
|
174
|
+
*
|
|
175
|
+
* @param srcLinesize - Source line sizes, or null
|
|
176
|
+
*
|
|
177
|
+
* @param pixFmt - Pixel format
|
|
178
|
+
*
|
|
179
|
+
* @param width - Image width
|
|
180
|
+
*
|
|
181
|
+
* @param height - Image height
|
|
182
|
+
*
|
|
183
|
+
* @param align - Buffer alignment
|
|
184
|
+
*
|
|
185
|
+
* @returns Bytes written, or negative error code
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* import { ImageUtils, FFmpegError } from 'node-av';
|
|
190
|
+
* import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
|
|
191
|
+
*
|
|
192
|
+
* // Copy planar data to single buffer
|
|
193
|
+
* const dstSize = ImageUtils.getBufferSize(AV_PIX_FMT_YUV420P, 1920, 1080, 1);
|
|
194
|
+
* const dst = Buffer.alloc(dstSize);
|
|
195
|
+
*
|
|
196
|
+
* const written = ImageUtils.copyToBuffer(
|
|
197
|
+
* dst, dstSize,
|
|
198
|
+
* srcBuffers, srcLinesizes,
|
|
199
|
+
* AV_PIX_FMT_YUV420P, 1920, 1080, 1
|
|
200
|
+
* );
|
|
201
|
+
*
|
|
202
|
+
* FFmpegError.throwIfError(written, 'Failed to copy image to buffer');
|
|
203
|
+
* console.log(`Wrote ${written} bytes`);
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
static copyToBuffer(dst: Buffer, dstSize: number, srcData: Buffer[] | null, srcLinesize: number[] | null, pixFmt: AVPixelFormat, width: number, height: number, align: number): number;
|
|
207
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { bindings } from '../../lib/binding.js';
|
|
2
|
+
import { FFmpegError } from '../../lib/error.js';
|
|
3
|
+
/**
|
|
4
|
+
* Image buffer utilities.
|
|
5
|
+
*
|
|
6
|
+
* Provides static methods for allocating, copying, and managing image buffers.
|
|
7
|
+
* These utilities handle the low-level memory layout for various pixel formats,
|
|
8
|
+
* including planar formats with multiple buffers.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { ImageUtils } from 'node-av';
|
|
13
|
+
* import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_RGB24 } from 'node-av/constants';
|
|
14
|
+
*
|
|
15
|
+
* // Allocate image buffer
|
|
16
|
+
* const image = ImageUtils.alloc(1920, 1080, AV_PIX_FMT_YUV420P, 32);
|
|
17
|
+
* console.log(`Allocated ${image.size} bytes`);
|
|
18
|
+
*
|
|
19
|
+
* // Get buffer size without allocating
|
|
20
|
+
* const size = ImageUtils.getBufferSize(AV_PIX_FMT_RGB24, 1920, 1080, 1);
|
|
21
|
+
* console.log(`RGB24 1080p needs ${size} bytes`);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export class ImageUtils {
|
|
25
|
+
// Private constructor to prevent instantiation
|
|
26
|
+
constructor() { }
|
|
27
|
+
/**
|
|
28
|
+
* Allocate an image buffer.
|
|
29
|
+
*
|
|
30
|
+
* Allocates a buffer large enough to hold an image with the specified dimensions
|
|
31
|
+
* and pixel format. Returns the buffer along with line sizes for each plane.
|
|
32
|
+
* Direct mapping to av_image_alloc()
|
|
33
|
+
*
|
|
34
|
+
* @param width - Image width in pixels
|
|
35
|
+
*
|
|
36
|
+
* @param height - Image height in pixels
|
|
37
|
+
*
|
|
38
|
+
* @param pixFmt - Pixel format
|
|
39
|
+
*
|
|
40
|
+
* @param align - Buffer alignment (typically 1, 16, or 32)
|
|
41
|
+
*
|
|
42
|
+
* @returns Allocation result with buffer, size, and line sizes
|
|
43
|
+
*
|
|
44
|
+
* @throws {FFmpegError} On allocation failure
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* import { ImageUtils } from 'node-av';
|
|
49
|
+
* import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
|
|
50
|
+
*
|
|
51
|
+
* // Allocate aligned buffer for YUV420P image
|
|
52
|
+
* const image = ImageUtils.alloc(1920, 1080, AV_PIX_FMT_YUV420P, 32);
|
|
53
|
+
* console.log(`Buffer size: ${image.size} bytes`);
|
|
54
|
+
* console.log(`Y plane line size: ${image.linesizes[0]}`);
|
|
55
|
+
* console.log(`U plane line size: ${image.linesizes[1]}`);
|
|
56
|
+
* console.log(`V plane line size: ${image.linesizes[2]}`);
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
static alloc(width, height, pixFmt, align) {
|
|
60
|
+
const result = bindings.avImageAlloc(width, height, pixFmt, align);
|
|
61
|
+
if (typeof result === 'number') {
|
|
62
|
+
FFmpegError.throwIfError(result, 'Failed to allocate image');
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Allocate image buffer arrays (alternative interface).
|
|
68
|
+
*
|
|
69
|
+
* Similar to alloc() but with a different return format.
|
|
70
|
+
* This is an alias for compatibility.
|
|
71
|
+
*
|
|
72
|
+
* @param width - Image width in pixels
|
|
73
|
+
*
|
|
74
|
+
* @param height - Image height in pixels
|
|
75
|
+
*
|
|
76
|
+
* @param pixFmt - Pixel format
|
|
77
|
+
*
|
|
78
|
+
* @param align - Buffer alignment
|
|
79
|
+
*
|
|
80
|
+
* @returns Allocation result
|
|
81
|
+
*
|
|
82
|
+
* @throws {FFmpegError} On allocation failure
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* import { ImageUtils } from 'node-av';
|
|
87
|
+
* import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
|
|
88
|
+
*
|
|
89
|
+
* // Allocate image buffer using allocArrays
|
|
90
|
+
* const image = ImageUtils.allocArrays(1920, 1080, AV_PIX_FMT_YUV420P, 32);
|
|
91
|
+
* console.log(`Allocated ${image.size} bytes`);
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
static allocArrays(width, height, pixFmt, align) {
|
|
95
|
+
return ImageUtils.alloc(width, height, pixFmt, align);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Copy image data between buffers.
|
|
99
|
+
*
|
|
100
|
+
* Copies image data from source buffers to destination buffers.
|
|
101
|
+
* Direct mapping to av_image_copy2()
|
|
102
|
+
*
|
|
103
|
+
* @param dstData - Destination data buffers (one per plane)
|
|
104
|
+
*
|
|
105
|
+
* @param dstLinesizes - Destination line sizes
|
|
106
|
+
*
|
|
107
|
+
* @param srcData - Source data buffers (one per plane)
|
|
108
|
+
*
|
|
109
|
+
* @param srcLinesizes - Source line sizes
|
|
110
|
+
*
|
|
111
|
+
* @param pixFmt - Pixel format
|
|
112
|
+
*
|
|
113
|
+
* @param width - Image width
|
|
114
|
+
*
|
|
115
|
+
* @param height - Image height
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* import { ImageUtils } from 'node-av';
|
|
120
|
+
* import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
|
|
121
|
+
*
|
|
122
|
+
* // Copy between two image buffers
|
|
123
|
+
* ImageUtils.copy(
|
|
124
|
+
* dstBuffers, dstLinesizes,
|
|
125
|
+
* srcBuffers, srcLinesizes,
|
|
126
|
+
* AV_PIX_FMT_YUV420P, 1920, 1080
|
|
127
|
+
* );
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
static copy(dstData, dstLinesizes, srcData, srcLinesizes, pixFmt, width, height) {
|
|
131
|
+
bindings.avImageCopy2(dstData, dstLinesizes, srcData, srcLinesizes, pixFmt, width, height);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Get required buffer size for an image.
|
|
135
|
+
*
|
|
136
|
+
* Calculates the buffer size needed to store an image with the given parameters.
|
|
137
|
+
* Direct mapping to av_image_get_buffer_size()
|
|
138
|
+
*
|
|
139
|
+
* @param pixFmt - Pixel format
|
|
140
|
+
*
|
|
141
|
+
* @param width - Image width
|
|
142
|
+
*
|
|
143
|
+
* @param height - Image height
|
|
144
|
+
*
|
|
145
|
+
* @param align - Buffer alignment
|
|
146
|
+
*
|
|
147
|
+
* @returns Required buffer size in bytes
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```typescript
|
|
151
|
+
* import { ImageUtils } from 'node-av';
|
|
152
|
+
* import { AV_PIX_FMT_RGB24, AV_PIX_FMT_YUV420P } from 'node-av/constants';
|
|
153
|
+
*
|
|
154
|
+
* // Calculate buffer sizes for different formats
|
|
155
|
+
* const rgbSize = ImageUtils.getBufferSize(AV_PIX_FMT_RGB24, 1920, 1080, 1);
|
|
156
|
+
* const yuvSize = ImageUtils.getBufferSize(AV_PIX_FMT_YUV420P, 1920, 1080, 1);
|
|
157
|
+
*
|
|
158
|
+
* console.log(`RGB24: ${rgbSize} bytes`); // 1920*1080*3
|
|
159
|
+
* console.log(`YUV420P: ${yuvSize} bytes`); // 1920*1080*1.5
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
static getBufferSize(pixFmt, width, height, align) {
|
|
163
|
+
return bindings.avImageGetBufferSize(pixFmt, width, height, align);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Copy image to a single buffer.
|
|
167
|
+
*
|
|
168
|
+
* Copies image data from multiple plane buffers to a single contiguous buffer.
|
|
169
|
+
* Useful for serialization or when a single buffer is required.
|
|
170
|
+
* Direct mapping to av_image_copy_to_buffer()
|
|
171
|
+
*
|
|
172
|
+
* @param dst - Destination buffer
|
|
173
|
+
*
|
|
174
|
+
* @param dstSize - Destination buffer size
|
|
175
|
+
*
|
|
176
|
+
* @param srcData - Source data buffers (one per plane), or null
|
|
177
|
+
*
|
|
178
|
+
* @param srcLinesize - Source line sizes, or null
|
|
179
|
+
*
|
|
180
|
+
* @param pixFmt - Pixel format
|
|
181
|
+
*
|
|
182
|
+
* @param width - Image width
|
|
183
|
+
*
|
|
184
|
+
* @param height - Image height
|
|
185
|
+
*
|
|
186
|
+
* @param align - Buffer alignment
|
|
187
|
+
*
|
|
188
|
+
* @returns Bytes written, or negative error code
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```typescript
|
|
192
|
+
* import { ImageUtils, FFmpegError } from 'node-av';
|
|
193
|
+
* import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
|
|
194
|
+
*
|
|
195
|
+
* // Copy planar data to single buffer
|
|
196
|
+
* const dstSize = ImageUtils.getBufferSize(AV_PIX_FMT_YUV420P, 1920, 1080, 1);
|
|
197
|
+
* const dst = Buffer.alloc(dstSize);
|
|
198
|
+
*
|
|
199
|
+
* const written = ImageUtils.copyToBuffer(
|
|
200
|
+
* dst, dstSize,
|
|
201
|
+
* srcBuffers, srcLinesizes,
|
|
202
|
+
* AV_PIX_FMT_YUV420P, 1920, 1080, 1
|
|
203
|
+
* );
|
|
204
|
+
*
|
|
205
|
+
* FFmpegError.throwIfError(written, 'Failed to copy image to buffer');
|
|
206
|
+
* console.log(`Wrote ${written} bytes`);
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
static copyToBuffer(dst, dstSize, srcData, srcLinesize, pixFmt, width, height, align) {
|
|
210
|
+
return bindings.avImageCopyToBuffer(dst, dstSize, srcData, srcLinesize, pixFmt, width, height, align);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.js","sourceRoot":"","sources":["../../../src/api/utilities/image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAgBjD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,UAAU;IACrB,+CAA+C;IAC/C,gBAAuB,CAAC;IAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,MAAM,CAAC,KAAK,CAAC,KAAa,EAAE,MAAc,EAAE,MAAqB,EAAE,KAAa;QAC9E,MAAM,MAAM,GAAG,QAAQ,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QACnE,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,WAAW,CAAC,YAAY,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,MAAyB,CAAC;IACnC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,MAAM,CAAC,WAAW,CAAC,KAAa,EAAE,MAAc,EAAE,MAAqB,EAAE,KAAa;QACpF,OAAO,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,MAAM,CAAC,IAAI,CAAC,OAAiB,EAAE,YAAsB,EAAE,OAAiB,EAAE,YAAsB,EAAE,MAAqB,EAAE,KAAa,EAAE,MAAc;QACpJ,QAAQ,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAC7F,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,MAAM,CAAC,aAAa,CAAC,MAAqB,EAAE,KAAa,EAAE,MAAc,EAAE,KAAa;QACtF,OAAO,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACrE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2CG;IACH,MAAM,CAAC,YAAY,CACjB,GAAW,EACX,OAAe,EACf,OAAwB,EACxB,WAA4B,EAC5B,MAAqB,EACrB,KAAa,EACb,MAAc,EACd,KAAa;QAEb,OAAO,QAAQ,CAAC,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACxG,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { AudioSampleUtils, type AudioSampleAllocation, type AudioSampleBufferSize } from './audio-sample.js';
|
|
2
|
+
export { ChannelLayoutUtils } from './channel-layout.js';
|
|
3
|
+
export { pickSupportedLayout, pickSupportedPixelFormat, pickSupportedRate, pickSupportedSampleFormat } from './codec-format.js';
|
|
4
|
+
export type { ContextOptions } from './context-options.js';
|
|
5
|
+
export { ImageUtils, type ImageAllocation } from './image.js';
|
|
6
|
+
export { MediaTypeUtils } from './media-type.js';
|
|
7
|
+
export { PixelFormatUtils } from './pixel-format.js';
|
|
8
|
+
export { SampleFormatUtils } from './sample-format.js';
|
|
9
|
+
export { TimestampUtils } from './timestamp.js';
|
|
10
|
+
export { StreamingUtils } from './streaming.js';
|
|
11
|
+
export { WHISPER_MODELS, WHISPER_VAD_MODELS, WhisperDownloader, type DownloadOptions, type WhisperModelName, type WhisperModelType, type WhisperVADModelName, } from './whisper-model.js';
|
|
12
|
+
export { AsyncQueue } from './async-queue.js';
|
|
13
|
+
export { Scheduler, SchedulerControl, type SchedulableComponent } from './scheduler.js';
|
|
14
|
+
export { SharedTexture, type ImportHandleProps, type SharedTextureHandle, type SharedTextureOptions, type TextureColorSpace, type TextureFrameOptions, type TextureInfo, } from './electron-shared-texture.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Audio
|
|
2
|
+
export { AudioSampleUtils } from './audio-sample.js';
|
|
3
|
+
// Channel Layouts
|
|
4
|
+
export { ChannelLayoutUtils } from './channel-layout.js';
|
|
5
|
+
// Codec-format negotiation
|
|
6
|
+
export { pickSupportedLayout, pickSupportedPixelFormat, pickSupportedRate, pickSupportedSampleFormat } from './codec-format.js';
|
|
7
|
+
// Image
|
|
8
|
+
export { ImageUtils } from './image.js';
|
|
9
|
+
// Media
|
|
10
|
+
export { MediaTypeUtils } from './media-type.js';
|
|
11
|
+
// Pixel Format
|
|
12
|
+
export { PixelFormatUtils } from './pixel-format.js';
|
|
13
|
+
// Sample Format
|
|
14
|
+
export { SampleFormatUtils } from './sample-format.js';
|
|
15
|
+
// Timestamp
|
|
16
|
+
export { TimestampUtils } from './timestamp.js';
|
|
17
|
+
// Streaming
|
|
18
|
+
export { StreamingUtils } from './streaming.js';
|
|
19
|
+
// Whisper Model Downloader
|
|
20
|
+
export { WHISPER_MODELS, WHISPER_VAD_MODELS, WhisperDownloader, } from './whisper-model.js';
|
|
21
|
+
// AsyncQueue
|
|
22
|
+
export { AsyncQueue } from './async-queue.js';
|
|
23
|
+
// Scheduler
|
|
24
|
+
export { Scheduler, SchedulerControl } from './scheduler.js';
|
|
25
|
+
// SharedTexture
|
|
26
|
+
export { SharedTexture, } from './electron-shared-texture.js';
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/utilities/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,OAAO,EAAE,gBAAgB,EAA0D,MAAM,mBAAmB,CAAC;AAE7G,kBAAkB;AAClB,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,2BAA2B;AAC3B,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAKhI,QAAQ;AACR,OAAO,EAAE,UAAU,EAAwB,MAAM,YAAY,CAAC;AAE9D,QAAQ;AACR,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,eAAe;AACf,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,gBAAgB;AAChB,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,YAAY;AACZ,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,YAAY;AACZ,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,2BAA2B;AAC3B,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,iBAAiB,GAKlB,MAAM,oBAAoB,CAAC;AAE5B,aAAa;AACb,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,YAAY;AACZ,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAA6B,MAAM,gBAAgB,CAAC;AAExF,gBAAgB;AAChB,OAAO,EACL,aAAa,GAOd,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CodecContext } from '../../lib/codec-context.js';
|
|
2
|
+
/**
|
|
3
|
+
* Choose low-latency threading for a live video decoder; a Decoder `configure` callback.
|
|
4
|
+
*
|
|
5
|
+
* Frame threading holds back one frame per thread before the first output, up to
|
|
6
|
+
* 16 with the automatic thread count (~0.6 s at 25 fps). Hardware decoding gets
|
|
7
|
+
* slice threading, which costs it nothing. Software decoding keeps frame threading
|
|
8
|
+
* with at most 4 threads: slice threading only splits a frame into its slices, and
|
|
9
|
+
* most cameras send one slice per frame, so it would decode on a single thread.
|
|
10
|
+
*
|
|
11
|
+
* @param context - Decoder context, before it is opened
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare function configureLiveDecoderThreading(context: CodecContext): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { availableParallelism } from 'node:os';
|
|
2
|
+
import { FF_THREAD_SLICE } from '../../constants/constants.js';
|
|
3
|
+
/**
|
|
4
|
+
* Most frame threads a live software decoder uses.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
const MAX_LIVE_FRAME_THREADS = 4;
|
|
9
|
+
/**
|
|
10
|
+
* Choose low-latency threading for a live video decoder; a Decoder `configure` callback.
|
|
11
|
+
*
|
|
12
|
+
* Frame threading holds back one frame per thread before the first output, up to
|
|
13
|
+
* 16 with the automatic thread count (~0.6 s at 25 fps). Hardware decoding gets
|
|
14
|
+
* slice threading, which costs it nothing. Software decoding keeps frame threading
|
|
15
|
+
* with at most 4 threads: slice threading only splits a frame into its slices, and
|
|
16
|
+
* most cameras send one slice per frame, so it would decode on a single thread.
|
|
17
|
+
*
|
|
18
|
+
* @param context - Decoder context, before it is opened
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export function configureLiveDecoderThreading(context) {
|
|
23
|
+
// Decoder.create() set the device only if it decodes on it
|
|
24
|
+
if (context.hwDeviceCtx) {
|
|
25
|
+
context.threadType = FF_THREAD_SLICE;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
// Like FFmpeg's automatic count (CPUs + 1, a single thread on one CPU), capped
|
|
29
|
+
const cpus = availableParallelism();
|
|
30
|
+
context.threadCount = cpus > 1 ? Math.min(cpus + 1, MAX_LIVE_FRAME_THREADS) : 1;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=live-decoding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-decoding.js","sourceRoot":"","sources":["../../../src/api/utilities/live-decoding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAI/D;;;;GAIG;AACH,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAEjC;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,6BAA6B,CAAC,OAAqB;IACjE,2DAA2D;IAC3D,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACxB,OAAO,CAAC,UAAU,GAAG,eAAe,CAAC;QACrC,OAAO;IACT,CAAC;IAED,+EAA+E;IAC/E,MAAM,IAAI,GAAG,oBAAoB,EAAE,CAAC;IACpC,OAAO,CAAC,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { AVMediaType } from '../../constants/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Media type utilities.
|
|
4
|
+
*
|
|
5
|
+
* Provides static methods for converting media type enum values to
|
|
6
|
+
* human-readable strings.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { MediaType } from 'node-av';
|
|
11
|
+
* import { AVMEDIA_TYPE_VIDEO, AVMEDIA_TYPE_AUDIO } from 'node-av/constants';
|
|
12
|
+
*
|
|
13
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_VIDEO)); // "video"
|
|
14
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_AUDIO)); // "audio"
|
|
15
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_SUBTITLE)); // "subtitle"
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare class MediaTypeUtils {
|
|
19
|
+
private constructor();
|
|
20
|
+
/**
|
|
21
|
+
* Get string representation of media type.
|
|
22
|
+
*
|
|
23
|
+
* Converts a media type enum value to its string representation.
|
|
24
|
+
* Direct mapping to av_get_media_type_string()
|
|
25
|
+
*
|
|
26
|
+
* @param type - Media type enum value
|
|
27
|
+
*
|
|
28
|
+
* @returns String representation, or null for invalid type
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* import { MediaType } from 'node-av';
|
|
33
|
+
* import {
|
|
34
|
+
* AVMEDIA_TYPE_VIDEO,
|
|
35
|
+
* AVMEDIA_TYPE_AUDIO,
|
|
36
|
+
* AVMEDIA_TYPE_DATA,
|
|
37
|
+
* AVMEDIA_TYPE_SUBTITLE,
|
|
38
|
+
* AVMEDIA_TYPE_ATTACHMENT
|
|
39
|
+
* } from 'node-av/constants';
|
|
40
|
+
*
|
|
41
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_VIDEO)); // "video"
|
|
42
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_AUDIO)); // "audio"
|
|
43
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_DATA)); // "data"
|
|
44
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_SUBTITLE)); // "subtitle"
|
|
45
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_ATTACHMENT)); // "attachment"
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
static getString(type: AVMediaType): string | null;
|
|
49
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { bindings } from '../../lib/binding.js';
|
|
2
|
+
/**
|
|
3
|
+
* Media type utilities.
|
|
4
|
+
*
|
|
5
|
+
* Provides static methods for converting media type enum values to
|
|
6
|
+
* human-readable strings.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { MediaType } from 'node-av';
|
|
11
|
+
* import { AVMEDIA_TYPE_VIDEO, AVMEDIA_TYPE_AUDIO } from 'node-av/constants';
|
|
12
|
+
*
|
|
13
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_VIDEO)); // "video"
|
|
14
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_AUDIO)); // "audio"
|
|
15
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_SUBTITLE)); // "subtitle"
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export class MediaTypeUtils {
|
|
19
|
+
// Private constructor to prevent instantiation
|
|
20
|
+
constructor() { }
|
|
21
|
+
/**
|
|
22
|
+
* Get string representation of media type.
|
|
23
|
+
*
|
|
24
|
+
* Converts a media type enum value to its string representation.
|
|
25
|
+
* Direct mapping to av_get_media_type_string()
|
|
26
|
+
*
|
|
27
|
+
* @param type - Media type enum value
|
|
28
|
+
*
|
|
29
|
+
* @returns String representation, or null for invalid type
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* import { MediaType } from 'node-av';
|
|
34
|
+
* import {
|
|
35
|
+
* AVMEDIA_TYPE_VIDEO,
|
|
36
|
+
* AVMEDIA_TYPE_AUDIO,
|
|
37
|
+
* AVMEDIA_TYPE_DATA,
|
|
38
|
+
* AVMEDIA_TYPE_SUBTITLE,
|
|
39
|
+
* AVMEDIA_TYPE_ATTACHMENT
|
|
40
|
+
* } from 'node-av/constants';
|
|
41
|
+
*
|
|
42
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_VIDEO)); // "video"
|
|
43
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_AUDIO)); // "audio"
|
|
44
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_DATA)); // "data"
|
|
45
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_SUBTITLE)); // "subtitle"
|
|
46
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_ATTACHMENT)); // "attachment"
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
static getString(type) {
|
|
50
|
+
return bindings.avGetMediaTypeString(type);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=media-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-type.js","sourceRoot":"","sources":["../../../src/api/utilities/media-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,cAAc;IACzB,+CAA+C;IAC/C,gBAAuB,CAAC;IAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,MAAM,CAAC,SAAS,CAAC,IAAiB;QAChC,OAAO,QAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;CACF"}
|