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,216 @@
|
|
|
1
|
+
import type { AVFormatFlag } from './constants.js';
|
|
2
|
+
import type { NativeInputFormat, NativeIOContext, NativeWrapper } from './native-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Input format (demuxer) descriptor.
|
|
5
|
+
*
|
|
6
|
+
* Describes a supported input container format for demuxing.
|
|
7
|
+
* Provides format information like name, extensions, and capabilities.
|
|
8
|
+
* These are read-only format descriptors managed by FFmpeg.
|
|
9
|
+
*
|
|
10
|
+
* Direct mapping to FFmpeg's AVInputFormat.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { InputFormat, FormatContext, FFmpegError } from 'node-av';
|
|
15
|
+
*
|
|
16
|
+
* // Find a specific input format
|
|
17
|
+
* const mp4Format = InputFormat.findInputFormat('mp4');
|
|
18
|
+
* if (mp4Format) {
|
|
19
|
+
* console.log(`Format: ${mp4Format.longName}`);
|
|
20
|
+
* console.log(`Extensions: ${mp4Format.extensions}`);
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* // Use with FormatContext
|
|
24
|
+
* const ctx = new FormatContext();
|
|
25
|
+
* ctx.allocContext();
|
|
26
|
+
*
|
|
27
|
+
* // Force a specific input format
|
|
28
|
+
* const movFormat = InputFormat.findInputFormat('mov');
|
|
29
|
+
* const ret = await ctx.openInput('video.dat', movFormat, null);
|
|
30
|
+
* FFmpegError.throwIfError(ret, 'openInput');
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @see {@link FormatContext} For using input formats
|
|
34
|
+
* @see {@link OutputFormat} For output formats
|
|
35
|
+
*/
|
|
36
|
+
export declare class InputFormat implements NativeWrapper<NativeInputFormat> {
|
|
37
|
+
private native;
|
|
38
|
+
/**
|
|
39
|
+
* Constructor is internal - use static factory methods.
|
|
40
|
+
*
|
|
41
|
+
* InputFormats are obtained via static methods, not created directly.
|
|
42
|
+
* FFmpeg manages these format descriptors internally.
|
|
43
|
+
*
|
|
44
|
+
* @internal
|
|
45
|
+
*
|
|
46
|
+
* @param native - Native AVInputFormat to wrap
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* import { InputFormat } from 'node-av';
|
|
51
|
+
*
|
|
52
|
+
* // Don't use constructor directly
|
|
53
|
+
* // const format = new InputFormat(); // Wrong
|
|
54
|
+
*
|
|
55
|
+
* // Use static factory methods instead
|
|
56
|
+
* const format = InputFormat.findInputFormat('mp4'); // Correct
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
constructor(native: NativeInputFormat);
|
|
60
|
+
/**
|
|
61
|
+
* Find a registered input format with matching name.
|
|
62
|
+
*
|
|
63
|
+
* Searches FFmpeg's registered demuxers by short name.
|
|
64
|
+
* Useful for forcing a specific format when auto-detection fails.
|
|
65
|
+
*
|
|
66
|
+
* Direct mapping to av_find_input_format()
|
|
67
|
+
*
|
|
68
|
+
* @param shortName - Short name of the format (e.g., 'mp4', 'mov', 'avi')
|
|
69
|
+
*
|
|
70
|
+
* @returns InputFormat if found, null otherwise
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* import { InputFormat, FormatContext, FFmpegError } from 'node-av';
|
|
75
|
+
*
|
|
76
|
+
* const format = InputFormat.findInputFormat('mp4');
|
|
77
|
+
* if (format) {
|
|
78
|
+
* console.log(`Found: ${format.longName}`);
|
|
79
|
+
* }
|
|
80
|
+
*
|
|
81
|
+
* // Force specific format when opening
|
|
82
|
+
* const movFormat = InputFormat.findInputFormat('mov');
|
|
83
|
+
* if (movFormat) {
|
|
84
|
+
* const ctx = new FormatContext();
|
|
85
|
+
* ctx.allocContext();
|
|
86
|
+
* const ret = await ctx.openInput('video.dat', movFormat, null);
|
|
87
|
+
* FFmpegError.throwIfError(ret, 'openInput');
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
static findInputFormat(shortName: string): InputFormat | null;
|
|
92
|
+
/**
|
|
93
|
+
* Probe input format from buffer data.
|
|
94
|
+
*
|
|
95
|
+
* Attempts to detect the input format based on buffer contents.
|
|
96
|
+
* This is a synchronous operation that analyzes buffer data to identify the format.
|
|
97
|
+
*
|
|
98
|
+
* Direct mapping to av_probe_input_format3()
|
|
99
|
+
*
|
|
100
|
+
* @param buffer - Buffer containing media data to probe
|
|
101
|
+
* @param filename - Optional filename hint to aid detection
|
|
102
|
+
*
|
|
103
|
+
* @returns InputFormat if detected, null otherwise
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* import { InputFormat } from 'node-av';
|
|
108
|
+
* import { readFileSync } from 'fs';
|
|
109
|
+
*
|
|
110
|
+
* // Read first few KB of a media file
|
|
111
|
+
* const buffer = readFileSync('video.mp4', { length: 4096 });
|
|
112
|
+
* const format = InputFormat.probe(buffer, 'video.mp4');
|
|
113
|
+
*
|
|
114
|
+
* if (format) {
|
|
115
|
+
* console.log(`Detected format: ${format.longName}`);
|
|
116
|
+
* }
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
static probe(buffer: Buffer, filename?: string): InputFormat | null;
|
|
120
|
+
/**
|
|
121
|
+
* Probe input format from IOContext buffer.
|
|
122
|
+
*
|
|
123
|
+
* Attempts to detect the input format by reading from an IOContext.
|
|
124
|
+
* This is an asynchronous operation that reads data from the IOContext to identify the format.
|
|
125
|
+
* The IOContext position may be changed during probing.
|
|
126
|
+
*
|
|
127
|
+
* Direct mapping to av_probe_input_buffer2()
|
|
128
|
+
*
|
|
129
|
+
* @param ioContext - IOContext to read data from for probing
|
|
130
|
+
* @param maxProbeSize - Maximum bytes to read for probing (0 for default)
|
|
131
|
+
*
|
|
132
|
+
* @returns Promise resolving to InputFormat if detected, null otherwise
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* import { InputFormat, IOContext } from 'node-av';
|
|
137
|
+
*
|
|
138
|
+
* // Open an IOContext
|
|
139
|
+
* const io = new IOContext();
|
|
140
|
+
* await io.open2('video.mp4', AVIO_FLAG_READ);
|
|
141
|
+
*
|
|
142
|
+
* // Probe the format
|
|
143
|
+
* const format = await InputFormat.probeBuffer(io);
|
|
144
|
+
*
|
|
145
|
+
* if (format) {
|
|
146
|
+
* console.log(`Detected format: ${format.longName}`);
|
|
147
|
+
* }
|
|
148
|
+
*
|
|
149
|
+
* await io.closep();
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
static probeBuffer(ioContext: {
|
|
153
|
+
getNative(): NativeIOContext;
|
|
154
|
+
}, maxProbeSize?: number): Promise<InputFormat | null>;
|
|
155
|
+
/**
|
|
156
|
+
* A comma separated list of short names for the format.
|
|
157
|
+
*
|
|
158
|
+
* Direct mapping to AVInputFormat->name
|
|
159
|
+
*
|
|
160
|
+
* @readonly
|
|
161
|
+
*/
|
|
162
|
+
get name(): string | null;
|
|
163
|
+
/**
|
|
164
|
+
* Descriptive name for the format.
|
|
165
|
+
*
|
|
166
|
+
* Direct mapping to AVInputFormat->long_name
|
|
167
|
+
*
|
|
168
|
+
* Meant to be more human-readable than the short name.
|
|
169
|
+
* @readonly
|
|
170
|
+
*/
|
|
171
|
+
get longName(): string | null;
|
|
172
|
+
/**
|
|
173
|
+
* Comma-separated list of file extensions.
|
|
174
|
+
*
|
|
175
|
+
* Direct mapping to AVInputFormat->extensions
|
|
176
|
+
*
|
|
177
|
+
* If extensions are defined, then no probe is done.
|
|
178
|
+
* @readonly
|
|
179
|
+
*/
|
|
180
|
+
get extensions(): string | null;
|
|
181
|
+
/**
|
|
182
|
+
* Comma-separated list of mime types.
|
|
183
|
+
*
|
|
184
|
+
* Direct mapping to AVInputFormat->mime_type
|
|
185
|
+
*
|
|
186
|
+
* @readonly
|
|
187
|
+
*/
|
|
188
|
+
get mimeType(): string | null;
|
|
189
|
+
/**
|
|
190
|
+
* Format flags.
|
|
191
|
+
*
|
|
192
|
+
* Direct mapping to AVInputFormat->flags
|
|
193
|
+
*
|
|
194
|
+
* Combination of AVFMT_* flags:
|
|
195
|
+
* - AVFMT_NOFILE: No file is opened
|
|
196
|
+
* - AVFMT_NEEDNUMBER: Needs '%d' in filename
|
|
197
|
+
* - AVFMT_SHOW_IDS: Show format stream IDs
|
|
198
|
+
* - AVFMT_GLOBALHEADER: Format wants global headers
|
|
199
|
+
* - AVFMT_NOTIMESTAMPS: Format does not need/have timestamps
|
|
200
|
+
* - AVFMT_GENERIC_INDEX: Use generic index building code
|
|
201
|
+
* - AVFMT_TS_DISCONT: Format allows timestamp discontinuities
|
|
202
|
+
* - AVFMT_NOBINSEARCH: Format does not allow seeking by bytes
|
|
203
|
+
* - AVFMT_NOGENSEARCH: Format does not allow seeking by timestamp
|
|
204
|
+
* - AVFMT_NO_BYTE_SEEK: Format does not allow seeking by bytes
|
|
205
|
+
* - AVFMT_SEEK_TO_PTS: Seeking is based on PTS
|
|
206
|
+
* @readonly
|
|
207
|
+
*/
|
|
208
|
+
get flags(): AVFormatFlag;
|
|
209
|
+
/**
|
|
210
|
+
* Get the native FFmpeg AVInputFormat pointer.
|
|
211
|
+
*
|
|
212
|
+
* @internal For use by other wrapper classes
|
|
213
|
+
* @returns The underlying native input format object
|
|
214
|
+
*/
|
|
215
|
+
getNative(): NativeInputFormat;
|
|
216
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { bindings } from './binding.js';
|
|
2
|
+
/**
|
|
3
|
+
* Input format (demuxer) descriptor.
|
|
4
|
+
*
|
|
5
|
+
* Describes a supported input container format for demuxing.
|
|
6
|
+
* Provides format information like name, extensions, and capabilities.
|
|
7
|
+
* These are read-only format descriptors managed by FFmpeg.
|
|
8
|
+
*
|
|
9
|
+
* Direct mapping to FFmpeg's AVInputFormat.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { InputFormat, FormatContext, FFmpegError } from 'node-av';
|
|
14
|
+
*
|
|
15
|
+
* // Find a specific input format
|
|
16
|
+
* const mp4Format = InputFormat.findInputFormat('mp4');
|
|
17
|
+
* if (mp4Format) {
|
|
18
|
+
* console.log(`Format: ${mp4Format.longName}`);
|
|
19
|
+
* console.log(`Extensions: ${mp4Format.extensions}`);
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* // Use with FormatContext
|
|
23
|
+
* const ctx = new FormatContext();
|
|
24
|
+
* ctx.allocContext();
|
|
25
|
+
*
|
|
26
|
+
* // Force a specific input format
|
|
27
|
+
* const movFormat = InputFormat.findInputFormat('mov');
|
|
28
|
+
* const ret = await ctx.openInput('video.dat', movFormat, null);
|
|
29
|
+
* FFmpegError.throwIfError(ret, 'openInput');
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @see {@link FormatContext} For using input formats
|
|
33
|
+
* @see {@link OutputFormat} For output formats
|
|
34
|
+
*/
|
|
35
|
+
export class InputFormat {
|
|
36
|
+
native;
|
|
37
|
+
/**
|
|
38
|
+
* Constructor is internal - use static factory methods.
|
|
39
|
+
*
|
|
40
|
+
* InputFormats are obtained via static methods, not created directly.
|
|
41
|
+
* FFmpeg manages these format descriptors internally.
|
|
42
|
+
*
|
|
43
|
+
* @internal
|
|
44
|
+
*
|
|
45
|
+
* @param native - Native AVInputFormat to wrap
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* import { InputFormat } from 'node-av';
|
|
50
|
+
*
|
|
51
|
+
* // Don't use constructor directly
|
|
52
|
+
* // const format = new InputFormat(); // Wrong
|
|
53
|
+
*
|
|
54
|
+
* // Use static factory methods instead
|
|
55
|
+
* const format = InputFormat.findInputFormat('mp4'); // Correct
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
constructor(native) {
|
|
59
|
+
this.native = native;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Find a registered input format with matching name.
|
|
63
|
+
*
|
|
64
|
+
* Searches FFmpeg's registered demuxers by short name.
|
|
65
|
+
* Useful for forcing a specific format when auto-detection fails.
|
|
66
|
+
*
|
|
67
|
+
* Direct mapping to av_find_input_format()
|
|
68
|
+
*
|
|
69
|
+
* @param shortName - Short name of the format (e.g., 'mp4', 'mov', 'avi')
|
|
70
|
+
*
|
|
71
|
+
* @returns InputFormat if found, null otherwise
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* import { InputFormat, FormatContext, FFmpegError } from 'node-av';
|
|
76
|
+
*
|
|
77
|
+
* const format = InputFormat.findInputFormat('mp4');
|
|
78
|
+
* if (format) {
|
|
79
|
+
* console.log(`Found: ${format.longName}`);
|
|
80
|
+
* }
|
|
81
|
+
*
|
|
82
|
+
* // Force specific format when opening
|
|
83
|
+
* const movFormat = InputFormat.findInputFormat('mov');
|
|
84
|
+
* if (movFormat) {
|
|
85
|
+
* const ctx = new FormatContext();
|
|
86
|
+
* ctx.allocContext();
|
|
87
|
+
* const ret = await ctx.openInput('video.dat', movFormat, null);
|
|
88
|
+
* FFmpegError.throwIfError(ret, 'openInput');
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
static findInputFormat(shortName) {
|
|
93
|
+
const native = bindings.InputFormat.findInputFormat(shortName);
|
|
94
|
+
if (!native) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
return new InputFormat(native);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Probe input format from buffer data.
|
|
101
|
+
*
|
|
102
|
+
* Attempts to detect the input format based on buffer contents.
|
|
103
|
+
* This is a synchronous operation that analyzes buffer data to identify the format.
|
|
104
|
+
*
|
|
105
|
+
* Direct mapping to av_probe_input_format3()
|
|
106
|
+
*
|
|
107
|
+
* @param buffer - Buffer containing media data to probe
|
|
108
|
+
* @param filename - Optional filename hint to aid detection
|
|
109
|
+
*
|
|
110
|
+
* @returns InputFormat if detected, null otherwise
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* import { InputFormat } from 'node-av';
|
|
115
|
+
* import { readFileSync } from 'fs';
|
|
116
|
+
*
|
|
117
|
+
* // Read first few KB of a media file
|
|
118
|
+
* const buffer = readFileSync('video.mp4', { length: 4096 });
|
|
119
|
+
* const format = InputFormat.probe(buffer, 'video.mp4');
|
|
120
|
+
*
|
|
121
|
+
* if (format) {
|
|
122
|
+
* console.log(`Detected format: ${format.longName}`);
|
|
123
|
+
* }
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
static probe(buffer, filename) {
|
|
127
|
+
const native = bindings.InputFormat.probe(buffer, filename);
|
|
128
|
+
if (!native) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
return new InputFormat(native);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Probe input format from IOContext buffer.
|
|
135
|
+
*
|
|
136
|
+
* Attempts to detect the input format by reading from an IOContext.
|
|
137
|
+
* This is an asynchronous operation that reads data from the IOContext to identify the format.
|
|
138
|
+
* The IOContext position may be changed during probing.
|
|
139
|
+
*
|
|
140
|
+
* Direct mapping to av_probe_input_buffer2()
|
|
141
|
+
*
|
|
142
|
+
* @param ioContext - IOContext to read data from for probing
|
|
143
|
+
* @param maxProbeSize - Maximum bytes to read for probing (0 for default)
|
|
144
|
+
*
|
|
145
|
+
* @returns Promise resolving to InputFormat if detected, null otherwise
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* import { InputFormat, IOContext } from 'node-av';
|
|
150
|
+
*
|
|
151
|
+
* // Open an IOContext
|
|
152
|
+
* const io = new IOContext();
|
|
153
|
+
* await io.open2('video.mp4', AVIO_FLAG_READ);
|
|
154
|
+
*
|
|
155
|
+
* // Probe the format
|
|
156
|
+
* const format = await InputFormat.probeBuffer(io);
|
|
157
|
+
*
|
|
158
|
+
* if (format) {
|
|
159
|
+
* console.log(`Detected format: ${format.longName}`);
|
|
160
|
+
* }
|
|
161
|
+
*
|
|
162
|
+
* await io.closep();
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
static async probeBuffer(ioContext, maxProbeSize) {
|
|
166
|
+
const native = await bindings.InputFormat.probeBuffer(ioContext.getNative(), maxProbeSize);
|
|
167
|
+
if (!native) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
return new InputFormat(native);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* A comma separated list of short names for the format.
|
|
174
|
+
*
|
|
175
|
+
* Direct mapping to AVInputFormat->name
|
|
176
|
+
*
|
|
177
|
+
* @readonly
|
|
178
|
+
*/
|
|
179
|
+
get name() {
|
|
180
|
+
return this.native.name;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Descriptive name for the format.
|
|
184
|
+
*
|
|
185
|
+
* Direct mapping to AVInputFormat->long_name
|
|
186
|
+
*
|
|
187
|
+
* Meant to be more human-readable than the short name.
|
|
188
|
+
* @readonly
|
|
189
|
+
*/
|
|
190
|
+
get longName() {
|
|
191
|
+
return this.native.longName;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Comma-separated list of file extensions.
|
|
195
|
+
*
|
|
196
|
+
* Direct mapping to AVInputFormat->extensions
|
|
197
|
+
*
|
|
198
|
+
* If extensions are defined, then no probe is done.
|
|
199
|
+
* @readonly
|
|
200
|
+
*/
|
|
201
|
+
get extensions() {
|
|
202
|
+
return this.native.extensions;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Comma-separated list of mime types.
|
|
206
|
+
*
|
|
207
|
+
* Direct mapping to AVInputFormat->mime_type
|
|
208
|
+
*
|
|
209
|
+
* @readonly
|
|
210
|
+
*/
|
|
211
|
+
get mimeType() {
|
|
212
|
+
return this.native.mimeType;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Format flags.
|
|
216
|
+
*
|
|
217
|
+
* Direct mapping to AVInputFormat->flags
|
|
218
|
+
*
|
|
219
|
+
* Combination of AVFMT_* flags:
|
|
220
|
+
* - AVFMT_NOFILE: No file is opened
|
|
221
|
+
* - AVFMT_NEEDNUMBER: Needs '%d' in filename
|
|
222
|
+
* - AVFMT_SHOW_IDS: Show format stream IDs
|
|
223
|
+
* - AVFMT_GLOBALHEADER: Format wants global headers
|
|
224
|
+
* - AVFMT_NOTIMESTAMPS: Format does not need/have timestamps
|
|
225
|
+
* - AVFMT_GENERIC_INDEX: Use generic index building code
|
|
226
|
+
* - AVFMT_TS_DISCONT: Format allows timestamp discontinuities
|
|
227
|
+
* - AVFMT_NOBINSEARCH: Format does not allow seeking by bytes
|
|
228
|
+
* - AVFMT_NOGENSEARCH: Format does not allow seeking by timestamp
|
|
229
|
+
* - AVFMT_NO_BYTE_SEEK: Format does not allow seeking by bytes
|
|
230
|
+
* - AVFMT_SEEK_TO_PTS: Seeking is based on PTS
|
|
231
|
+
* @readonly
|
|
232
|
+
*/
|
|
233
|
+
get flags() {
|
|
234
|
+
return this.native.flags;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Get the native FFmpeg AVInputFormat pointer.
|
|
238
|
+
*
|
|
239
|
+
* @internal For use by other wrapper classes
|
|
240
|
+
* @returns The underlying native input format object
|
|
241
|
+
*/
|
|
242
|
+
getNative() {
|
|
243
|
+
return this.native;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
//# sourceMappingURL=input-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-format.js","sourceRoot":"","sources":["../../src/lib/input-format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAKxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,OAAO,WAAW;IACd,MAAM,CAAoB;IAElC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,YAAY,MAAyB;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,MAAM,CAAC,eAAe,CAAC,SAAiB;QACtC,MAAM,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QAC/D,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,MAAM,CAAC,KAAK,CAAC,MAAc,EAAE,QAAiB;QAC5C,MAAM,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC5D,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,SAA2C,EAAE,YAAqB;QACzF,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,YAAY,CAAC,CAAC;QAC3F,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;OAMG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;IAChC,CAAC;IAED;;;;;;OAMG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IAC3B,CAAC;IAED;;;;;OAKG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF"}
|