@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,419 @@
|
|
|
1
|
+
import { HardwareDeviceContext } from './hardware-device-context.js';
|
|
2
|
+
import type { AVHWFrameTransferDirection, AVPixelFormat } from '../constants/constants.js';
|
|
3
|
+
import type { Frame } from './frame.js';
|
|
4
|
+
import type { NativeHardwareFramesContext, NativeWrapper } from './native-types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Hardware frames context for GPU memory management.
|
|
7
|
+
*
|
|
8
|
+
* Manages pools of hardware frames (textures/surfaces) on the GPU.
|
|
9
|
+
* Essential for zero-copy hardware acceleration, allowing frames to stay
|
|
10
|
+
* in GPU memory throughout the processing pipeline. Provides frame allocation,
|
|
11
|
+
* format conversion, and data transfer between hardware and system memory.
|
|
12
|
+
*
|
|
13
|
+
* Direct mapping to FFmpeg's AVHWFramesContext.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { HardwareFramesContext, HardwareDeviceContext, Frame, FFmpegError } from 'node-av';
|
|
18
|
+
* import { AV_PIX_FMT_NV12, AV_PIX_FMT_CUDA, AV_HWDEVICE_TYPE_CUDA } from 'node-av/constants';
|
|
19
|
+
*
|
|
20
|
+
* // Create hardware frames context
|
|
21
|
+
* const device = new HardwareDeviceContext();
|
|
22
|
+
* device.create(AV_HWDEVICE_TYPE_CUDA);
|
|
23
|
+
*
|
|
24
|
+
* const frames = new HardwareFramesContext();
|
|
25
|
+
* frames.format = AV_PIX_FMT_CUDA; // Hardware format
|
|
26
|
+
* frames.swFormat = AV_PIX_FMT_NV12; // Software format
|
|
27
|
+
* frames.width = 1920;
|
|
28
|
+
* frames.height = 1080;
|
|
29
|
+
* frames.initialPoolSize = 20; // Pre-allocate 20 frames
|
|
30
|
+
*
|
|
31
|
+
* frames.alloc(device);
|
|
32
|
+
* const ret = frames.init();
|
|
33
|
+
* FFmpegError.throwIfError(ret, 'init');
|
|
34
|
+
*
|
|
35
|
+
* // Allocate hardware frame
|
|
36
|
+
* const hwFrame = new Frame();
|
|
37
|
+
* const ret2 = frames.getBuffer(hwFrame, 0);
|
|
38
|
+
* FFmpegError.throwIfError(ret2, 'getBuffer');
|
|
39
|
+
*
|
|
40
|
+
* // Transfer from CPU to GPU
|
|
41
|
+
* const cpuFrame = new Frame();
|
|
42
|
+
* // ... fill cpuFrame with data ...
|
|
43
|
+
* await frames.transferData(hwFrame, cpuFrame);
|
|
44
|
+
*
|
|
45
|
+
* // Map hardware frame to CPU for access
|
|
46
|
+
* const mappedFrame = new Frame();
|
|
47
|
+
* const ret3 = frames.map(mappedFrame, hwFrame, AV_HWFRAME_MAP_READ);
|
|
48
|
+
* FFmpegError.throwIfError(ret3, 'map');
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @see [AVHWFramesContext](https://ffmpeg.org/doxygen/trunk/structAVHWFramesContext.html) - FFmpeg Doxygen
|
|
52
|
+
* @see {@link HardwareDeviceContext} For device management
|
|
53
|
+
* @see {@link Frame} For frame operations
|
|
54
|
+
*/
|
|
55
|
+
export declare class HardwareFramesContext implements Disposable, NativeWrapper<NativeHardwareFramesContext> {
|
|
56
|
+
private native;
|
|
57
|
+
private _deviceRef?;
|
|
58
|
+
constructor();
|
|
59
|
+
/**
|
|
60
|
+
* Hardware pixel format.
|
|
61
|
+
*
|
|
62
|
+
* The pixel format used for frames in GPU memory.
|
|
63
|
+
* Hardware-specific format like AV_PIX_FMT_CUDA or AV_PIX_FMT_VAAPI.
|
|
64
|
+
*
|
|
65
|
+
* Direct mapping to AVHWFramesContext->format.
|
|
66
|
+
*/
|
|
67
|
+
get format(): AVPixelFormat;
|
|
68
|
+
set format(value: AVPixelFormat);
|
|
69
|
+
/**
|
|
70
|
+
* Software pixel format.
|
|
71
|
+
*
|
|
72
|
+
* The pixel format frames are converted to when transferred
|
|
73
|
+
* to system memory. Standard format like AV_PIX_FMT_YUV420P.
|
|
74
|
+
*
|
|
75
|
+
* Direct mapping to AVHWFramesContext->sw_format.
|
|
76
|
+
*/
|
|
77
|
+
get swFormat(): AVPixelFormat;
|
|
78
|
+
set swFormat(value: AVPixelFormat);
|
|
79
|
+
/**
|
|
80
|
+
* Frame width.
|
|
81
|
+
*
|
|
82
|
+
* Width of frames in pixels.
|
|
83
|
+
*
|
|
84
|
+
* Direct mapping to AVHWFramesContext->width.
|
|
85
|
+
*/
|
|
86
|
+
get width(): number;
|
|
87
|
+
set width(value: number);
|
|
88
|
+
/**
|
|
89
|
+
* Frame height.
|
|
90
|
+
*
|
|
91
|
+
* Height of frames in pixels.
|
|
92
|
+
*
|
|
93
|
+
* Direct mapping to AVHWFramesContext->height.
|
|
94
|
+
*/
|
|
95
|
+
get height(): number;
|
|
96
|
+
set height(value: number);
|
|
97
|
+
/**
|
|
98
|
+
* Initial pool size.
|
|
99
|
+
*
|
|
100
|
+
* Number of frames to pre-allocate in the pool.
|
|
101
|
+
* Set before calling init() for optimal performance.
|
|
102
|
+
*
|
|
103
|
+
* Direct mapping to AVHWFramesContext->initial_pool_size.
|
|
104
|
+
*/
|
|
105
|
+
get initialPoolSize(): number;
|
|
106
|
+
set initialPoolSize(value: number);
|
|
107
|
+
/**
|
|
108
|
+
* Associated hardware device.
|
|
109
|
+
*
|
|
110
|
+
* Reference to the device context this frames context belongs to.
|
|
111
|
+
* Automatically set when calling alloc().
|
|
112
|
+
*
|
|
113
|
+
* Direct mapping to AVHWFramesContext->device_ref.
|
|
114
|
+
*/
|
|
115
|
+
get deviceRef(): HardwareDeviceContext | null;
|
|
116
|
+
/**
|
|
117
|
+
* Allocate hardware frames context.
|
|
118
|
+
*
|
|
119
|
+
* Allocates the frames context and associates it with a device.
|
|
120
|
+
* Must be called before init().
|
|
121
|
+
*
|
|
122
|
+
* Direct mapping to av_hwframe_ctx_alloc().
|
|
123
|
+
*
|
|
124
|
+
* @param device - Hardware device context to use
|
|
125
|
+
*
|
|
126
|
+
* @throws {Error} If allocation fails (ENOMEM)
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* import { AV_PIX_FMT_CUDA, AV_PIX_FMT_NV12 } from 'node-av/constants';
|
|
131
|
+
*
|
|
132
|
+
* const frames = new HardwareFramesContext();
|
|
133
|
+
* frames.format = AV_PIX_FMT_CUDA;
|
|
134
|
+
* frames.swFormat = AV_PIX_FMT_NV12;
|
|
135
|
+
* frames.width = 1920;
|
|
136
|
+
* frames.height = 1080;
|
|
137
|
+
* frames.alloc(device);
|
|
138
|
+
* ```
|
|
139
|
+
*
|
|
140
|
+
* @see {@link init} To initialize after allocation
|
|
141
|
+
*/
|
|
142
|
+
alloc(device: HardwareDeviceContext): void;
|
|
143
|
+
/**
|
|
144
|
+
* Initialize hardware frames context.
|
|
145
|
+
*
|
|
146
|
+
* Initializes the frame pool after configuration.
|
|
147
|
+
* Must be called after alloc() and property setup.
|
|
148
|
+
*
|
|
149
|
+
* Direct mapping to av_hwframe_ctx_init().
|
|
150
|
+
*
|
|
151
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
152
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
153
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
154
|
+
* - AVERROR_ENOSYS: Operation not supported
|
|
155
|
+
* - Hardware-specific errors
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* import { FFmpegError } from 'node-av';
|
|
160
|
+
*
|
|
161
|
+
* frames.alloc(device);
|
|
162
|
+
* const ret = frames.init();
|
|
163
|
+
* FFmpegError.throwIfError(ret, 'init');
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* @see {@link alloc} Must be called first
|
|
167
|
+
*/
|
|
168
|
+
init(): number;
|
|
169
|
+
/**
|
|
170
|
+
* Free hardware frames context.
|
|
171
|
+
*
|
|
172
|
+
* Releases all frames and resources associated with the context.
|
|
173
|
+
* The context becomes invalid after calling this.
|
|
174
|
+
*
|
|
175
|
+
* Direct mapping to av_buffer_unref() on frames context.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```typescript
|
|
179
|
+
* frames.free();
|
|
180
|
+
* // Frames context is now invalid
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* @see {@link Symbol.dispose} For automatic cleanup
|
|
184
|
+
*/
|
|
185
|
+
free(): void;
|
|
186
|
+
/**
|
|
187
|
+
* Allocate hardware frame from pool.
|
|
188
|
+
*
|
|
189
|
+
* Gets a frame from the hardware frame pool.
|
|
190
|
+
* The frame will have hardware-backed storage.
|
|
191
|
+
*
|
|
192
|
+
* Direct mapping to av_hwframe_get_buffer().
|
|
193
|
+
*
|
|
194
|
+
* @param frame - Frame to allocate buffer for
|
|
195
|
+
*
|
|
196
|
+
* @param flags - Allocation flags (usually 0)
|
|
197
|
+
*
|
|
198
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
199
|
+
* - AVERROR_ENOMEM: No frames available in pool
|
|
200
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```typescript
|
|
204
|
+
* import { Frame, FFmpegError } from 'node-av';
|
|
205
|
+
*
|
|
206
|
+
* const hwFrame = new Frame();
|
|
207
|
+
* const ret = frames.getBuffer(hwFrame, 0);
|
|
208
|
+
* FFmpegError.throwIfError(ret, 'getBuffer');
|
|
209
|
+
* // hwFrame now has GPU memory allocated
|
|
210
|
+
* ```
|
|
211
|
+
*
|
|
212
|
+
* @see {@link transferData} To upload data to hardware frame
|
|
213
|
+
*/
|
|
214
|
+
getBuffer(frame: Frame, flags?: number): number;
|
|
215
|
+
/**
|
|
216
|
+
* Transfer data between hardware and system memory.
|
|
217
|
+
*
|
|
218
|
+
* Copies frame data between GPU and CPU memory.
|
|
219
|
+
* Direction is determined by frame types.
|
|
220
|
+
*
|
|
221
|
+
* Direct mapping to av_hwframe_transfer_data().
|
|
222
|
+
*
|
|
223
|
+
* @param dst - Destination frame
|
|
224
|
+
*
|
|
225
|
+
* @param src - Source frame
|
|
226
|
+
*
|
|
227
|
+
* @param flags - Transfer flags (usually 0)
|
|
228
|
+
*
|
|
229
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
230
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
231
|
+
* - AVERROR_ENOSYS: Transfer not supported
|
|
232
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```typescript
|
|
236
|
+
* import { FFmpegError } from 'node-av';
|
|
237
|
+
*
|
|
238
|
+
* // Upload: CPU -> GPU
|
|
239
|
+
* const cpuFrame = new Frame();
|
|
240
|
+
* // ... fill cpuFrame with data ...
|
|
241
|
+
* const hwFrame = new Frame();
|
|
242
|
+
* frames.getBuffer(hwFrame, 0);
|
|
243
|
+
* const ret = await frames.transferData(hwFrame, cpuFrame);
|
|
244
|
+
* FFmpegError.throwIfError(ret, 'transferData');
|
|
245
|
+
*
|
|
246
|
+
* // Download: GPU -> CPU
|
|
247
|
+
* const downloadFrame = new Frame();
|
|
248
|
+
* const ret2 = await frames.transferData(downloadFrame, hwFrame);
|
|
249
|
+
* FFmpegError.throwIfError(ret2, 'transferData');
|
|
250
|
+
* ```
|
|
251
|
+
*
|
|
252
|
+
* @see {@link getBuffer} To allocate hardware frame
|
|
253
|
+
* @see {@link map} For zero-copy access
|
|
254
|
+
*/
|
|
255
|
+
transferData(dst: Frame, src: Frame, flags?: number): Promise<number>;
|
|
256
|
+
/**
|
|
257
|
+
* Transfer frame between hardware and system memory synchronously.
|
|
258
|
+
* Synchronous version of transferData.
|
|
259
|
+
*
|
|
260
|
+
* Copies frame data between GPU and CPU memory.
|
|
261
|
+
* Direction depends on frame types (hardware vs software).
|
|
262
|
+
*
|
|
263
|
+
* Direct mapping to av_hwframe_transfer_data().
|
|
264
|
+
*
|
|
265
|
+
* @param dst - Destination frame
|
|
266
|
+
*
|
|
267
|
+
* @param src - Source frame
|
|
268
|
+
*
|
|
269
|
+
* @param flags - Transfer flags (currently unused, pass 0)
|
|
270
|
+
*
|
|
271
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
272
|
+
* - AVERROR_EINVAL: Invalid frames
|
|
273
|
+
* - AVERROR_ENOSYS: Operation not supported
|
|
274
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ```typescript
|
|
278
|
+
* import { Frame, FFmpegError } from 'node-av';
|
|
279
|
+
*
|
|
280
|
+
* // Download from GPU to CPU
|
|
281
|
+
* const cpuFrame = new Frame();
|
|
282
|
+
* cpuFrame.format = frames.swFormat;
|
|
283
|
+
* cpuFrame.width = frames.width;
|
|
284
|
+
* cpuFrame.height = frames.height;
|
|
285
|
+
* cpuFrame.allocBuffer();
|
|
286
|
+
*
|
|
287
|
+
* const ret = frames.transferDataSync(cpuFrame, hwFrame);
|
|
288
|
+
* FFmpegError.throwIfError(ret, 'transferDataSync');
|
|
289
|
+
*
|
|
290
|
+
* // Upload from CPU to GPU
|
|
291
|
+
* const ret2 = frames.transferDataSync(hwFrame, cpuFrame);
|
|
292
|
+
* FFmpegError.throwIfError(ret2, 'transferDataSync');
|
|
293
|
+
* ```
|
|
294
|
+
*
|
|
295
|
+
* @see {@link transferData} For async version
|
|
296
|
+
*/
|
|
297
|
+
transferDataSync(dst: Frame, src: Frame, flags?: number): number;
|
|
298
|
+
/**
|
|
299
|
+
* Get supported transfer formats.
|
|
300
|
+
*
|
|
301
|
+
* Returns pixel formats supported for frame transfer
|
|
302
|
+
* in the specified direction.
|
|
303
|
+
*
|
|
304
|
+
* Direct mapping to av_hwframe_transfer_get_formats().
|
|
305
|
+
*
|
|
306
|
+
* @param direction - Transfer direction (FROM/TO hardware)
|
|
307
|
+
*
|
|
308
|
+
* @returns Array of supported formats, or error code:
|
|
309
|
+
* - AVERROR_ENOSYS: Query not supported
|
|
310
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* ```typescript
|
|
314
|
+
* import { AV_HWFRAME_TRANSFER_DIRECTION_FROM } from 'node-av/constants';
|
|
315
|
+
*
|
|
316
|
+
* const formats = frames.transferGetFormats(AV_HWFRAME_TRANSFER_DIRECTION_FROM);
|
|
317
|
+
* if (Array.isArray(formats)) {
|
|
318
|
+
* console.log('Supported download formats:', formats);
|
|
319
|
+
* } else {
|
|
320
|
+
* console.error('Error querying formats:', formats);
|
|
321
|
+
* }
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
324
|
+
transferGetFormats(direction: AVHWFrameTransferDirection): AVPixelFormat[] | number;
|
|
325
|
+
/**
|
|
326
|
+
* Map hardware frame to system memory.
|
|
327
|
+
*
|
|
328
|
+
* Creates a mapping of hardware frame data accessible from CPU.
|
|
329
|
+
* More efficient than transferData() for read-only access.
|
|
330
|
+
*
|
|
331
|
+
* Direct mapping to av_hwframe_map().
|
|
332
|
+
*
|
|
333
|
+
* @param dst - Destination frame for mapped data
|
|
334
|
+
*
|
|
335
|
+
* @param src - Hardware frame to map
|
|
336
|
+
*
|
|
337
|
+
* @param flags - Mapping flags (AV_HWFRAME_MAP_*)
|
|
338
|
+
*
|
|
339
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
340
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
341
|
+
* - AVERROR_ENOSYS: Mapping not supported
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```typescript
|
|
345
|
+
* import { FFmpegError } from 'node-av';
|
|
346
|
+
* import { AV_HWFRAME_MAP_READ } from 'node-av/constants';
|
|
347
|
+
*
|
|
348
|
+
* const mappedFrame = new Frame();
|
|
349
|
+
* const ret = frames.map(mappedFrame, hwFrame, AV_HWFRAME_MAP_READ);
|
|
350
|
+
* FFmpegError.throwIfError(ret, 'map');
|
|
351
|
+
* // Can now read hwFrame data through mappedFrame
|
|
352
|
+
* ```
|
|
353
|
+
*
|
|
354
|
+
* @see {@link transferData} For full data copy
|
|
355
|
+
*/
|
|
356
|
+
map(dst: Frame, src: Frame, flags?: number): number;
|
|
357
|
+
/**
|
|
358
|
+
* Create derived frames context.
|
|
359
|
+
*
|
|
360
|
+
* Creates a new frames context derived from another,
|
|
361
|
+
* potentially on a different device.
|
|
362
|
+
*
|
|
363
|
+
* Direct mapping to av_hwframe_ctx_create_derived().
|
|
364
|
+
*
|
|
365
|
+
* @param format - Pixel format for derived frames
|
|
366
|
+
*
|
|
367
|
+
* @param derivedDevice - Target device context
|
|
368
|
+
*
|
|
369
|
+
* @param source - Source frames context
|
|
370
|
+
*
|
|
371
|
+
* @param flags - Creation flags
|
|
372
|
+
*
|
|
373
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
374
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
375
|
+
* - AVERROR_ENOSYS: Derivation not supported
|
|
376
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* ```typescript
|
|
380
|
+
* import { FFmpegError } from 'node-av';
|
|
381
|
+
* import { AV_PIX_FMT_VULKAN } from 'node-av/constants';
|
|
382
|
+
*
|
|
383
|
+
* const derivedFrames = new HardwareFramesContext();
|
|
384
|
+
* const ret = derivedFrames.createDerived(
|
|
385
|
+
* AV_PIX_FMT_VULKAN,
|
|
386
|
+
* vulkanDevice,
|
|
387
|
+
* cudaFrames,
|
|
388
|
+
* 0
|
|
389
|
+
* );
|
|
390
|
+
* FFmpegError.throwIfError(ret, 'createDerived');
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
createDerived(format: AVPixelFormat, derivedDevice: HardwareDeviceContext, source: HardwareFramesContext, flags?: number): number;
|
|
394
|
+
/**
|
|
395
|
+
* Get the underlying native HardwareFramesContext object.
|
|
396
|
+
*
|
|
397
|
+
* @returns The native HardwareFramesContext binding object
|
|
398
|
+
*
|
|
399
|
+
* @internal
|
|
400
|
+
*/
|
|
401
|
+
getNative(): NativeHardwareFramesContext;
|
|
402
|
+
/**
|
|
403
|
+
* Dispose of the hardware frames context.
|
|
404
|
+
*
|
|
405
|
+
* Implements the Disposable interface for automatic cleanup.
|
|
406
|
+
* Equivalent to calling free().
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* ```typescript
|
|
410
|
+
* {
|
|
411
|
+
* using frames = new HardwareFramesContext();
|
|
412
|
+
* frames.alloc(device);
|
|
413
|
+
* frames.init();
|
|
414
|
+
* // Use frames...
|
|
415
|
+
* } // Automatically freed when leaving scope
|
|
416
|
+
* ```
|
|
417
|
+
*/
|
|
418
|
+
[Symbol.dispose](): void;
|
|
419
|
+
}
|