node-av 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -38
- package/dist/api/bitstream-filter.d.ts +180 -123
- package/dist/api/bitstream-filter.js +180 -125
- package/dist/api/bitstream-filter.js.map +1 -1
- package/dist/api/decoder.d.ts +279 -132
- package/dist/api/decoder.js +285 -142
- package/dist/api/decoder.js.map +1 -1
- package/dist/api/encoder.d.ts +246 -162
- package/dist/api/encoder.js +272 -208
- package/dist/api/encoder.js.map +1 -1
- package/dist/api/filter-presets.d.ts +690 -94
- package/dist/api/filter-presets.js +686 -102
- package/dist/api/filter-presets.js.map +1 -1
- package/dist/api/filter.d.ts +249 -213
- package/dist/api/filter.js +252 -242
- package/dist/api/filter.js.map +1 -1
- package/dist/api/hardware.d.ts +224 -117
- package/dist/api/hardware.js +380 -214
- package/dist/api/hardware.js.map +1 -1
- package/dist/api/index.d.ts +3 -3
- package/dist/api/index.js +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/io-stream.d.ts +65 -61
- package/dist/api/io-stream.js +43 -46
- package/dist/api/io-stream.js.map +1 -1
- package/dist/api/media-input.d.ts +242 -140
- package/dist/api/media-input.js +205 -103
- package/dist/api/media-input.js.map +1 -1
- package/dist/api/media-output.d.ts +206 -128
- package/dist/api/media-output.js +210 -128
- package/dist/api/media-output.js.map +1 -1
- package/dist/api/pipeline.d.ts +168 -38
- package/dist/api/pipeline.js +238 -14
- package/dist/api/pipeline.js.map +1 -1
- package/dist/api/types.d.ts +21 -187
- package/dist/api/utils.d.ts +1 -2
- package/dist/api/utils.js +9 -0
- package/dist/api/utils.js.map +1 -1
- package/dist/lib/audio-fifo.d.ts +127 -170
- package/dist/lib/audio-fifo.js +130 -173
- package/dist/lib/audio-fifo.js.map +1 -1
- package/dist/lib/binding.js +5 -0
- package/dist/lib/binding.js.map +1 -1
- package/dist/lib/bitstream-filter-context.d.ts +139 -184
- package/dist/lib/bitstream-filter-context.js +139 -188
- package/dist/lib/bitstream-filter-context.js.map +1 -1
- package/dist/lib/bitstream-filter.d.ts +68 -54
- package/dist/lib/bitstream-filter.js +68 -54
- package/dist/lib/bitstream-filter.js.map +1 -1
- package/dist/lib/codec-context.d.ts +316 -380
- package/dist/lib/codec-context.js +316 -381
- package/dist/lib/codec-context.js.map +1 -1
- package/dist/lib/codec-parameters.d.ts +160 -170
- package/dist/lib/codec-parameters.js +162 -172
- package/dist/lib/codec-parameters.js.map +1 -1
- package/dist/lib/codec-parser.d.ts +91 -104
- package/dist/lib/codec-parser.js +92 -103
- package/dist/lib/codec-parser.js.map +1 -1
- package/dist/lib/codec.d.ts +264 -281
- package/dist/lib/codec.js +268 -285
- package/dist/lib/codec.js.map +1 -1
- package/dist/lib/dictionary.d.ts +149 -203
- package/dist/lib/dictionary.js +158 -212
- package/dist/lib/dictionary.js.map +1 -1
- package/dist/lib/error.d.ts +96 -130
- package/dist/lib/error.js +98 -128
- package/dist/lib/error.js.map +1 -1
- package/dist/lib/filter-context.d.ts +284 -218
- package/dist/lib/filter-context.js +290 -227
- package/dist/lib/filter-context.js.map +1 -1
- package/dist/lib/filter-graph.d.ts +251 -292
- package/dist/lib/filter-graph.js +253 -294
- package/dist/lib/filter-graph.js.map +1 -1
- package/dist/lib/filter-inout.d.ts +87 -95
- package/dist/lib/filter-inout.js +87 -95
- package/dist/lib/filter-inout.js.map +1 -1
- package/dist/lib/filter.d.ts +93 -111
- package/dist/lib/filter.js +93 -111
- package/dist/lib/filter.js.map +1 -1
- package/dist/lib/format-context.d.ts +320 -428
- package/dist/lib/format-context.js +313 -385
- package/dist/lib/format-context.js.map +1 -1
- package/dist/lib/frame.d.ts +262 -405
- package/dist/lib/frame.js +263 -408
- package/dist/lib/frame.js.map +1 -1
- package/dist/lib/hardware-device-context.d.ts +149 -203
- package/dist/lib/hardware-device-context.js +149 -203
- package/dist/lib/hardware-device-context.js.map +1 -1
- package/dist/lib/hardware-frames-context.d.ts +170 -180
- package/dist/lib/hardware-frames-context.js +171 -181
- package/dist/lib/hardware-frames-context.js.map +1 -1
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/index.js +2 -2
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/input-format.d.ts +89 -117
- package/dist/lib/input-format.js +89 -117
- package/dist/lib/input-format.js.map +1 -1
- package/dist/lib/io-context.d.ts +209 -241
- package/dist/lib/io-context.js +220 -252
- package/dist/lib/io-context.js.map +1 -1
- package/dist/lib/log.d.ts +85 -119
- package/dist/lib/log.js +85 -122
- package/dist/lib/log.js.map +1 -1
- package/dist/lib/native-types.d.ts +117 -106
- package/dist/lib/native-types.js +0 -7
- package/dist/lib/native-types.js.map +1 -1
- package/dist/lib/option.d.ts +284 -241
- package/dist/lib/option.js +309 -249
- package/dist/lib/option.js.map +1 -1
- package/dist/lib/output-format.d.ts +77 -101
- package/dist/lib/output-format.js +77 -101
- package/dist/lib/output-format.js.map +1 -1
- package/dist/lib/packet.d.ts +172 -240
- package/dist/lib/packet.js +172 -241
- package/dist/lib/packet.js.map +1 -1
- package/dist/lib/rational.d.ts +0 -2
- package/dist/lib/rational.js +0 -2
- package/dist/lib/rational.js.map +1 -1
- package/dist/lib/software-resample-context.d.ts +241 -325
- package/dist/lib/software-resample-context.js +242 -326
- package/dist/lib/software-resample-context.js.map +1 -1
- package/dist/lib/software-scale-context.d.ts +129 -173
- package/dist/lib/software-scale-context.js +131 -175
- package/dist/lib/software-scale-context.js.map +1 -1
- package/dist/lib/stream.d.ts +87 -197
- package/dist/lib/stream.js +87 -197
- package/dist/lib/stream.js.map +1 -1
- package/dist/lib/utilities.d.ts +372 -181
- package/dist/lib/utilities.js +373 -182
- package/dist/lib/utilities.js.map +1 -1
- package/install/check.js +0 -1
- package/package.json +21 -12
- package/release_notes.md +43 -59
- package/CHANGELOG.md +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"software-resample-context.js","sourceRoot":"","sources":["../../src/lib/software-resample-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAO3C
|
|
1
|
+
{"version":3,"file":"software-resample-context.js","sourceRoot":"","sources":["../../src/lib/software-resample-context.ts"],"names":[],"mappings":"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"}
|
|
@@ -3,288 +3,244 @@ import type { AVPixelFormat, SWSFlag } from '../constants/constants.js';
|
|
|
3
3
|
import type { Frame } from './frame.js';
|
|
4
4
|
import type { NativeSoftwareScaleContext, NativeWrapper } from './native-types.js';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Video scaling and pixel format conversion context.
|
|
7
7
|
*
|
|
8
|
-
* Provides high-quality
|
|
8
|
+
* Provides high-quality image scaling and pixel format conversion for video frames.
|
|
9
9
|
* Supports various scaling algorithms from fast bilinear to high-quality Lanczos.
|
|
10
|
-
*
|
|
10
|
+
* Essential for resolution changes, aspect ratio adjustments, and format compatibility
|
|
11
|
+
* in video processing pipelines.
|
|
11
12
|
*
|
|
12
13
|
* Direct mapping to FFmpeg's SwsContext.
|
|
13
14
|
*
|
|
14
15
|
* @example
|
|
15
16
|
* ```typescript
|
|
16
17
|
* import { SoftwareScaleContext, Frame, FFmpegError } from 'node-av';
|
|
17
|
-
* import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_RGB24,
|
|
18
|
+
* import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_RGB24, SWS_LANCZOS } from 'node-av/constants';
|
|
18
19
|
*
|
|
19
|
-
* // Create
|
|
20
|
-
* const
|
|
21
|
-
* sws.getContext(
|
|
22
|
-
* 1920, 1080, AV_PIX_FMT_YUV420P,
|
|
23
|
-
* 1280, 720, AV_PIX_FMT_RGB24,
|
|
24
|
-
* SWS_BILINEAR
|
|
25
|
-
* );
|
|
20
|
+
* // Create scaler
|
|
21
|
+
* const scaler = new SoftwareScaleContext();
|
|
26
22
|
*
|
|
27
|
-
* //
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
23
|
+
* // Configure scaling: 1920x1080 YUV420P -> 1280x720 RGB24
|
|
24
|
+
* scaler.getContext(
|
|
25
|
+
* 1920, 1080, AV_PIX_FMT_YUV420P, // Source
|
|
26
|
+
* 1280, 720, AV_PIX_FMT_RGB24, // Destination
|
|
27
|
+
* SWS_LANCZOS // High quality
|
|
31
28
|
* );
|
|
32
29
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
30
|
+
* const ret = scaler.initContext();
|
|
31
|
+
* FFmpegError.throwIfError(ret, 'initContext');
|
|
32
|
+
*
|
|
33
|
+
* // Scale frames
|
|
34
|
+
* const dstFrame = new Frame();
|
|
35
|
+
* dstFrame.width = 1280;
|
|
36
|
+
* dstFrame.height = 720;
|
|
37
|
+
* dstFrame.format = AV_PIX_FMT_RGB24;
|
|
38
|
+
* dstFrame.allocBuffer();
|
|
39
|
+
*
|
|
40
|
+
* const height = await scaler.scaleFrame(dstFrame, srcFrame);
|
|
41
|
+
* console.log(`Scaled to ${height} lines`);
|
|
36
42
|
*
|
|
37
|
-
* //
|
|
38
|
-
*
|
|
43
|
+
* // Clean up
|
|
44
|
+
* scaler.freeContext();
|
|
39
45
|
* ```
|
|
46
|
+
*
|
|
47
|
+
* @see [SwsContext](https://ffmpeg.org/doxygen/trunk/structSwsContext.html) - FFmpeg Doxygen
|
|
48
|
+
* @see {@link Frame} For video frame operations
|
|
40
49
|
*/
|
|
41
50
|
export declare class SoftwareScaleContext extends OptionMember<NativeSoftwareScaleContext> implements Disposable, NativeWrapper<NativeSoftwareScaleContext> {
|
|
42
|
-
/**
|
|
43
|
-
* Create a new software scale context.
|
|
44
|
-
*
|
|
45
|
-
* The context is uninitialized - you must call allocContext() or getContext() before use.
|
|
46
|
-
* No FFmpeg resources are allocated until initialization.
|
|
47
|
-
*
|
|
48
|
-
* Direct wrapper around SwsContext.
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```typescript
|
|
52
|
-
* import { SoftwareScaleContext } from 'node-av';
|
|
53
|
-
* import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_RGB24, SWS_BILINEAR } from 'node-av/constants';
|
|
54
|
-
*
|
|
55
|
-
* const sws = new SoftwareScaleContext();
|
|
56
|
-
* sws.getContext(
|
|
57
|
-
* 1920, 1080, AV_PIX_FMT_YUV420P,
|
|
58
|
-
* 1280, 720, AV_PIX_FMT_RGB24,
|
|
59
|
-
* SWS_BILINEAR
|
|
60
|
-
* );
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
51
|
constructor();
|
|
64
52
|
/**
|
|
65
|
-
* Allocate
|
|
53
|
+
* Allocate scale context.
|
|
66
54
|
*
|
|
67
|
-
* Allocates
|
|
68
|
-
*
|
|
55
|
+
* Allocates memory for the scaler.
|
|
56
|
+
* Must be called before configuration if using options.
|
|
69
57
|
*
|
|
70
|
-
* Direct mapping to sws_alloc_context()
|
|
71
|
-
*
|
|
72
|
-
* @throws {Error} Memory allocation failure (ENOMEM)
|
|
58
|
+
* Direct mapping to sws_alloc_context().
|
|
73
59
|
*
|
|
74
60
|
* @example
|
|
75
61
|
* ```typescript
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* sws.allocContext();
|
|
80
|
-
* // Set options via AVOptions API
|
|
81
|
-
* const ret = sws.initContext();
|
|
82
|
-
* FFmpegError.throwIfError(ret, 'initContext');
|
|
62
|
+
* const scaler = new SoftwareScaleContext();
|
|
63
|
+
* scaler.allocContext();
|
|
64
|
+
* // Now configure with setOption() or getContext()
|
|
83
65
|
* ```
|
|
84
66
|
*
|
|
85
|
-
* @see {@link getContext} For
|
|
86
|
-
* @see {@link initContext} To initialize after configuration
|
|
67
|
+
* @see {@link getContext} For direct configuration
|
|
87
68
|
*/
|
|
88
69
|
allocContext(): void;
|
|
89
70
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
* Direct mapping to sws_getContext()
|
|
96
|
-
*
|
|
97
|
-
* @param srcW -
|
|
98
|
-
* @param srcH -
|
|
99
|
-
* @param srcFormat -
|
|
100
|
-
* @param dstW -
|
|
101
|
-
* @param dstH -
|
|
102
|
-
* @param dstFormat -
|
|
103
|
-
* @param flags -
|
|
104
|
-
* - SWS_FAST_BILINEAR: Fast bilinear
|
|
105
|
-
* - SWS_BILINEAR: Bilinear
|
|
106
|
-
* - SWS_BICUBIC: Bicubic
|
|
107
|
-
* - SWS_X: Experimental
|
|
108
|
-
* - SWS_POINT: Nearest neighbor
|
|
109
|
-
* - SWS_AREA: Area averaging
|
|
110
|
-
* - SWS_BICUBLIN: Luma bicubic, chroma bilinear
|
|
111
|
-
* - SWS_GAUSS: Gaussian
|
|
112
|
-
* - SWS_SINC: Sinc
|
|
113
|
-
* - SWS_LANCZOS: Lanczos
|
|
114
|
-
* - SWS_SPLINE: Natural bicubic spline
|
|
115
|
-
*
|
|
116
|
-
* @throws {Error} Memory allocation failure (ENOMEM)
|
|
71
|
+
* Configure scaling context.
|
|
72
|
+
*
|
|
73
|
+
* Sets up the scaler with source and destination formats.
|
|
74
|
+
* This is the primary configuration method.
|
|
75
|
+
*
|
|
76
|
+
* Direct mapping to sws_getContext().
|
|
77
|
+
*
|
|
78
|
+
* @param srcW - Source width in pixels
|
|
79
|
+
* @param srcH - Source height in pixels
|
|
80
|
+
* @param srcFormat - Source pixel format
|
|
81
|
+
* @param dstW - Destination width in pixels
|
|
82
|
+
* @param dstH - Destination height in pixels
|
|
83
|
+
* @param dstFormat - Destination pixel format
|
|
84
|
+
* @param flags - Scaling algorithm flags (SWS_*)
|
|
117
85
|
*
|
|
118
86
|
* @example
|
|
119
87
|
* ```typescript
|
|
120
|
-
* import {
|
|
121
|
-
* import {
|
|
88
|
+
* import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_RGB24 } from 'node-av/constants';
|
|
89
|
+
* import { SWS_BILINEAR, SWS_BICUBIC, SWS_LANCZOS, SWS_FAST_BILINEAR } from 'node-av/constants';
|
|
122
90
|
*
|
|
123
|
-
* //
|
|
124
|
-
*
|
|
91
|
+
* // Fast bilinear (lower quality, faster)
|
|
92
|
+
* scaler.getContext(
|
|
125
93
|
* 1920, 1080, AV_PIX_FMT_YUV420P,
|
|
126
94
|
* 1280, 720, AV_PIX_FMT_RGB24,
|
|
127
|
-
*
|
|
95
|
+
* SWS_FAST_BILINEAR
|
|
96
|
+
* );
|
|
97
|
+
*
|
|
98
|
+
* // High quality Lanczos (higher quality, slower)
|
|
99
|
+
* scaler.getContext(
|
|
100
|
+
* 1920, 1080, AV_PIX_FMT_YUV420P,
|
|
101
|
+
* 3840, 2160, AV_PIX_FMT_YUV420P, // Upscaling
|
|
102
|
+
* SWS_LANCZOS
|
|
128
103
|
* );
|
|
129
104
|
* ```
|
|
130
105
|
*
|
|
131
|
-
* @see {@link
|
|
132
|
-
* @see {@link scaleFrame} To scale Frame objects
|
|
106
|
+
* @see {@link initContext} Must be called after configuration
|
|
133
107
|
*/
|
|
134
108
|
getContext(srcW: number, srcH: number, srcFormat: AVPixelFormat, dstW: number, dstH: number, dstFormat: AVPixelFormat, flags?: SWSFlag): void;
|
|
135
109
|
/**
|
|
136
|
-
* Initialize
|
|
110
|
+
* Initialize scaling context.
|
|
137
111
|
*
|
|
138
|
-
*
|
|
139
|
-
* Must be called
|
|
112
|
+
* Initializes the scaler after configuration.
|
|
113
|
+
* Must be called before any scaling operations.
|
|
140
114
|
*
|
|
141
|
-
* Direct mapping to sws_init_context()
|
|
115
|
+
* Direct mapping to sws_init_context().
|
|
142
116
|
*
|
|
143
117
|
* @returns 0 on success, negative AVERROR on error:
|
|
144
|
-
* -
|
|
145
|
-
* -
|
|
146
|
-
* - AVERROR(ENOMEM): Memory allocation failure
|
|
147
|
-
* - <0: Other errors
|
|
118
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
119
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
148
120
|
*
|
|
149
121
|
* @example
|
|
150
122
|
* ```typescript
|
|
151
123
|
* import { FFmpegError } from 'node-av';
|
|
152
124
|
*
|
|
153
|
-
* const ret =
|
|
125
|
+
* const ret = scaler.initContext();
|
|
154
126
|
* FFmpegError.throwIfError(ret, 'initContext');
|
|
155
127
|
* ```
|
|
156
128
|
*
|
|
157
|
-
* @see {@link
|
|
158
|
-
* @see {@link getContext} For one-step setup
|
|
129
|
+
* @see {@link getContext} For configuration
|
|
159
130
|
*/
|
|
160
131
|
initContext(): number;
|
|
161
132
|
/**
|
|
162
|
-
* Free
|
|
133
|
+
* Free scaling context.
|
|
163
134
|
*
|
|
164
|
-
* Releases all resources associated with the
|
|
165
|
-
*
|
|
135
|
+
* Releases all resources associated with the scaler.
|
|
136
|
+
* The context becomes invalid after calling this.
|
|
166
137
|
*
|
|
167
|
-
* Direct mapping to sws_freeContext()
|
|
138
|
+
* Direct mapping to sws_freeContext().
|
|
168
139
|
*
|
|
169
140
|
* @example
|
|
170
141
|
* ```typescript
|
|
171
|
-
*
|
|
172
|
-
* //
|
|
142
|
+
* scaler.freeContext();
|
|
143
|
+
* // Scaler is now invalid
|
|
173
144
|
* ```
|
|
145
|
+
*
|
|
146
|
+
* @see {@link Symbol.dispose} For automatic cleanup
|
|
174
147
|
*/
|
|
175
148
|
freeContext(): void;
|
|
176
149
|
/**
|
|
177
|
-
* Scale
|
|
178
|
-
*
|
|
179
|
-
* Scales image data from source to destination.
|
|
180
|
-
* Processes image in slices for efficient memory usage.
|
|
150
|
+
* Scale image data.
|
|
181
151
|
*
|
|
182
|
-
*
|
|
152
|
+
* Scales raw image data from source to destination buffers.
|
|
153
|
+
* Low-level interface for custom buffer management.
|
|
183
154
|
*
|
|
184
|
-
*
|
|
185
|
-
* @param srcStride - The array containing the strides for each plane of the source image
|
|
186
|
-
* @param srcSliceY - The position in the source image of the slice to process (first row number)
|
|
187
|
-
* @param srcSliceH - The height of the source slice (number of rows)
|
|
188
|
-
* @param dst - The array containing the pointers to the planes of the destination image
|
|
189
|
-
* @param dstStride - The array containing the strides for each plane of the destination image
|
|
155
|
+
* Direct mapping to sws_scale().
|
|
190
156
|
*
|
|
191
|
-
* @
|
|
157
|
+
* @param srcSlice - Source data planes (one buffer per plane)
|
|
158
|
+
* @param srcStride - Bytes per line for each plane
|
|
159
|
+
* @param srcSliceY - Starting Y position in source
|
|
160
|
+
* @param srcSliceH - Height of source slice to process
|
|
161
|
+
* @param dst - Destination data planes
|
|
162
|
+
* @param dstStride - Destination bytes per line
|
|
163
|
+
* @returns Output height in pixels, negative AVERROR on error:
|
|
164
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
192
165
|
*
|
|
193
166
|
* @example
|
|
194
167
|
* ```typescript
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
168
|
+
* // Scale YUV420P data
|
|
169
|
+
* const srcPlanes = [yPlane, uPlane, vPlane];
|
|
170
|
+
* const srcStrides = [1920, 960, 960]; // Full HD
|
|
171
|
+
* const dstPlanes = [dstY, dstU, dstV];
|
|
172
|
+
* const dstStrides = [1280, 640, 640]; // 720p
|
|
173
|
+
*
|
|
174
|
+
* const height = await scaler.scale(
|
|
175
|
+
* srcPlanes, srcStrides, 0, 1080,
|
|
176
|
+
* dstPlanes, dstStrides
|
|
202
177
|
* );
|
|
203
|
-
* console.log(`Scaled ${
|
|
178
|
+
* console.log(`Scaled ${height} lines`);
|
|
204
179
|
* ```
|
|
205
180
|
*
|
|
206
|
-
* @see {@link scaleFrame} For
|
|
207
|
-
*
|
|
208
|
-
* @note Slices must be provided in sequential order (top-bottom or bottom-top).
|
|
209
|
-
* Non-sequential order results in undefined behavior.
|
|
181
|
+
* @see {@link scaleFrame} For frame-based scaling
|
|
210
182
|
*/
|
|
211
183
|
scale(srcSlice: Buffer[], srcStride: number[], srcSliceY: number, srcSliceH: number, dst: Buffer[], dstStride: number[]): Promise<number>;
|
|
212
184
|
/**
|
|
213
|
-
* Scale
|
|
214
|
-
*
|
|
215
|
-
* Frame-based scaling with automatic configuration.
|
|
216
|
-
* Dynamically adapts to frame properties without reallocation.
|
|
185
|
+
* Scale video frame.
|
|
217
186
|
*
|
|
218
|
-
*
|
|
187
|
+
* Scales an entire video frame to the destination format.
|
|
188
|
+
* Simpler interface than scale() for frame-based processing.
|
|
219
189
|
*
|
|
220
|
-
*
|
|
221
|
-
* @param src - The source frame
|
|
190
|
+
* Direct mapping to sws_scale_frame().
|
|
222
191
|
*
|
|
223
|
-
* @
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
* -
|
|
227
|
-
* -
|
|
192
|
+
* @param dst - Destination frame (must be allocated)
|
|
193
|
+
* @param src - Source frame
|
|
194
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
195
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
196
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
228
197
|
*
|
|
229
198
|
* @example
|
|
230
199
|
* ```typescript
|
|
231
200
|
* import { Frame, FFmpegError } from 'node-av';
|
|
232
201
|
* import { AV_PIX_FMT_RGB24 } from 'node-av/constants';
|
|
233
202
|
*
|
|
234
|
-
*
|
|
235
|
-
* srcFrame.alloc();
|
|
236
|
-
* // ... fill srcFrame with data ...
|
|
237
|
-
*
|
|
203
|
+
* // Create destination frame
|
|
238
204
|
* const dstFrame = new Frame();
|
|
239
|
-
* dstFrame.alloc();
|
|
240
205
|
* dstFrame.width = 1280;
|
|
241
206
|
* dstFrame.height = 720;
|
|
242
207
|
* dstFrame.format = AV_PIX_FMT_RGB24;
|
|
243
|
-
* const
|
|
244
|
-
* FFmpegError.throwIfError(
|
|
208
|
+
* const ret = dstFrame.allocBuffer();
|
|
209
|
+
* FFmpegError.throwIfError(ret, 'allocBuffer');
|
|
210
|
+
*
|
|
211
|
+
* // Scale frame
|
|
212
|
+
* const ret2 = await scaler.scaleFrame(dstFrame, srcFrame);
|
|
213
|
+
* FFmpegError.throwIfError(ret2, 'scaleFrame');
|
|
245
214
|
*
|
|
246
|
-
*
|
|
247
|
-
* FFmpegError.throwIfError(ret, 'scaleFrame');
|
|
248
|
-
* console.log(`Scaled to height: ${ret}`);
|
|
215
|
+
* // dstFrame now contains scaled image
|
|
249
216
|
* ```
|
|
250
217
|
*
|
|
251
218
|
* @see {@link scale} For buffer-based scaling
|
|
252
|
-
*
|
|
253
|
-
* @note This function can be used directly on an allocated context without
|
|
254
|
-
* calling sws_init_context(). Such usage is fully dynamic and does not
|
|
255
|
-
* require reallocation if frame properties change.
|
|
256
219
|
*/
|
|
257
220
|
scaleFrame(dst: Frame, src: Frame): Promise<number>;
|
|
258
221
|
/**
|
|
259
|
-
* Get the native
|
|
222
|
+
* Get the underlying native SoftwareScaleContext object.
|
|
223
|
+
*
|
|
224
|
+
* @returns The native SoftwareScaleContext binding object
|
|
260
225
|
*
|
|
261
|
-
* @internal
|
|
262
|
-
* @returns The underlying native scale context object
|
|
226
|
+
* @internal
|
|
263
227
|
*/
|
|
264
228
|
getNative(): NativeSoftwareScaleContext;
|
|
265
229
|
/**
|
|
266
|
-
* Dispose of the
|
|
230
|
+
* Dispose of the scaling context.
|
|
267
231
|
*
|
|
268
232
|
* Implements the Disposable interface for automatic cleanup.
|
|
269
233
|
* Equivalent to calling freeContext().
|
|
270
234
|
*
|
|
271
235
|
* @example
|
|
272
236
|
* ```typescript
|
|
273
|
-
* import { SoftwareScaleContext } from 'node-av';
|
|
274
|
-
* import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_RGB24, SWS_BILINEAR } from 'node-av/constants';
|
|
275
|
-
*
|
|
276
237
|
* {
|
|
277
|
-
* using
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
* SWS_BILINEAR
|
|
282
|
-
* );
|
|
283
|
-
* // ... use context
|
|
238
|
+
* using scaler = new SoftwareScaleContext();
|
|
239
|
+
* scaler.getContext(...);
|
|
240
|
+
* scaler.initContext();
|
|
241
|
+
* // Use scaler...
|
|
284
242
|
* } // Automatically freed when leaving scope
|
|
285
243
|
* ```
|
|
286
|
-
*
|
|
287
|
-
* @see {@link freeContext} For manual cleanup
|
|
288
244
|
*/
|
|
289
245
|
[Symbol.dispose](): void;
|
|
290
246
|
}
|