@revizly/node-av 5.2.2-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/BUILD_LINUX.md +61 -0
- package/LICENSE.md +22 -0
- package/README.md +662 -0
- package/build_mac_local.sh +69 -0
- package/dist/api/audio-frame-buffer.d.ts +205 -0
- package/dist/api/audio-frame-buffer.js +287 -0
- package/dist/api/audio-frame-buffer.js.map +1 -0
- package/dist/api/bitstream-filter.d.ts +820 -0
- package/dist/api/bitstream-filter.js +1242 -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 +1088 -0
- package/dist/api/decoder.js +1775 -0
- package/dist/api/decoder.js.map +1 -0
- package/dist/api/demuxer.d.ts +1219 -0
- package/dist/api/demuxer.js +2081 -0
- package/dist/api/demuxer.js.map +1 -0
- package/dist/api/device.d.ts +586 -0
- package/dist/api/device.js +961 -0
- package/dist/api/device.js.map +1 -0
- package/dist/api/encoder.d.ts +1132 -0
- package/dist/api/encoder.js +1988 -0
- package/dist/api/encoder.js.map +1 -0
- package/dist/api/filter-complex.d.ts +821 -0
- package/dist/api/filter-complex.js +1604 -0
- package/dist/api/filter-complex.js.map +1 -0
- package/dist/api/filter-presets.d.ts +1286 -0
- package/dist/api/filter-presets.js +2152 -0
- package/dist/api/filter-presets.js.map +1 -0
- package/dist/api/filter.d.ts +1234 -0
- package/dist/api/filter.js +1976 -0
- package/dist/api/filter.js.map +1 -0
- package/dist/api/fmp4-stream.d.ts +426 -0
- package/dist/api/fmp4-stream.js +739 -0
- package/dist/api/fmp4-stream.js.map +1 -0
- package/dist/api/hardware.d.ts +651 -0
- package/dist/api/hardware.js +1260 -0
- package/dist/api/hardware.js.map +1 -0
- package/dist/api/index.d.ts +17 -0
- package/dist/api/index.js +32 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/io-stream.d.ts +307 -0
- package/dist/api/io-stream.js +282 -0
- package/dist/api/io-stream.js.map +1 -0
- package/dist/api/muxer.d.ts +957 -0
- package/dist/api/muxer.js +2002 -0
- package/dist/api/muxer.js.map +1 -0
- package/dist/api/pipeline.d.ts +607 -0
- package/dist/api/pipeline.js +1145 -0
- package/dist/api/pipeline.js.map +1 -0
- package/dist/api/utilities/async-queue.d.ts +120 -0
- package/dist/api/utilities/async-queue.js +211 -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/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/electron-shared-texture.d.ts +328 -0
- package/dist/api/utilities/electron-shared-texture.js +503 -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 +12 -0
- package/dist/api/utilities/index.js +25 -0
- package/dist/api/utilities/index.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/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/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/whisper-model.d.ts +310 -0
- package/dist/api/utilities/whisper-model.js +528 -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/whisper.d.ts +324 -0
- package/dist/api/whisper.js +362 -0
- package/dist/api/whisper.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 +2325 -0
- package/dist/constants/constants.js +1887 -0
- package/dist/constants/constants.js.map +1 -0
- package/dist/constants/decoders.d.ts +633 -0
- package/dist/constants/decoders.js +641 -0
- package/dist/constants/decoders.js.map +1 -0
- package/dist/constants/encoders.d.ts +295 -0
- package/dist/constants/encoders.js +308 -0
- package/dist/constants/encoders.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 +5 -0
- package/dist/constants/index.js +6 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/ffmpeg/index.d.ts +99 -0
- package/dist/ffmpeg/index.js +115 -0
- package/dist/ffmpeg/index.js.map +1 -0
- package/dist/ffmpeg/utils.d.ts +31 -0
- package/dist/ffmpeg/utils.js +68 -0
- package/dist/ffmpeg/utils.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 +228 -0
- package/dist/lib/binding.js +60 -0
- package/dist/lib/binding.js.map +1 -0
- package/dist/lib/bitstream-filter-context.d.ts +379 -0
- package/dist/lib/bitstream-filter-context.js +441 -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 +1071 -0
- package/dist/lib/codec-context.js +1354 -0
- package/dist/lib/codec-context.js.map +1 -0
- package/dist/lib/codec-parameters.d.ts +616 -0
- package/dist/lib/codec-parameters.js +761 -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 +586 -0
- package/dist/lib/codec.js +713 -0
- package/dist/lib/codec.js.map +1 -0
- package/dist/lib/device.d.ts +291 -0
- package/dist/lib/device.js +324 -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 +242 -0
- package/dist/lib/error.js +303 -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 +712 -0
- package/dist/lib/filter-context.js +789 -0
- package/dist/lib/filter-context.js.map +1 -0
- package/dist/lib/filter-graph-segment.d.ts +160 -0
- package/dist/lib/filter-graph-segment.js +171 -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 +198 -0
- package/dist/lib/filter-inout.js +257 -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 +1254 -0
- package/dist/lib/format-context.js +1379 -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 +1222 -0
- package/dist/lib/frame.js +1435 -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 +419 -0
- package/dist/lib/hardware-frames-context.js +477 -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 +696 -0
- package/dist/lib/io-context.js +769 -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 +946 -0
- package/dist/lib/native-types.js +2 -0
- package/dist/lib/native-types.js.map +1 -0
- package/dist/lib/option.d.ts +927 -0
- package/dist/lib/option.js +1583 -0
- package/dist/lib/option.js.map +1 -0
- package/dist/lib/output-format.d.ts +180 -0
- package/dist/lib/output-format.js +213 -0
- package/dist/lib/output-format.js.map +1 -0
- package/dist/lib/packet.d.ts +501 -0
- package/dist/lib/packet.js +590 -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 +379 -0
- package/dist/lib/stream.js +526 -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 +1127 -0
- package/dist/lib/utilities.js +1225 -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 +4 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/install/check.js +121 -0
- package/install/ffmpeg.js +66 -0
- package/jellyfin-ffmpeg.patch +181 -0
- package/package.json +129 -0
|
@@ -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,12 @@
|
|
|
1
|
+
export { AudioSampleUtils, type AudioSampleAllocation, type AudioSampleBufferSize } from './audio-sample.js';
|
|
2
|
+
export { ChannelLayoutUtils } from './channel-layout.js';
|
|
3
|
+
export { ImageUtils, type ImageAllocation } from './image.js';
|
|
4
|
+
export { MediaTypeUtils } from './media-type.js';
|
|
5
|
+
export { PixelFormatUtils } from './pixel-format.js';
|
|
6
|
+
export { SampleFormatUtils } from './sample-format.js';
|
|
7
|
+
export { TimestampUtils } from './timestamp.js';
|
|
8
|
+
export { StreamingUtils } from './streaming.js';
|
|
9
|
+
export { WHISPER_MODELS, WHISPER_VAD_MODELS, WhisperDownloader, type DownloadOptions, type WhisperModelName, type WhisperModelType, type WhisperVADModelName, } from './whisper-model.js';
|
|
10
|
+
export { AsyncQueue } from './async-queue.js';
|
|
11
|
+
export { Scheduler, SchedulerControl, type SchedulableComponent } from './scheduler.js';
|
|
12
|
+
export { SharedTexture, type ImportHandleProps, type SharedTextureHandle, type SharedTextureOptions, type TextureFrameOptions, type TextureInfo, } from './electron-shared-texture.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Audio
|
|
2
|
+
export { AudioSampleUtils } from './audio-sample.js';
|
|
3
|
+
// Channel Layouts
|
|
4
|
+
export { ChannelLayoutUtils } from './channel-layout.js';
|
|
5
|
+
// Image
|
|
6
|
+
export { ImageUtils } from './image.js';
|
|
7
|
+
// Media
|
|
8
|
+
export { MediaTypeUtils } from './media-type.js';
|
|
9
|
+
// Pixel Format
|
|
10
|
+
export { PixelFormatUtils } from './pixel-format.js';
|
|
11
|
+
// Sample Format
|
|
12
|
+
export { SampleFormatUtils } from './sample-format.js';
|
|
13
|
+
// Timestamp
|
|
14
|
+
export { TimestampUtils } from './timestamp.js';
|
|
15
|
+
// Streaming
|
|
16
|
+
export { StreamingUtils } from './streaming.js';
|
|
17
|
+
// Whisper Model Downloader
|
|
18
|
+
export { WHISPER_MODELS, WHISPER_VAD_MODELS, WhisperDownloader, } from './whisper-model.js';
|
|
19
|
+
// AsyncQueue
|
|
20
|
+
export { AsyncQueue } from './async-queue.js';
|
|
21
|
+
// Scheduler
|
|
22
|
+
export { Scheduler, SchedulerControl } from './scheduler.js';
|
|
23
|
+
// SharedTexture
|
|
24
|
+
export { SharedTexture, } from './electron-shared-texture.js';
|
|
25
|
+
//# 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,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,GAMd,MAAM,8BAA8B,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"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { AVPixelFormat } from '../../constants/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Video pixel format utilities.
|
|
4
|
+
*
|
|
5
|
+
* Provides static methods for querying pixel format properties, converting
|
|
6
|
+
* between format names and values, and checking hardware acceleration support.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { PixelFormat } from 'node-av';
|
|
11
|
+
* import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_CUDA } from 'node-av/constants';
|
|
12
|
+
*
|
|
13
|
+
* // Get format information
|
|
14
|
+
* console.log(PixelFormat.getName(AV_PIX_FMT_YUV420P)); // "yuv420p"
|
|
15
|
+
* console.log(PixelFormat.isHardware(AV_PIX_FMT_CUDA)); // true
|
|
16
|
+
*
|
|
17
|
+
* // Convert between names and values
|
|
18
|
+
* const format = PixelFormat.fromName("yuv420p");
|
|
19
|
+
* console.log(format === AV_PIX_FMT_YUV420P); // true
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare class PixelFormatUtils {
|
|
23
|
+
private constructor();
|
|
24
|
+
/**
|
|
25
|
+
* Get the name of a pixel format.
|
|
26
|
+
*
|
|
27
|
+
* Returns a string describing the pixel format.
|
|
28
|
+
* Direct mapping to av_get_pix_fmt_name()
|
|
29
|
+
*
|
|
30
|
+
* @param format - Video pixel format
|
|
31
|
+
*
|
|
32
|
+
* @returns Format name string, or null for invalid format
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* import { PixelFormat } from 'node-av';
|
|
37
|
+
* import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_RGB24 } from 'node-av/constants';
|
|
38
|
+
*
|
|
39
|
+
* console.log(PixelFormat.getName(AV_PIX_FMT_YUV420P)); // "yuv420p"
|
|
40
|
+
* console.log(PixelFormat.getName(AV_PIX_FMT_RGB24)); // "rgb24"
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
static getName(format: AVPixelFormat): string | null;
|
|
44
|
+
/**
|
|
45
|
+
* Get pixel format from name.
|
|
46
|
+
*
|
|
47
|
+
* Converts a pixel format name string to its enum value.
|
|
48
|
+
* Direct mapping to av_get_pix_fmt()
|
|
49
|
+
*
|
|
50
|
+
* @param name - Pixel format name string
|
|
51
|
+
*
|
|
52
|
+
* @returns Pixel format enum value, or AV_PIX_FMT_NONE for unknown formats
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* import { PixelFormat } from 'node-av';
|
|
57
|
+
* import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
|
|
58
|
+
*
|
|
59
|
+
* const format = PixelFormat.fromName("yuv420p");
|
|
60
|
+
* console.log(format === AV_PIX_FMT_YUV420P); // true
|
|
61
|
+
*
|
|
62
|
+
* const invalid = PixelFormat.fromName("invalid");
|
|
63
|
+
* console.log(invalid === AV_PIX_FMT_NONE); // true
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
static fromName(name: string): AVPixelFormat;
|
|
67
|
+
/**
|
|
68
|
+
* Check if pixel format is hardware accelerated.
|
|
69
|
+
*
|
|
70
|
+
* Returns true if the pixel format represents frames in GPU/hardware memory
|
|
71
|
+
* rather than system memory.
|
|
72
|
+
* Direct mapping to av_pix_fmt_desc_get() and checking for AV_PIX_FMT_FLAG_HWACCEL
|
|
73
|
+
*
|
|
74
|
+
* @param format - Video pixel format
|
|
75
|
+
*
|
|
76
|
+
* @returns True if format is hardware accelerated
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* import { PixelFormat } from 'node-av';
|
|
81
|
+
* import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_CUDA, AV_PIX_FMT_VAAPI } from 'node-av/constants';
|
|
82
|
+
*
|
|
83
|
+
* console.log(PixelFormat.isHardware(AV_PIX_FMT_YUV420P)); // false
|
|
84
|
+
* console.log(PixelFormat.isHardware(AV_PIX_FMT_CUDA)); // true
|
|
85
|
+
* console.log(PixelFormat.isHardware(AV_PIX_FMT_VAAPI)); // true
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
static isHardware(format: AVPixelFormat): boolean;
|
|
89
|
+
}
|