node-av-light 0.0.0-stage → 7.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +22 -0
- package/README.md +710 -2
- package/dist/api/audio-frame-buffer.d.ts +636 -0
- package/dist/api/audio-frame-buffer.js +1027 -0
- package/dist/api/audio-frame-buffer.js.map +1 -0
- package/dist/api/bitstream-filter.d.ts +938 -0
- package/dist/api/bitstream-filter.js +1427 -0
- package/dist/api/bitstream-filter.js.map +1 -0
- package/dist/api/constants.d.ts +44 -0
- package/dist/api/constants.js +45 -0
- package/dist/api/constants.js.map +1 -0
- package/dist/api/data/test_av1.ivf +0 -0
- package/dist/api/data/test_h264.h264 +0 -0
- package/dist/api/data/test_hevc.h265 +0 -0
- package/dist/api/data/test_mjpeg.mjpeg +0 -0
- package/dist/api/data/test_vp8.ivf +0 -0
- package/dist/api/data/test_vp9.ivf +0 -0
- package/dist/api/decoder.d.ts +1413 -0
- package/dist/api/decoder.js +2367 -0
- package/dist/api/decoder.js.map +1 -0
- package/dist/api/demuxer.d.ts +1295 -0
- package/dist/api/demuxer.js +2344 -0
- package/dist/api/demuxer.js.map +1 -0
- package/dist/api/device.d.ts +589 -0
- package/dist/api/device.js +964 -0
- package/dist/api/device.js.map +1 -0
- package/dist/api/encoder-pool.d.ts +262 -0
- package/dist/api/encoder-pool.js +397 -0
- package/dist/api/encoder-pool.js.map +1 -0
- package/dist/api/encoder.d.ts +1509 -0
- package/dist/api/encoder.js +2619 -0
- package/dist/api/encoder.js.map +1 -0
- package/dist/api/filter-complex.d.ts +828 -0
- package/dist/api/filter-complex.js +1661 -0
- package/dist/api/filter-complex.js.map +1 -0
- package/dist/api/filter-presets.d.ts +800 -0
- package/dist/api/filter-presets.js +1554 -0
- package/dist/api/filter-presets.js.map +1 -0
- package/dist/api/filter.d.ts +1339 -0
- package/dist/api/filter.js +2075 -0
- package/dist/api/filter.js.map +1 -0
- package/dist/api/fmp4-stream.d.ts +797 -0
- package/dist/api/fmp4-stream.js +1428 -0
- package/dist/api/fmp4-stream.js.map +1 -0
- package/dist/api/hardware.d.ts +677 -0
- package/dist/api/hardware.js +1300 -0
- package/dist/api/hardware.js.map +1 -0
- package/dist/api/index.d.ts +21 -0
- package/dist/api/index.js +38 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/io-stream.d.ts +308 -0
- package/dist/api/io-stream.js +358 -0
- package/dist/api/io-stream.js.map +1 -0
- package/dist/api/muxer.d.ts +1311 -0
- package/dist/api/muxer.js +2672 -0
- package/dist/api/muxer.js.map +1 -0
- package/dist/api/pipeline.d.ts +801 -0
- package/dist/api/pipeline.js +1344 -0
- package/dist/api/pipeline.js.map +1 -0
- package/dist/api/probe.d.ts +128 -0
- package/dist/api/probe.js +227 -0
- package/dist/api/probe.js.map +1 -0
- package/dist/api/rtp-stream.d.ts +497 -0
- package/dist/api/rtp-stream.js +1131 -0
- package/dist/api/rtp-stream.js.map +1 -0
- package/dist/api/scaler.d.ts +561 -0
- package/dist/api/scaler.js +918 -0
- package/dist/api/scaler.js.map +1 -0
- package/dist/api/types.d.ts +17 -0
- package/dist/api/types.js +2 -0
- package/dist/api/types.js.map +1 -0
- package/dist/api/utilities/async-queue.d.ts +149 -0
- package/dist/api/utilities/async-queue.js +254 -0
- package/dist/api/utilities/async-queue.js.map +1 -0
- package/dist/api/utilities/audio-sample.d.ts +117 -0
- package/dist/api/utilities/audio-sample.js +112 -0
- package/dist/api/utilities/audio-sample.js.map +1 -0
- package/dist/api/utilities/audio-transcode.d.ts +20 -0
- package/dist/api/utilities/audio-transcode.js +27 -0
- package/dist/api/utilities/audio-transcode.js.map +1 -0
- package/dist/api/utilities/channel-layout.d.ts +76 -0
- package/dist/api/utilities/channel-layout.js +80 -0
- package/dist/api/utilities/channel-layout.js.map +1 -0
- package/dist/api/utilities/codec-format.d.ts +87 -0
- package/dist/api/utilities/codec-format.js +117 -0
- package/dist/api/utilities/codec-format.js.map +1 -0
- package/dist/api/utilities/context-options.d.ts +25 -0
- package/dist/api/utilities/context-options.js +23 -0
- package/dist/api/utilities/context-options.js.map +1 -0
- package/dist/api/utilities/electron-shared-texture.d.ts +368 -0
- package/dist/api/utilities/electron-shared-texture.js +540 -0
- package/dist/api/utilities/electron-shared-texture.js.map +1 -0
- package/dist/api/utilities/image.d.ts +207 -0
- package/dist/api/utilities/image.js +213 -0
- package/dist/api/utilities/image.js.map +1 -0
- package/dist/api/utilities/index.d.ts +14 -0
- package/dist/api/utilities/index.js +27 -0
- package/dist/api/utilities/index.js.map +1 -0
- package/dist/api/utilities/live-decoding.d.ts +15 -0
- package/dist/api/utilities/live-decoding.js +32 -0
- package/dist/api/utilities/live-decoding.js.map +1 -0
- package/dist/api/utilities/media-type.d.ts +49 -0
- package/dist/api/utilities/media-type.js +53 -0
- package/dist/api/utilities/media-type.js.map +1 -0
- package/dist/api/utilities/packet-age-watchdog.d.ts +198 -0
- package/dist/api/utilities/packet-age-watchdog.js +594 -0
- package/dist/api/utilities/packet-age-watchdog.js.map +1 -0
- package/dist/api/utilities/pixel-format.d.ts +89 -0
- package/dist/api/utilities/pixel-format.js +97 -0
- package/dist/api/utilities/pixel-format.js.map +1 -0
- package/dist/api/utilities/sample-format.d.ts +129 -0
- package/dist/api/utilities/sample-format.js +141 -0
- package/dist/api/utilities/sample-format.js.map +1 -0
- package/dist/api/utilities/scale-size.d.ts +51 -0
- package/dist/api/utilities/scale-size.js +55 -0
- package/dist/api/utilities/scale-size.js.map +1 -0
- package/dist/api/utilities/scheduler.d.ts +138 -0
- package/dist/api/utilities/scheduler.js +98 -0
- package/dist/api/utilities/scheduler.js.map +1 -0
- package/dist/api/utilities/streaming.d.ts +186 -0
- package/dist/api/utilities/streaming.js +309 -0
- package/dist/api/utilities/streaming.js.map +1 -0
- package/dist/api/utilities/timestamp.d.ts +193 -0
- package/dist/api/utilities/timestamp.js +206 -0
- package/dist/api/utilities/timestamp.js.map +1 -0
- package/dist/api/utilities/video-transcode.d.ts +218 -0
- package/dist/api/utilities/video-transcode.js +624 -0
- package/dist/api/utilities/video-transcode.js.map +1 -0
- package/dist/api/utilities/whisper-model.d.ts +330 -0
- package/dist/api/utilities/whisper-model.js +587 -0
- package/dist/api/utilities/whisper-model.js.map +1 -0
- package/dist/api/utils.d.ts +19 -0
- package/dist/api/utils.js +39 -0
- package/dist/api/utils.js.map +1 -0
- package/dist/api/webrtc-stream.d.ts +294 -0
- package/dist/api/webrtc-stream.js +546 -0
- package/dist/api/webrtc-stream.js.map +1 -0
- package/dist/api/whisper.d.ts +326 -0
- package/dist/api/whisper.js +402 -0
- package/dist/api/whisper.js.map +1 -0
- package/dist/constants/bsf-options.d.ts +364 -0
- package/dist/constants/bsf-options.js +7 -0
- package/dist/constants/bsf-options.js.map +1 -0
- package/dist/constants/channel-layouts.d.ts +53 -0
- package/dist/constants/channel-layouts.js +57 -0
- package/dist/constants/channel-layouts.js.map +1 -0
- package/dist/constants/constants.d.ts +2435 -0
- package/dist/constants/constants.js +1989 -0
- package/dist/constants/constants.js.map +1 -0
- package/dist/constants/decoders.d.ts +651 -0
- package/dist/constants/decoders.js +641 -0
- package/dist/constants/decoders.js.map +1 -0
- package/dist/constants/encoders.d.ts +314 -0
- package/dist/constants/encoders.js +309 -0
- package/dist/constants/encoders.js.map +1 -0
- package/dist/constants/filter-options.d.ts +12099 -0
- package/dist/constants/filter-options.js +7 -0
- package/dist/constants/filter-options.js.map +1 -0
- package/dist/constants/format-options.d.ts +4319 -0
- package/dist/constants/format-options.js +7 -0
- package/dist/constants/format-options.js.map +1 -0
- package/dist/constants/formats.d.ts +18 -0
- package/dist/constants/formats.js +7 -0
- package/dist/constants/formats.js.map +1 -0
- package/dist/constants/hardware.d.ts +26 -0
- package/dist/constants/hardware.js +27 -0
- package/dist/constants/hardware.js.map +1 -0
- package/dist/constants/index.d.ts +10 -0
- package/dist/constants/index.js +6 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/options.d.ts +6217 -0
- package/dist/constants/options.js +7 -0
- package/dist/constants/options.js.map +1 -0
- package/dist/ffmpeg/index.d.ts +101 -0
- package/dist/ffmpeg/index.js +161 -0
- package/dist/ffmpeg/index.js.map +1 -0
- package/dist/ffmpeg/version.d.ts +6 -0
- package/dist/ffmpeg/version.js +7 -0
- package/dist/ffmpeg/version.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/audio-fifo.d.ts +399 -0
- package/dist/lib/audio-fifo.js +431 -0
- package/dist/lib/audio-fifo.js.map +1 -0
- package/dist/lib/binding.d.ts +242 -0
- package/dist/lib/binding.js +102 -0
- package/dist/lib/binding.js.map +1 -0
- package/dist/lib/bitstream-filter-context.d.ts +381 -0
- package/dist/lib/bitstream-filter-context.js +443 -0
- package/dist/lib/bitstream-filter-context.js.map +1 -0
- package/dist/lib/bitstream-filter.d.ts +140 -0
- package/dist/lib/bitstream-filter.js +154 -0
- package/dist/lib/bitstream-filter.js.map +1 -0
- package/dist/lib/codec-context.d.ts +1069 -0
- package/dist/lib/codec-context.js +1336 -0
- package/dist/lib/codec-context.js.map +1 -0
- package/dist/lib/codec-parameters.d.ts +664 -0
- package/dist/lib/codec-parameters.js +813 -0
- package/dist/lib/codec-parameters.js.map +1 -0
- package/dist/lib/codec-parser.d.ts +201 -0
- package/dist/lib/codec-parser.js +213 -0
- package/dist/lib/codec-parser.js.map +1 -0
- package/dist/lib/codec.d.ts +617 -0
- package/dist/lib/codec.js +746 -0
- package/dist/lib/codec.js.map +1 -0
- package/dist/lib/device.d.ts +294 -0
- package/dist/lib/device.js +326 -0
- package/dist/lib/device.js.map +1 -0
- package/dist/lib/dictionary.d.ts +333 -0
- package/dist/lib/dictionary.js +372 -0
- package/dist/lib/dictionary.js.map +1 -0
- package/dist/lib/error.d.ts +311 -0
- package/dist/lib/error.js +395 -0
- package/dist/lib/error.js.map +1 -0
- package/dist/lib/fifo.d.ts +416 -0
- package/dist/lib/fifo.js +453 -0
- package/dist/lib/fifo.js.map +1 -0
- package/dist/lib/filter-context.d.ts +714 -0
- package/dist/lib/filter-context.js +783 -0
- package/dist/lib/filter-context.js.map +1 -0
- package/dist/lib/filter-graph-segment.d.ts +161 -0
- package/dist/lib/filter-graph-segment.js +172 -0
- package/dist/lib/filter-graph-segment.js.map +1 -0
- package/dist/lib/filter-graph.d.ts +641 -0
- package/dist/lib/filter-graph.js +704 -0
- package/dist/lib/filter-graph.js.map +1 -0
- package/dist/lib/filter-inout.d.ts +202 -0
- package/dist/lib/filter-inout.js +261 -0
- package/dist/lib/filter-inout.js.map +1 -0
- package/dist/lib/filter.d.ts +243 -0
- package/dist/lib/filter.js +272 -0
- package/dist/lib/filter.js.map +1 -0
- package/dist/lib/format-context.d.ts +1335 -0
- package/dist/lib/format-context.js +1455 -0
- package/dist/lib/format-context.js.map +1 -0
- package/dist/lib/frame-utils.d.ts +116 -0
- package/dist/lib/frame-utils.js +98 -0
- package/dist/lib/frame-utils.js.map +1 -0
- package/dist/lib/frame.d.ts +1315 -0
- package/dist/lib/frame.js +1535 -0
- package/dist/lib/frame.js.map +1 -0
- package/dist/lib/hardware-device-context.d.ts +362 -0
- package/dist/lib/hardware-device-context.js +383 -0
- package/dist/lib/hardware-device-context.js.map +1 -0
- package/dist/lib/hardware-frames-context.d.ts +418 -0
- package/dist/lib/hardware-frames-context.js +471 -0
- package/dist/lib/hardware-frames-context.js.map +1 -0
- package/dist/lib/index.d.ts +35 -0
- package/dist/lib/index.js +60 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/input-format.d.ts +249 -0
- package/dist/lib/input-format.js +306 -0
- package/dist/lib/input-format.js.map +1 -0
- package/dist/lib/io-context.d.ts +698 -0
- package/dist/lib/io-context.js +771 -0
- package/dist/lib/io-context.js.map +1 -0
- package/dist/lib/log.d.ts +174 -0
- package/dist/lib/log.js +184 -0
- package/dist/lib/log.js.map +1 -0
- package/dist/lib/native-types.d.ts +1024 -0
- package/dist/lib/native-types.js +2 -0
- package/dist/lib/native-types.js.map +1 -0
- package/dist/lib/option.d.ts +953 -0
- package/dist/lib/option.js +1607 -0
- package/dist/lib/option.js.map +1 -0
- package/dist/lib/output-format.d.ts +222 -0
- package/dist/lib/output-format.js +259 -0
- package/dist/lib/output-format.js.map +1 -0
- package/dist/lib/packet.d.ts +521 -0
- package/dist/lib/packet.js +613 -0
- package/dist/lib/packet.js.map +1 -0
- package/dist/lib/rational.d.ts +251 -0
- package/dist/lib/rational.js +278 -0
- package/dist/lib/rational.js.map +1 -0
- package/dist/lib/software-resample-context.d.ts +552 -0
- package/dist/lib/software-resample-context.js +592 -0
- package/dist/lib/software-resample-context.js.map +1 -0
- package/dist/lib/software-scale-context.d.ts +344 -0
- package/dist/lib/software-scale-context.js +366 -0
- package/dist/lib/software-scale-context.js.map +1 -0
- package/dist/lib/stream.d.ts +383 -0
- package/dist/lib/stream.js +524 -0
- package/dist/lib/stream.js.map +1 -0
- package/dist/lib/sync-queue.d.ts +179 -0
- package/dist/lib/sync-queue.js +197 -0
- package/dist/lib/sync-queue.js.map +1 -0
- package/dist/lib/types.d.ts +34 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utilities.d.ts +1198 -0
- package/dist/lib/utilities.js +1302 -0
- package/dist/lib/utilities.js.map +1 -0
- package/dist/utils/electron.d.ts +49 -0
- package/dist/utils/electron.js +63 -0
- package/dist/utils/electron.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/libc.d.ts +11 -0
- package/dist/utils/libc.js +35 -0
- package/dist/utils/libc.js.map +1 -0
- package/dist/utils/variant.d.ts +26 -0
- package/dist/utils/variant.js +31 -0
- package/dist/utils/variant.js.map +1 -0
- package/dist/webrtc/index.d.ts +4 -0
- package/dist/webrtc/index.js +7 -0
- package/dist/webrtc/index.js.map +1 -0
- package/install/check.js +124 -0
- package/install/ffmpeg.js +66 -0
- package/package.json +167 -4
|
@@ -0,0 +1,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
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { bindings } from '../../lib/binding.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 class PixelFormatUtils {
|
|
23
|
+
// Private constructor to prevent instantiation
|
|
24
|
+
constructor() { }
|
|
25
|
+
/**
|
|
26
|
+
* Get the name of a pixel format.
|
|
27
|
+
*
|
|
28
|
+
* Returns a string describing the pixel format.
|
|
29
|
+
* Direct mapping to av_get_pix_fmt_name()
|
|
30
|
+
*
|
|
31
|
+
* @param format - Video pixel format
|
|
32
|
+
*
|
|
33
|
+
* @returns Format name string, or null for invalid format
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* import { PixelFormat } from 'node-av';
|
|
38
|
+
* import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_RGB24 } from 'node-av/constants';
|
|
39
|
+
*
|
|
40
|
+
* console.log(PixelFormat.getName(AV_PIX_FMT_YUV420P)); // "yuv420p"
|
|
41
|
+
* console.log(PixelFormat.getName(AV_PIX_FMT_RGB24)); // "rgb24"
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
static getName(format) {
|
|
45
|
+
return bindings.avGetPixFmtName(format);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get pixel format from name.
|
|
49
|
+
*
|
|
50
|
+
* Converts a pixel format name string to its enum value.
|
|
51
|
+
* Direct mapping to av_get_pix_fmt()
|
|
52
|
+
*
|
|
53
|
+
* @param name - Pixel format name string
|
|
54
|
+
*
|
|
55
|
+
* @returns Pixel format enum value, or AV_PIX_FMT_NONE for unknown formats
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* import { PixelFormat } from 'node-av';
|
|
60
|
+
* import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
|
|
61
|
+
*
|
|
62
|
+
* const format = PixelFormat.fromName("yuv420p");
|
|
63
|
+
* console.log(format === AV_PIX_FMT_YUV420P); // true
|
|
64
|
+
*
|
|
65
|
+
* const invalid = PixelFormat.fromName("invalid");
|
|
66
|
+
* console.log(invalid === AV_PIX_FMT_NONE); // true
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
static fromName(name) {
|
|
70
|
+
return bindings.avGetPixFmtFromName(name);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Check if pixel format is hardware accelerated.
|
|
74
|
+
*
|
|
75
|
+
* Returns true if the pixel format represents frames in GPU/hardware memory
|
|
76
|
+
* rather than system memory.
|
|
77
|
+
* Direct mapping to av_pix_fmt_desc_get() and checking for AV_PIX_FMT_FLAG_HWACCEL
|
|
78
|
+
*
|
|
79
|
+
* @param format - Video pixel format
|
|
80
|
+
*
|
|
81
|
+
* @returns True if format is hardware accelerated
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* import { PixelFormat } from 'node-av';
|
|
86
|
+
* import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_CUDA, AV_PIX_FMT_VAAPI } from 'node-av/constants';
|
|
87
|
+
*
|
|
88
|
+
* console.log(PixelFormat.isHardware(AV_PIX_FMT_YUV420P)); // false
|
|
89
|
+
* console.log(PixelFormat.isHardware(AV_PIX_FMT_CUDA)); // true
|
|
90
|
+
* console.log(PixelFormat.isHardware(AV_PIX_FMT_VAAPI)); // true
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
static isHardware(format) {
|
|
94
|
+
return bindings.avIsHardwarePixelFormat(format);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=pixel-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pixel-format.js","sourceRoot":"","sources":["../../../src/api/utilities/pixel-format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,gBAAgB;IAC3B,+CAA+C;IAC/C,gBAAuB,CAAC;IAExB;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,OAAO,CAAC,MAAqB;QAClC,OAAO,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAY;QAC1B,OAAO,QAAQ,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,MAAM,CAAC,UAAU,CAAC,MAAqB;QACrC,OAAO,QAAQ,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAClD,CAAC;CACF"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { AVSampleFormat } from '../../constants/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Audio sample format utilities.
|
|
4
|
+
*
|
|
5
|
+
* Provides static methods for querying and converting between audio sample formats.
|
|
6
|
+
* These utilities help with format introspection, conversion between packed/planar
|
|
7
|
+
* layouts, and getting human-readable format information.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { SampleFormat } from 'node-av';
|
|
12
|
+
* import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
|
|
13
|
+
*
|
|
14
|
+
* // Get format information
|
|
15
|
+
* console.log(SampleFormat.getName(AV_SAMPLE_FMT_S16)); // "s16"
|
|
16
|
+
* console.log(SampleFormat.getBytesPerSample(AV_SAMPLE_FMT_S16)); // 2
|
|
17
|
+
* console.log(SampleFormat.isPlanar(AV_SAMPLE_FMT_FLTP)); // true
|
|
18
|
+
*
|
|
19
|
+
* // Convert between packed and planar formats
|
|
20
|
+
* const packed = SampleFormat.getPackedFormat(AV_SAMPLE_FMT_FLTP);
|
|
21
|
+
* const planar = SampleFormat.getPlanarFormat(AV_SAMPLE_FMT_FLT);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare class SampleFormatUtils {
|
|
25
|
+
private constructor();
|
|
26
|
+
/**
|
|
27
|
+
* Get bytes per sample for a sample format.
|
|
28
|
+
*
|
|
29
|
+
* Returns the number of bytes required to store one sample in the given format.
|
|
30
|
+
* Direct mapping to av_get_bytes_per_sample()
|
|
31
|
+
*
|
|
32
|
+
* @param format - Audio sample format
|
|
33
|
+
*
|
|
34
|
+
* @returns Number of bytes per sample, or 0 for invalid format
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import { SampleFormat } from 'node-av';
|
|
39
|
+
* import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT } from 'node-av/constants';
|
|
40
|
+
*
|
|
41
|
+
* console.log(SampleFormat.getBytesPerSample(AV_SAMPLE_FMT_S16)); // 2
|
|
42
|
+
* console.log(SampleFormat.getBytesPerSample(AV_SAMPLE_FMT_FLT)); // 4
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
static getBytesPerSample(format: AVSampleFormat): number;
|
|
46
|
+
/**
|
|
47
|
+
* Get the name of a sample format.
|
|
48
|
+
*
|
|
49
|
+
* Returns a string describing the sample format.
|
|
50
|
+
* Direct mapping to av_get_sample_fmt_name()
|
|
51
|
+
*
|
|
52
|
+
* @param format - Audio sample format
|
|
53
|
+
*
|
|
54
|
+
* @returns Format name string, or null for invalid format
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* import { SampleFormat } from 'node-av';
|
|
59
|
+
* import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
|
|
60
|
+
*
|
|
61
|
+
* console.log(SampleFormat.getName(AV_SAMPLE_FMT_S16)); // "s16"
|
|
62
|
+
* console.log(SampleFormat.getName(AV_SAMPLE_FMT_FLTP)); // "fltp"
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
static getName(format: AVSampleFormat): string | null;
|
|
66
|
+
/**
|
|
67
|
+
* Get packed sample format.
|
|
68
|
+
*
|
|
69
|
+
* Returns the packed variant of the given sample format.
|
|
70
|
+
* If the format is already packed, returns it unchanged.
|
|
71
|
+
* Direct mapping to av_get_packed_sample_fmt()
|
|
72
|
+
*
|
|
73
|
+
* @param format - Audio sample format
|
|
74
|
+
*
|
|
75
|
+
* @returns Packed sample format
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* import { SampleFormat } from 'node-av';
|
|
80
|
+
* import { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT } from 'node-av/constants';
|
|
81
|
+
*
|
|
82
|
+
* const packed = SampleFormat.getPackedFormat(AV_SAMPLE_FMT_FLTP);
|
|
83
|
+
* console.log(packed === AV_SAMPLE_FMT_FLT); // true
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
static getPackedFormat(format: AVSampleFormat): AVSampleFormat;
|
|
87
|
+
/**
|
|
88
|
+
* Get planar sample format.
|
|
89
|
+
*
|
|
90
|
+
* Returns the planar variant of the given sample format.
|
|
91
|
+
* If the format is already planar, returns it unchanged.
|
|
92
|
+
* Direct mapping to av_get_planar_sample_fmt()
|
|
93
|
+
*
|
|
94
|
+
* @param format - Audio sample format
|
|
95
|
+
*
|
|
96
|
+
* @returns Planar sample format
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* import { SampleFormat } from 'node-av';
|
|
101
|
+
* import { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
|
|
102
|
+
*
|
|
103
|
+
* const planar = SampleFormat.getPlanarFormat(AV_SAMPLE_FMT_FLT);
|
|
104
|
+
* console.log(planar === AV_SAMPLE_FMT_FLTP); // true
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
static getPlanarFormat(format: AVSampleFormat): AVSampleFormat;
|
|
108
|
+
/**
|
|
109
|
+
* Check if sample format is planar.
|
|
110
|
+
*
|
|
111
|
+
* Returns true if the sample format stores each channel in a separate buffer.
|
|
112
|
+
* Returns false if all channels are interleaved in a single buffer.
|
|
113
|
+
* Direct mapping to av_sample_fmt_is_planar()
|
|
114
|
+
*
|
|
115
|
+
* @param format - Audio sample format
|
|
116
|
+
*
|
|
117
|
+
* @returns True if format is planar, false if packed/interleaved
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* import { SampleFormat } from 'node-av';
|
|
122
|
+
* import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P } from 'node-av/constants';
|
|
123
|
+
*
|
|
124
|
+
* console.log(SampleFormat.isPlanar(AV_SAMPLE_FMT_S16)); // false (packed)
|
|
125
|
+
* console.log(SampleFormat.isPlanar(AV_SAMPLE_FMT_S16P)); // true (planar)
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
static isPlanar(format: AVSampleFormat): boolean;
|
|
129
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { bindings } from '../../lib/binding.js';
|
|
2
|
+
/**
|
|
3
|
+
* Audio sample format utilities.
|
|
4
|
+
*
|
|
5
|
+
* Provides static methods for querying and converting between audio sample formats.
|
|
6
|
+
* These utilities help with format introspection, conversion between packed/planar
|
|
7
|
+
* layouts, and getting human-readable format information.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { SampleFormat } from 'node-av';
|
|
12
|
+
* import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
|
|
13
|
+
*
|
|
14
|
+
* // Get format information
|
|
15
|
+
* console.log(SampleFormat.getName(AV_SAMPLE_FMT_S16)); // "s16"
|
|
16
|
+
* console.log(SampleFormat.getBytesPerSample(AV_SAMPLE_FMT_S16)); // 2
|
|
17
|
+
* console.log(SampleFormat.isPlanar(AV_SAMPLE_FMT_FLTP)); // true
|
|
18
|
+
*
|
|
19
|
+
* // Convert between packed and planar formats
|
|
20
|
+
* const packed = SampleFormat.getPackedFormat(AV_SAMPLE_FMT_FLTP);
|
|
21
|
+
* const planar = SampleFormat.getPlanarFormat(AV_SAMPLE_FMT_FLT);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export class SampleFormatUtils {
|
|
25
|
+
// Private constructor to prevent instantiation
|
|
26
|
+
constructor() { }
|
|
27
|
+
/**
|
|
28
|
+
* Get bytes per sample for a sample format.
|
|
29
|
+
*
|
|
30
|
+
* Returns the number of bytes required to store one sample in the given format.
|
|
31
|
+
* Direct mapping to av_get_bytes_per_sample()
|
|
32
|
+
*
|
|
33
|
+
* @param format - Audio sample format
|
|
34
|
+
*
|
|
35
|
+
* @returns Number of bytes per sample, or 0 for invalid format
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* import { SampleFormat } from 'node-av';
|
|
40
|
+
* import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT } from 'node-av/constants';
|
|
41
|
+
*
|
|
42
|
+
* console.log(SampleFormat.getBytesPerSample(AV_SAMPLE_FMT_S16)); // 2
|
|
43
|
+
* console.log(SampleFormat.getBytesPerSample(AV_SAMPLE_FMT_FLT)); // 4
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
static getBytesPerSample(format) {
|
|
47
|
+
return bindings.avGetBytesPerSample(format);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get the name of a sample format.
|
|
51
|
+
*
|
|
52
|
+
* Returns a string describing the sample format.
|
|
53
|
+
* Direct mapping to av_get_sample_fmt_name()
|
|
54
|
+
*
|
|
55
|
+
* @param format - Audio sample format
|
|
56
|
+
*
|
|
57
|
+
* @returns Format name string, or null for invalid format
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* import { SampleFormat } from 'node-av';
|
|
62
|
+
* import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
|
|
63
|
+
*
|
|
64
|
+
* console.log(SampleFormat.getName(AV_SAMPLE_FMT_S16)); // "s16"
|
|
65
|
+
* console.log(SampleFormat.getName(AV_SAMPLE_FMT_FLTP)); // "fltp"
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
static getName(format) {
|
|
69
|
+
return bindings.avGetSampleFmtName(format);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Get packed sample format.
|
|
73
|
+
*
|
|
74
|
+
* Returns the packed variant of the given sample format.
|
|
75
|
+
* If the format is already packed, returns it unchanged.
|
|
76
|
+
* Direct mapping to av_get_packed_sample_fmt()
|
|
77
|
+
*
|
|
78
|
+
* @param format - Audio sample format
|
|
79
|
+
*
|
|
80
|
+
* @returns Packed sample format
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* import { SampleFormat } from 'node-av';
|
|
85
|
+
* import { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT } from 'node-av/constants';
|
|
86
|
+
*
|
|
87
|
+
* const packed = SampleFormat.getPackedFormat(AV_SAMPLE_FMT_FLTP);
|
|
88
|
+
* console.log(packed === AV_SAMPLE_FMT_FLT); // true
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
static getPackedFormat(format) {
|
|
92
|
+
return bindings.avGetPackedSampleFmt(format);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get planar sample format.
|
|
96
|
+
*
|
|
97
|
+
* Returns the planar variant of the given sample format.
|
|
98
|
+
* If the format is already planar, returns it unchanged.
|
|
99
|
+
* Direct mapping to av_get_planar_sample_fmt()
|
|
100
|
+
*
|
|
101
|
+
* @param format - Audio sample format
|
|
102
|
+
*
|
|
103
|
+
* @returns Planar sample format
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* import { SampleFormat } from 'node-av';
|
|
108
|
+
* import { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
|
|
109
|
+
*
|
|
110
|
+
* const planar = SampleFormat.getPlanarFormat(AV_SAMPLE_FMT_FLT);
|
|
111
|
+
* console.log(planar === AV_SAMPLE_FMT_FLTP); // true
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
static getPlanarFormat(format) {
|
|
115
|
+
return bindings.avGetPlanarSampleFmt(format);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Check if sample format is planar.
|
|
119
|
+
*
|
|
120
|
+
* Returns true if the sample format stores each channel in a separate buffer.
|
|
121
|
+
* Returns false if all channels are interleaved in a single buffer.
|
|
122
|
+
* Direct mapping to av_sample_fmt_is_planar()
|
|
123
|
+
*
|
|
124
|
+
* @param format - Audio sample format
|
|
125
|
+
*
|
|
126
|
+
* @returns True if format is planar, false if packed/interleaved
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* import { SampleFormat } from 'node-av';
|
|
131
|
+
* import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P } from 'node-av/constants';
|
|
132
|
+
*
|
|
133
|
+
* console.log(SampleFormat.isPlanar(AV_SAMPLE_FMT_S16)); // false (packed)
|
|
134
|
+
* console.log(SampleFormat.isPlanar(AV_SAMPLE_FMT_S16P)); // true (planar)
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
static isPlanar(format) {
|
|
138
|
+
return bindings.avSampleFmtIsPlanar(format);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=sample-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sample-format.js","sourceRoot":"","sources":["../../../src/api/utilities/sample-format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,iBAAiB;IAC5B,+CAA+C;IAC/C,gBAAuB,CAAC;IAExB;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,iBAAiB,CAAC,MAAsB;QAC7C,OAAO,QAAQ,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,OAAO,CAAC,MAAsB;QACnC,OAAO,QAAQ,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,eAAe,CAAC,MAAsB;QAC3C,OAAO,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,eAAe,CAAC,MAAsB;QAC3C,OAAO,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,QAAQ,CAAC,MAAsB;QACpC,OAAO,QAAQ,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve a scale target where -1 keeps the source aspect ratio.
|
|
3
|
+
*
|
|
4
|
+
* Like the scale filter's -2: the derived side is rounded to an even number so
|
|
5
|
+
* 4:2:0 encoders accept it. Both sides -1 keeps the source size.
|
|
6
|
+
*
|
|
7
|
+
* @param srcWidth - Source width
|
|
8
|
+
*
|
|
9
|
+
* @param srcHeight - Source height
|
|
10
|
+
*
|
|
11
|
+
* @param width - Target width, or -1 to derive it from the height
|
|
12
|
+
*
|
|
13
|
+
* @param height - Target height, or -1 to derive it from the width
|
|
14
|
+
*
|
|
15
|
+
* @returns The target size
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveScaleSize(srcWidth: number, srcHeight: number, width: number, height: number): {
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Scale target and output size of a transcode, never larger than the source.
|
|
25
|
+
*
|
|
26
|
+
* A requested width or height above the source keeps the source size, since a
|
|
27
|
+
* bigger picture only raises the bitrate.
|
|
28
|
+
*
|
|
29
|
+
* @param srcWidth - Source width, 0 when unknown before the first frame
|
|
30
|
+
*
|
|
31
|
+
* @param srcHeight - Source height, 0 when unknown before the first frame
|
|
32
|
+
*
|
|
33
|
+
* @param width - Requested width, or -1 to derive it from the height
|
|
34
|
+
*
|
|
35
|
+
* @param height - Requested height, or -1 to derive it from the width
|
|
36
|
+
*
|
|
37
|
+
* @returns The target for the scale filter (-1 follows the source) and the
|
|
38
|
+
* resolved output size, undefined while the source size is unknown
|
|
39
|
+
*
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
export declare function transcodeScale(srcWidth: number, srcHeight: number, width?: number, height?: number): {
|
|
43
|
+
target: {
|
|
44
|
+
width: number;
|
|
45
|
+
height: number;
|
|
46
|
+
};
|
|
47
|
+
output?: {
|
|
48
|
+
width: number;
|
|
49
|
+
height: number;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve a scale target where -1 keeps the source aspect ratio.
|
|
3
|
+
*
|
|
4
|
+
* Like the scale filter's -2: the derived side is rounded to an even number so
|
|
5
|
+
* 4:2:0 encoders accept it. Both sides -1 keeps the source size.
|
|
6
|
+
*
|
|
7
|
+
* @param srcWidth - Source width
|
|
8
|
+
*
|
|
9
|
+
* @param srcHeight - Source height
|
|
10
|
+
*
|
|
11
|
+
* @param width - Target width, or -1 to derive it from the height
|
|
12
|
+
*
|
|
13
|
+
* @param height - Target height, or -1 to derive it from the width
|
|
14
|
+
*
|
|
15
|
+
* @returns The target size
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export function resolveScaleSize(srcWidth, srcHeight, width, height) {
|
|
20
|
+
if (width < 0 && height < 0) {
|
|
21
|
+
return { width: srcWidth, height: srcHeight };
|
|
22
|
+
}
|
|
23
|
+
if (width < 0) {
|
|
24
|
+
return { width: Math.max(2, Math.round((height * srcWidth) / srcHeight / 2) * 2), height };
|
|
25
|
+
}
|
|
26
|
+
if (height < 0) {
|
|
27
|
+
return { width, height: Math.max(2, Math.round((width * srcHeight) / srcWidth / 2) * 2) };
|
|
28
|
+
}
|
|
29
|
+
return { width, height };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Scale target and output size of a transcode, never larger than the source.
|
|
33
|
+
*
|
|
34
|
+
* A requested width or height above the source keeps the source size, since a
|
|
35
|
+
* bigger picture only raises the bitrate.
|
|
36
|
+
*
|
|
37
|
+
* @param srcWidth - Source width, 0 when unknown before the first frame
|
|
38
|
+
*
|
|
39
|
+
* @param srcHeight - Source height, 0 when unknown before the first frame
|
|
40
|
+
*
|
|
41
|
+
* @param width - Requested width, or -1 to derive it from the height
|
|
42
|
+
*
|
|
43
|
+
* @param height - Requested height, or -1 to derive it from the width
|
|
44
|
+
*
|
|
45
|
+
* @returns The target for the scale filter (-1 follows the source) and the
|
|
46
|
+
* resolved output size, undefined while the source size is unknown
|
|
47
|
+
*
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
export function transcodeScale(srcWidth, srcHeight, width = -1, height = -1) {
|
|
51
|
+
const known = srcWidth > 0 && srcHeight > 0;
|
|
52
|
+
const target = known && (width > srcWidth || height > srcHeight) ? { width: -1, height: -1 } : { width, height };
|
|
53
|
+
return { target, output: known ? resolveScaleSize(srcWidth, srcHeight, target.width, target.height) : undefined };
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=scale-size.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scale-size.js","sourceRoot":"","sources":["../../../src/api/utilities/scale-size.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB,EAAE,SAAiB,EAAE,KAAa,EAAE,MAAc;IACjG,IAAI,KAAK,GAAG,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IAChD,CAAC;IACD,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,QAAQ,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7F,CAAC;IACD,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QACf,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;IAC5F,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC3B,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,cAAc,CAC5B,QAAgB,EAChB,SAAiB,EACjB,KAAK,GAAG,CAAC,CAAC,EACV,MAAM,GAAG,CAAC,CAAC;IAEX,MAAM,KAAK,GAAG,QAAQ,GAAG,CAAC,IAAI,SAAS,GAAG,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,KAAK,IAAI,CAAC,KAAK,GAAG,QAAQ,IAAI,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IACjH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;AACpH,CAAC"}
|