node-av 0.0.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/CHANGELOG.md +8 -0
- package/LICENSE.md +22 -0
- package/README.md +377 -0
- package/binding.gyp +78 -0
- package/dist/api/bitstream-filter.d.ts +246 -0
- package/dist/api/bitstream-filter.js +369 -0
- package/dist/api/bitstream-filter.js.map +1 -0
- package/dist/api/decoder.d.ts +257 -0
- package/dist/api/decoder.js +424 -0
- package/dist/api/decoder.js.map +1 -0
- package/dist/api/encoder.d.ts +298 -0
- package/dist/api/encoder.js +574 -0
- package/dist/api/encoder.js.map +1 -0
- package/dist/api/filter.d.ts +457 -0
- package/dist/api/filter.js +876 -0
- package/dist/api/filter.js.map +1 -0
- package/dist/api/hardware.d.ts +318 -0
- package/dist/api/hardware.js +558 -0
- package/dist/api/hardware.js.map +1 -0
- package/dist/api/index.d.ts +12 -0
- package/dist/api/index.js +20 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/io-stream.d.ts +109 -0
- package/dist/api/io-stream.js +124 -0
- package/dist/api/io-stream.js.map +1 -0
- package/dist/api/media-input.d.ts +295 -0
- package/dist/api/media-input.js +456 -0
- package/dist/api/media-input.js.map +1 -0
- package/dist/api/media-output.d.ts +274 -0
- package/dist/api/media-output.js +486 -0
- package/dist/api/media-output.js.map +1 -0
- package/dist/api/pipeline.d.ts +117 -0
- package/dist/api/pipeline.js +836 -0
- package/dist/api/pipeline.js.map +1 -0
- package/dist/api/types.d.ts +440 -0
- package/dist/api/types.js +2 -0
- package/dist/api/types.js.map +1 -0
- package/dist/api/utilities/audio-sample.d.ts +115 -0
- package/dist/api/utilities/audio-sample.js +110 -0
- package/dist/api/utilities/audio-sample.js.map +1 -0
- package/dist/api/utilities/channel-layout.d.ts +83 -0
- package/dist/api/utilities/channel-layout.js +87 -0
- package/dist/api/utilities/channel-layout.js.map +1 -0
- package/dist/api/utilities/image.d.ts +177 -0
- package/dist/api/utilities/image.js +183 -0
- package/dist/api/utilities/image.js.map +1 -0
- package/dist/api/utilities/index.d.ts +8 -0
- package/dist/api/utilities/index.js +17 -0
- package/dist/api/utilities/index.js.map +1 -0
- package/dist/api/utilities/media-type.d.ts +56 -0
- package/dist/api/utilities/media-type.js +60 -0
- package/dist/api/utilities/media-type.js.map +1 -0
- package/dist/api/utilities/pixel-format.d.ts +94 -0
- package/dist/api/utilities/pixel-format.js +102 -0
- package/dist/api/utilities/pixel-format.js.map +1 -0
- package/dist/api/utilities/sample-format.d.ts +132 -0
- package/dist/api/utilities/sample-format.js +144 -0
- package/dist/api/utilities/sample-format.js.map +1 -0
- package/dist/api/utilities/streaming.d.ts +104 -0
- package/dist/api/utilities/streaming.js +137 -0
- package/dist/api/utilities/streaming.js.map +1 -0
- package/dist/api/utilities/timestamp.d.ts +187 -0
- package/dist/api/utilities/timestamp.js +200 -0
- package/dist/api/utilities/timestamp.js.map +1 -0
- package/dist/api/utils.d.ts +61 -0
- package/dist/api/utils.js +330 -0
- package/dist/api/utils.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/audio-fifo.d.ts +339 -0
- package/dist/lib/audio-fifo.js +365 -0
- package/dist/lib/audio-fifo.js.map +1 -0
- package/dist/lib/binding.d.ts +192 -0
- package/dist/lib/binding.js +70 -0
- package/dist/lib/binding.js.map +1 -0
- package/dist/lib/bitstream-filter-context.d.ts +345 -0
- package/dist/lib/bitstream-filter-context.js +407 -0
- package/dist/lib/bitstream-filter-context.js.map +1 -0
- package/dist/lib/bitstream-filter.d.ts +124 -0
- package/dist/lib/bitstream-filter.js +138 -0
- package/dist/lib/bitstream-filter.js.map +1 -0
- package/dist/lib/channel-layouts.d.ts +51 -0
- package/dist/lib/channel-layouts.js +55 -0
- package/dist/lib/channel-layouts.js.map +1 -0
- package/dist/lib/codec-context.d.ts +763 -0
- package/dist/lib/codec-context.js +974 -0
- package/dist/lib/codec-context.js.map +1 -0
- package/dist/lib/codec-parameters.d.ts +362 -0
- package/dist/lib/codec-parameters.js +460 -0
- package/dist/lib/codec-parameters.js.map +1 -0
- package/dist/lib/codec-parser.d.ts +185 -0
- package/dist/lib/codec-parser.js +193 -0
- package/dist/lib/codec-parser.js.map +1 -0
- package/dist/lib/codec.d.ts +432 -0
- package/dist/lib/codec.js +492 -0
- package/dist/lib/codec.js.map +1 -0
- package/dist/lib/constants.d.ts +2037 -0
- package/dist/lib/constants.js +1659 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/dictionary.d.ts +371 -0
- package/dist/lib/dictionary.js +406 -0
- package/dist/lib/dictionary.js.map +1 -0
- package/dist/lib/error.d.ts +216 -0
- package/dist/lib/error.js +254 -0
- package/dist/lib/error.js.map +1 -0
- package/dist/lib/filter-context.d.ts +445 -0
- package/dist/lib/filter-context.js +505 -0
- package/dist/lib/filter-context.js.map +1 -0
- package/dist/lib/filter-graph.d.ts +556 -0
- package/dist/lib/filter-graph.js +608 -0
- package/dist/lib/filter-graph.js.map +1 -0
- package/dist/lib/filter-inout.d.ts +205 -0
- package/dist/lib/filter-inout.js +264 -0
- package/dist/lib/filter-inout.js.map +1 -0
- package/dist/lib/filter.d.ts +231 -0
- package/dist/lib/filter.js +260 -0
- package/dist/lib/filter.js.map +1 -0
- package/dist/lib/format-context.d.ts +798 -0
- package/dist/lib/format-context.js +845 -0
- package/dist/lib/format-context.js.map +1 -0
- package/dist/lib/frame.d.ts +784 -0
- package/dist/lib/frame.js +933 -0
- package/dist/lib/frame.js.map +1 -0
- package/dist/lib/hardware-device-context.d.ts +407 -0
- package/dist/lib/hardware-device-context.js +429 -0
- package/dist/lib/hardware-device-context.js.map +1 -0
- package/dist/lib/hardware-frames-context.d.ts +374 -0
- package/dist/lib/hardware-frames-context.js +430 -0
- package/dist/lib/hardware-frames-context.js.map +1 -0
- package/dist/lib/index.d.ts +31 -0
- package/dist/lib/index.js +54 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/input-format.d.ts +216 -0
- package/dist/lib/input-format.js +246 -0
- package/dist/lib/input-format.js.map +1 -0
- package/dist/lib/io-context.d.ts +495 -0
- package/dist/lib/io-context.js +550 -0
- package/dist/lib/io-context.js.map +1 -0
- package/dist/lib/log.d.ts +201 -0
- package/dist/lib/log.js +219 -0
- package/dist/lib/log.js.map +1 -0
- package/dist/lib/native-types.d.ts +719 -0
- package/dist/lib/native-types.js +2 -0
- package/dist/lib/native-types.js.map +1 -0
- package/dist/lib/option.d.ts +589 -0
- package/dist/lib/option.js +853 -0
- package/dist/lib/option.js.map +1 -0
- package/dist/lib/output-format.d.ts +179 -0
- package/dist/lib/output-format.js +205 -0
- package/dist/lib/output-format.js.map +1 -0
- package/dist/lib/packet.d.ts +487 -0
- package/dist/lib/packet.js +558 -0
- package/dist/lib/packet.js.map +1 -0
- package/dist/lib/rational.d.ts +210 -0
- package/dist/lib/rational.js +233 -0
- package/dist/lib/rational.js.map +1 -0
- package/dist/lib/software-resample-context.d.ts +572 -0
- package/dist/lib/software-resample-context.js +610 -0
- package/dist/lib/software-resample-context.js.map +1 -0
- package/dist/lib/software-scale-context.d.ts +290 -0
- package/dist/lib/software-scale-context.js +308 -0
- package/dist/lib/software-scale-context.js.map +1 -0
- package/dist/lib/stream.d.ts +322 -0
- package/dist/lib/stream.js +408 -0
- package/dist/lib/stream.js.map +1 -0
- package/dist/lib/types.d.ts +59 -0
- package/dist/lib/types.js +8 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utilities.d.ts +346 -0
- package/dist/lib/utilities.js +424 -0
- package/dist/lib/utilities.js.map +1 -0
- package/install/check.js +113 -0
- package/install/ffmpeg.js +163 -0
- package/package.json +107 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Media Type Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities for working with media types in FFmpeg.
|
|
5
|
+
* All methods are static and map directly to FFmpeg's libavutil functions.
|
|
6
|
+
*
|
|
7
|
+
* @module lib/media-type
|
|
8
|
+
*/
|
|
9
|
+
import type { AVMediaType } from '../../lib/constants.js';
|
|
10
|
+
/**
|
|
11
|
+
* Media type utilities.
|
|
12
|
+
*
|
|
13
|
+
* Provides static methods for converting media type enum values to
|
|
14
|
+
* human-readable strings.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { MediaType } from 'node-av';
|
|
19
|
+
* import { AVMEDIA_TYPE_VIDEO, AVMEDIA_TYPE_AUDIO } from 'node-av/constants';
|
|
20
|
+
*
|
|
21
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_VIDEO)); // "video"
|
|
22
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_AUDIO)); // "audio"
|
|
23
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_SUBTITLE)); // "subtitle"
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class MediaType {
|
|
27
|
+
private constructor();
|
|
28
|
+
/**
|
|
29
|
+
* Get string representation of media type.
|
|
30
|
+
*
|
|
31
|
+
* Converts a media type enum value to its string representation.
|
|
32
|
+
* Direct mapping to av_get_media_type_string()
|
|
33
|
+
*
|
|
34
|
+
* @param type - Media type enum value
|
|
35
|
+
* @returns String representation, or null for invalid type
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* import { MediaType } from 'node-av';
|
|
40
|
+
* import {
|
|
41
|
+
* AVMEDIA_TYPE_VIDEO,
|
|
42
|
+
* AVMEDIA_TYPE_AUDIO,
|
|
43
|
+
* AVMEDIA_TYPE_DATA,
|
|
44
|
+
* AVMEDIA_TYPE_SUBTITLE,
|
|
45
|
+
* AVMEDIA_TYPE_ATTACHMENT
|
|
46
|
+
* } from 'node-av/constants';
|
|
47
|
+
*
|
|
48
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_VIDEO)); // "video"
|
|
49
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_AUDIO)); // "audio"
|
|
50
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_DATA)); // "data"
|
|
51
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_SUBTITLE)); // "subtitle"
|
|
52
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_ATTACHMENT)); // "attachment"
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
static getString(type: AVMediaType): string | null;
|
|
56
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Media Type Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities for working with media types in FFmpeg.
|
|
5
|
+
* All methods are static and map directly to FFmpeg's libavutil functions.
|
|
6
|
+
*
|
|
7
|
+
* @module lib/media-type
|
|
8
|
+
*/
|
|
9
|
+
import { bindings } from '../../lib/binding.js';
|
|
10
|
+
/**
|
|
11
|
+
* Media type utilities.
|
|
12
|
+
*
|
|
13
|
+
* Provides static methods for converting media type enum values to
|
|
14
|
+
* human-readable strings.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { MediaType } from 'node-av';
|
|
19
|
+
* import { AVMEDIA_TYPE_VIDEO, AVMEDIA_TYPE_AUDIO } from 'node-av/constants';
|
|
20
|
+
*
|
|
21
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_VIDEO)); // "video"
|
|
22
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_AUDIO)); // "audio"
|
|
23
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_SUBTITLE)); // "subtitle"
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export class MediaType {
|
|
27
|
+
// Private constructor to prevent instantiation
|
|
28
|
+
constructor() { }
|
|
29
|
+
/**
|
|
30
|
+
* Get string representation of media type.
|
|
31
|
+
*
|
|
32
|
+
* Converts a media type enum value to its string representation.
|
|
33
|
+
* Direct mapping to av_get_media_type_string()
|
|
34
|
+
*
|
|
35
|
+
* @param type - Media type enum value
|
|
36
|
+
* @returns String representation, or null for invalid type
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* import { MediaType } from 'node-av';
|
|
41
|
+
* import {
|
|
42
|
+
* AVMEDIA_TYPE_VIDEO,
|
|
43
|
+
* AVMEDIA_TYPE_AUDIO,
|
|
44
|
+
* AVMEDIA_TYPE_DATA,
|
|
45
|
+
* AVMEDIA_TYPE_SUBTITLE,
|
|
46
|
+
* AVMEDIA_TYPE_ATTACHMENT
|
|
47
|
+
* } from 'node-av/constants';
|
|
48
|
+
*
|
|
49
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_VIDEO)); // "video"
|
|
50
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_AUDIO)); // "audio"
|
|
51
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_DATA)); // "data"
|
|
52
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_SUBTITLE)); // "subtitle"
|
|
53
|
+
* console.log(MediaType.getString(AVMEDIA_TYPE_ATTACHMENT)); // "attachment"
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
static getString(type) {
|
|
57
|
+
return bindings.avGetMediaTypeString(type);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# 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;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,SAAS;IACpB,+CAA+C;IAC/C,gBAAuB,CAAC;IAExB;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,MAAM,CAAC,SAAS,CAAC,IAAiB;QAChC,OAAO,QAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;CACF"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pixel Format Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities for working with video pixel formats in FFmpeg.
|
|
5
|
+
* All methods are static and map directly to FFmpeg's libavutil functions.
|
|
6
|
+
*
|
|
7
|
+
* @module lib/pixel-format
|
|
8
|
+
*/
|
|
9
|
+
import type { AVPixelFormat } from '../../lib/constants.js';
|
|
10
|
+
/**
|
|
11
|
+
* Video pixel format utilities.
|
|
12
|
+
*
|
|
13
|
+
* Provides static methods for querying pixel format properties, converting
|
|
14
|
+
* between format names and values, and checking hardware acceleration support.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { PixelFormat } from 'node-av';
|
|
19
|
+
* import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_CUDA } from 'node-av/constants';
|
|
20
|
+
*
|
|
21
|
+
* // Get format information
|
|
22
|
+
* console.log(PixelFormat.getName(AV_PIX_FMT_YUV420P)); // "yuv420p"
|
|
23
|
+
* console.log(PixelFormat.isHardware(AV_PIX_FMT_CUDA)); // true
|
|
24
|
+
*
|
|
25
|
+
* // Convert between names and values
|
|
26
|
+
* const format = PixelFormat.fromName("yuv420p");
|
|
27
|
+
* console.log(format === AV_PIX_FMT_YUV420P); // true
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare class PixelFormat {
|
|
31
|
+
private constructor();
|
|
32
|
+
/**
|
|
33
|
+
* Get the name of a pixel format.
|
|
34
|
+
*
|
|
35
|
+
* Returns a string describing the pixel format.
|
|
36
|
+
* Direct mapping to av_get_pix_fmt_name()
|
|
37
|
+
*
|
|
38
|
+
* @param format - Video pixel format
|
|
39
|
+
* @returns Format name string, or null for invalid format
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* import { PixelFormat } from 'node-av';
|
|
44
|
+
* import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_RGB24 } from 'node-av/constants';
|
|
45
|
+
*
|
|
46
|
+
* console.log(PixelFormat.getName(AV_PIX_FMT_YUV420P)); // "yuv420p"
|
|
47
|
+
* console.log(PixelFormat.getName(AV_PIX_FMT_RGB24)); // "rgb24"
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
static getName(format: AVPixelFormat): string | null;
|
|
51
|
+
/**
|
|
52
|
+
* Get pixel format from name.
|
|
53
|
+
*
|
|
54
|
+
* Converts a pixel format name string to its enum value.
|
|
55
|
+
* Direct mapping to av_get_pix_fmt()
|
|
56
|
+
*
|
|
57
|
+
* @param name - Pixel format name string
|
|
58
|
+
* @returns Pixel format enum value, or AV_PIX_FMT_NONE for unknown formats
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* import { PixelFormat } from 'node-av';
|
|
63
|
+
* import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
|
|
64
|
+
*
|
|
65
|
+
* const format = PixelFormat.fromName("yuv420p");
|
|
66
|
+
* console.log(format === AV_PIX_FMT_YUV420P); // true
|
|
67
|
+
*
|
|
68
|
+
* const invalid = PixelFormat.fromName("invalid");
|
|
69
|
+
* console.log(invalid === AV_PIX_FMT_NONE); // true
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
static fromName(name: string): AVPixelFormat;
|
|
73
|
+
/**
|
|
74
|
+
* Check if pixel format is hardware accelerated.
|
|
75
|
+
*
|
|
76
|
+
* Returns true if the pixel format represents frames in GPU/hardware memory
|
|
77
|
+
* rather than system memory.
|
|
78
|
+
* Direct mapping to av_pix_fmt_desc_get() and checking for AV_PIX_FMT_FLAG_HWACCEL
|
|
79
|
+
*
|
|
80
|
+
* @param format - Video pixel format
|
|
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: AVPixelFormat): boolean;
|
|
94
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pixel Format Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities for working with video pixel formats in FFmpeg.
|
|
5
|
+
* All methods are static and map directly to FFmpeg's libavutil functions.
|
|
6
|
+
*
|
|
7
|
+
* @module lib/pixel-format
|
|
8
|
+
*/
|
|
9
|
+
import { bindings } from '../../lib/binding.js';
|
|
10
|
+
/**
|
|
11
|
+
* Video pixel format utilities.
|
|
12
|
+
*
|
|
13
|
+
* Provides static methods for querying pixel format properties, converting
|
|
14
|
+
* between format names and values, and checking hardware acceleration support.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { PixelFormat } from 'node-av';
|
|
19
|
+
* import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_CUDA } from 'node-av/constants';
|
|
20
|
+
*
|
|
21
|
+
* // Get format information
|
|
22
|
+
* console.log(PixelFormat.getName(AV_PIX_FMT_YUV420P)); // "yuv420p"
|
|
23
|
+
* console.log(PixelFormat.isHardware(AV_PIX_FMT_CUDA)); // true
|
|
24
|
+
*
|
|
25
|
+
* // Convert between names and values
|
|
26
|
+
* const format = PixelFormat.fromName("yuv420p");
|
|
27
|
+
* console.log(format === AV_PIX_FMT_YUV420P); // true
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export class PixelFormat {
|
|
31
|
+
// Private constructor to prevent instantiation
|
|
32
|
+
constructor() { }
|
|
33
|
+
/**
|
|
34
|
+
* Get the name of a pixel format.
|
|
35
|
+
*
|
|
36
|
+
* Returns a string describing the pixel format.
|
|
37
|
+
* Direct mapping to av_get_pix_fmt_name()
|
|
38
|
+
*
|
|
39
|
+
* @param format - Video pixel format
|
|
40
|
+
* @returns Format name string, or null for invalid format
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* import { PixelFormat } from 'node-av';
|
|
45
|
+
* import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_RGB24 } from 'node-av/constants';
|
|
46
|
+
*
|
|
47
|
+
* console.log(PixelFormat.getName(AV_PIX_FMT_YUV420P)); // "yuv420p"
|
|
48
|
+
* console.log(PixelFormat.getName(AV_PIX_FMT_RGB24)); // "rgb24"
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
static getName(format) {
|
|
52
|
+
return bindings.avGetPixFmtName(format);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get pixel format from name.
|
|
56
|
+
*
|
|
57
|
+
* Converts a pixel format name string to its enum value.
|
|
58
|
+
* Direct mapping to av_get_pix_fmt()
|
|
59
|
+
*
|
|
60
|
+
* @param name - Pixel format name string
|
|
61
|
+
* @returns Pixel format enum value, or AV_PIX_FMT_NONE for unknown formats
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* import { PixelFormat } from 'node-av';
|
|
66
|
+
* import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
|
|
67
|
+
*
|
|
68
|
+
* const format = PixelFormat.fromName("yuv420p");
|
|
69
|
+
* console.log(format === AV_PIX_FMT_YUV420P); // true
|
|
70
|
+
*
|
|
71
|
+
* const invalid = PixelFormat.fromName("invalid");
|
|
72
|
+
* console.log(invalid === AV_PIX_FMT_NONE); // true
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
static fromName(name) {
|
|
76
|
+
return bindings.avGetPixFmtFromName(name);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Check if pixel format is hardware accelerated.
|
|
80
|
+
*
|
|
81
|
+
* Returns true if the pixel format represents frames in GPU/hardware memory
|
|
82
|
+
* rather than system memory.
|
|
83
|
+
* Direct mapping to av_pix_fmt_desc_get() and checking for AV_PIX_FMT_FLAG_HWACCEL
|
|
84
|
+
*
|
|
85
|
+
* @param format - Video pixel format
|
|
86
|
+
* @returns True if format is hardware accelerated
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* import { PixelFormat } from 'node-av';
|
|
91
|
+
* import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_CUDA, AV_PIX_FMT_VAAPI } from 'node-av/constants';
|
|
92
|
+
*
|
|
93
|
+
* console.log(PixelFormat.isHardware(AV_PIX_FMT_YUV420P)); // false
|
|
94
|
+
* console.log(PixelFormat.isHardware(AV_PIX_FMT_CUDA)); // true
|
|
95
|
+
* console.log(PixelFormat.isHardware(AV_PIX_FMT_VAAPI)); // true
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
static isHardware(format) {
|
|
99
|
+
return bindings.avIsHardwarePixelFormat(format);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# 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;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,WAAW;IACtB,+CAA+C;IAC/C,gBAAuB,CAAC;IAExB;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,OAAO,CAAC,MAAqB;QAClC,OAAO,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAY;QAC1B,OAAO,QAAQ,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,UAAU,CAAC,MAAqB;QACrC,OAAO,QAAQ,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAClD,CAAC;CACF"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sample Format Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities for working with audio sample formats in FFmpeg.
|
|
5
|
+
* All methods are static and map directly to FFmpeg's libavutil functions.
|
|
6
|
+
*
|
|
7
|
+
* @module lib/sample-format
|
|
8
|
+
*/
|
|
9
|
+
import type { AVSampleFormat } from '../../lib/constants.js';
|
|
10
|
+
/**
|
|
11
|
+
* Audio sample format utilities.
|
|
12
|
+
*
|
|
13
|
+
* Provides static methods for querying and converting between audio sample formats.
|
|
14
|
+
* These utilities help with format introspection, conversion between packed/planar
|
|
15
|
+
* layouts, and getting human-readable format information.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { SampleFormat } from 'node-av';
|
|
20
|
+
* import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
|
|
21
|
+
*
|
|
22
|
+
* // Get format information
|
|
23
|
+
* console.log(SampleFormat.getName(AV_SAMPLE_FMT_S16)); // "s16"
|
|
24
|
+
* console.log(SampleFormat.getBytesPerSample(AV_SAMPLE_FMT_S16)); // 2
|
|
25
|
+
* console.log(SampleFormat.isPlanar(AV_SAMPLE_FMT_FLTP)); // true
|
|
26
|
+
*
|
|
27
|
+
* // Convert between packed and planar formats
|
|
28
|
+
* const packed = SampleFormat.getPackedFormat(AV_SAMPLE_FMT_FLTP);
|
|
29
|
+
* const planar = SampleFormat.getPlanarFormat(AV_SAMPLE_FMT_FLT);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare class SampleFormat {
|
|
33
|
+
private constructor();
|
|
34
|
+
/**
|
|
35
|
+
* Get bytes per sample for a sample format.
|
|
36
|
+
*
|
|
37
|
+
* Returns the number of bytes required to store one sample in the given format.
|
|
38
|
+
* Direct mapping to av_get_bytes_per_sample()
|
|
39
|
+
*
|
|
40
|
+
* @param format - Audio sample format
|
|
41
|
+
* @returns Number of bytes per sample, or 0 for invalid format
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* import { SampleFormat } from 'node-av';
|
|
46
|
+
* import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT } from 'node-av/constants';
|
|
47
|
+
*
|
|
48
|
+
* console.log(SampleFormat.getBytesPerSample(AV_SAMPLE_FMT_S16)); // 2
|
|
49
|
+
* console.log(SampleFormat.getBytesPerSample(AV_SAMPLE_FMT_FLT)); // 4
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
static getBytesPerSample(format: AVSampleFormat): number;
|
|
53
|
+
/**
|
|
54
|
+
* Get the name of a sample format.
|
|
55
|
+
*
|
|
56
|
+
* Returns a string describing the sample format.
|
|
57
|
+
* Direct mapping to av_get_sample_fmt_name()
|
|
58
|
+
*
|
|
59
|
+
* @param format - Audio sample format
|
|
60
|
+
* @returns Format name string, or null for invalid format
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* import { SampleFormat } from 'node-av';
|
|
65
|
+
* import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
|
|
66
|
+
*
|
|
67
|
+
* console.log(SampleFormat.getName(AV_SAMPLE_FMT_S16)); // "s16"
|
|
68
|
+
* console.log(SampleFormat.getName(AV_SAMPLE_FMT_FLTP)); // "fltp"
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
static getName(format: AVSampleFormat): string | null;
|
|
72
|
+
/**
|
|
73
|
+
* Get packed sample format.
|
|
74
|
+
*
|
|
75
|
+
* Returns the packed variant of the given sample format.
|
|
76
|
+
* If the format is already packed, returns it unchanged.
|
|
77
|
+
* Direct mapping to av_get_packed_sample_fmt()
|
|
78
|
+
*
|
|
79
|
+
* @param format - Audio sample format
|
|
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: AVSampleFormat): AVSampleFormat;
|
|
92
|
+
/**
|
|
93
|
+
* Get planar sample format.
|
|
94
|
+
*
|
|
95
|
+
* Returns the planar variant of the given sample format.
|
|
96
|
+
* If the format is already planar, returns it unchanged.
|
|
97
|
+
* Direct mapping to av_get_planar_sample_fmt()
|
|
98
|
+
*
|
|
99
|
+
* @param format - Audio sample format
|
|
100
|
+
* @returns Planar sample format
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* import { SampleFormat } from 'node-av';
|
|
105
|
+
* import { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
|
|
106
|
+
*
|
|
107
|
+
* const planar = SampleFormat.getPlanarFormat(AV_SAMPLE_FMT_FLT);
|
|
108
|
+
* console.log(planar === AV_SAMPLE_FMT_FLTP); // true
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
static getPlanarFormat(format: AVSampleFormat): AVSampleFormat;
|
|
112
|
+
/**
|
|
113
|
+
* Check if sample format is planar.
|
|
114
|
+
*
|
|
115
|
+
* Returns true if the sample format stores each channel in a separate buffer.
|
|
116
|
+
* Returns false if all channels are interleaved in a single buffer.
|
|
117
|
+
* Direct mapping to av_sample_fmt_is_planar()
|
|
118
|
+
*
|
|
119
|
+
* @param format - Audio sample format
|
|
120
|
+
* @returns True if format is planar, false if packed/interleaved
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* import { SampleFormat } from 'node-av';
|
|
125
|
+
* import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P } from 'node-av/constants';
|
|
126
|
+
*
|
|
127
|
+
* console.log(SampleFormat.isPlanar(AV_SAMPLE_FMT_S16)); // false (packed)
|
|
128
|
+
* console.log(SampleFormat.isPlanar(AV_SAMPLE_FMT_S16P)); // true (planar)
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
static isPlanar(format: AVSampleFormat): boolean;
|
|
132
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sample Format Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities for working with audio sample formats in FFmpeg.
|
|
5
|
+
* All methods are static and map directly to FFmpeg's libavutil functions.
|
|
6
|
+
*
|
|
7
|
+
* @module lib/sample-format
|
|
8
|
+
*/
|
|
9
|
+
import { bindings } from '../../lib/binding.js';
|
|
10
|
+
/**
|
|
11
|
+
* Audio sample format utilities.
|
|
12
|
+
*
|
|
13
|
+
* Provides static methods for querying and converting between audio sample formats.
|
|
14
|
+
* These utilities help with format introspection, conversion between packed/planar
|
|
15
|
+
* layouts, and getting human-readable format information.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { SampleFormat } from 'node-av';
|
|
20
|
+
* import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
|
|
21
|
+
*
|
|
22
|
+
* // Get format information
|
|
23
|
+
* console.log(SampleFormat.getName(AV_SAMPLE_FMT_S16)); // "s16"
|
|
24
|
+
* console.log(SampleFormat.getBytesPerSample(AV_SAMPLE_FMT_S16)); // 2
|
|
25
|
+
* console.log(SampleFormat.isPlanar(AV_SAMPLE_FMT_FLTP)); // true
|
|
26
|
+
*
|
|
27
|
+
* // Convert between packed and planar formats
|
|
28
|
+
* const packed = SampleFormat.getPackedFormat(AV_SAMPLE_FMT_FLTP);
|
|
29
|
+
* const planar = SampleFormat.getPlanarFormat(AV_SAMPLE_FMT_FLT);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export class SampleFormat {
|
|
33
|
+
// Private constructor to prevent instantiation
|
|
34
|
+
constructor() { }
|
|
35
|
+
/**
|
|
36
|
+
* Get bytes per sample for a sample format.
|
|
37
|
+
*
|
|
38
|
+
* Returns the number of bytes required to store one sample in the given format.
|
|
39
|
+
* Direct mapping to av_get_bytes_per_sample()
|
|
40
|
+
*
|
|
41
|
+
* @param format - Audio sample format
|
|
42
|
+
* @returns Number of bytes per sample, or 0 for invalid format
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* import { SampleFormat } from 'node-av';
|
|
47
|
+
* import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT } from 'node-av/constants';
|
|
48
|
+
*
|
|
49
|
+
* console.log(SampleFormat.getBytesPerSample(AV_SAMPLE_FMT_S16)); // 2
|
|
50
|
+
* console.log(SampleFormat.getBytesPerSample(AV_SAMPLE_FMT_FLT)); // 4
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
static getBytesPerSample(format) {
|
|
54
|
+
return bindings.avGetBytesPerSample(format);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get the name of a sample format.
|
|
58
|
+
*
|
|
59
|
+
* Returns a string describing the sample format.
|
|
60
|
+
* Direct mapping to av_get_sample_fmt_name()
|
|
61
|
+
*
|
|
62
|
+
* @param format - Audio sample format
|
|
63
|
+
* @returns Format name string, or null for invalid format
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* import { SampleFormat } from 'node-av';
|
|
68
|
+
* import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
|
|
69
|
+
*
|
|
70
|
+
* console.log(SampleFormat.getName(AV_SAMPLE_FMT_S16)); // "s16"
|
|
71
|
+
* console.log(SampleFormat.getName(AV_SAMPLE_FMT_FLTP)); // "fltp"
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
static getName(format) {
|
|
75
|
+
return bindings.avGetSampleFmtName(format);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get packed sample format.
|
|
79
|
+
*
|
|
80
|
+
* Returns the packed variant of the given sample format.
|
|
81
|
+
* If the format is already packed, returns it unchanged.
|
|
82
|
+
* Direct mapping to av_get_packed_sample_fmt()
|
|
83
|
+
*
|
|
84
|
+
* @param format - Audio sample format
|
|
85
|
+
* @returns Packed sample format
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* import { SampleFormat } from 'node-av';
|
|
90
|
+
* import { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT } from 'node-av/constants';
|
|
91
|
+
*
|
|
92
|
+
* const packed = SampleFormat.getPackedFormat(AV_SAMPLE_FMT_FLTP);
|
|
93
|
+
* console.log(packed === AV_SAMPLE_FMT_FLT); // true
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
static getPackedFormat(format) {
|
|
97
|
+
return bindings.avGetPackedSampleFmt(format);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get planar sample format.
|
|
101
|
+
*
|
|
102
|
+
* Returns the planar variant of the given sample format.
|
|
103
|
+
* If the format is already planar, returns it unchanged.
|
|
104
|
+
* Direct mapping to av_get_planar_sample_fmt()
|
|
105
|
+
*
|
|
106
|
+
* @param format - Audio sample format
|
|
107
|
+
* @returns Planar sample format
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* import { SampleFormat } from 'node-av';
|
|
112
|
+
* import { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
|
|
113
|
+
*
|
|
114
|
+
* const planar = SampleFormat.getPlanarFormat(AV_SAMPLE_FMT_FLT);
|
|
115
|
+
* console.log(planar === AV_SAMPLE_FMT_FLTP); // true
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
static getPlanarFormat(format) {
|
|
119
|
+
return bindings.avGetPlanarSampleFmt(format);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Check if sample format is planar.
|
|
123
|
+
*
|
|
124
|
+
* Returns true if the sample format stores each channel in a separate buffer.
|
|
125
|
+
* Returns false if all channels are interleaved in a single buffer.
|
|
126
|
+
* Direct mapping to av_sample_fmt_is_planar()
|
|
127
|
+
*
|
|
128
|
+
* @param format - Audio sample format
|
|
129
|
+
* @returns True if format is planar, false if packed/interleaved
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```typescript
|
|
133
|
+
* import { SampleFormat } from 'node-av';
|
|
134
|
+
* import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P } from 'node-av/constants';
|
|
135
|
+
*
|
|
136
|
+
* console.log(SampleFormat.isPlanar(AV_SAMPLE_FMT_S16)); // false (packed)
|
|
137
|
+
* console.log(SampleFormat.isPlanar(AV_SAMPLE_FMT_S16P)); // true (planar)
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
static isPlanar(format) {
|
|
141
|
+
return bindings.avSampleFmtIsPlanar(format);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
//# 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;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,YAAY;IACvB,+CAA+C;IAC/C,gBAAuB,CAAC;IAExB;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,iBAAiB,CAAC,MAAsB;QAC7C,OAAO,QAAQ,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,OAAO,CAAC,MAAsB;QACnC,OAAO,QAAQ,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,eAAe,CAAC,MAAsB;QAC3C,OAAO,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,eAAe,CAAC,MAAsB;QAC3C,OAAO,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,QAAQ,CAAC,MAAsB;QACpC,OAAO,QAAQ,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;CACF"}
|