node-av 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -38
- package/dist/api/bitstream-filter.d.ts +180 -123
- package/dist/api/bitstream-filter.js +180 -125
- package/dist/api/bitstream-filter.js.map +1 -1
- package/dist/api/decoder.d.ts +279 -132
- package/dist/api/decoder.js +285 -142
- package/dist/api/decoder.js.map +1 -1
- package/dist/api/encoder.d.ts +246 -162
- package/dist/api/encoder.js +272 -208
- package/dist/api/encoder.js.map +1 -1
- package/dist/api/filter-presets.d.ts +690 -94
- package/dist/api/filter-presets.js +686 -102
- package/dist/api/filter-presets.js.map +1 -1
- package/dist/api/filter.d.ts +249 -213
- package/dist/api/filter.js +252 -242
- package/dist/api/filter.js.map +1 -1
- package/dist/api/hardware.d.ts +224 -117
- package/dist/api/hardware.js +380 -214
- package/dist/api/hardware.js.map +1 -1
- package/dist/api/index.d.ts +3 -3
- package/dist/api/index.js +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/io-stream.d.ts +65 -61
- package/dist/api/io-stream.js +43 -46
- package/dist/api/io-stream.js.map +1 -1
- package/dist/api/media-input.d.ts +242 -140
- package/dist/api/media-input.js +205 -103
- package/dist/api/media-input.js.map +1 -1
- package/dist/api/media-output.d.ts +206 -128
- package/dist/api/media-output.js +210 -128
- package/dist/api/media-output.js.map +1 -1
- package/dist/api/pipeline.d.ts +168 -38
- package/dist/api/pipeline.js +238 -14
- package/dist/api/pipeline.js.map +1 -1
- package/dist/api/types.d.ts +21 -187
- package/dist/api/utils.d.ts +1 -2
- package/dist/api/utils.js +9 -0
- package/dist/api/utils.js.map +1 -1
- package/dist/lib/audio-fifo.d.ts +127 -170
- package/dist/lib/audio-fifo.js +130 -173
- package/dist/lib/audio-fifo.js.map +1 -1
- package/dist/lib/binding.js +5 -0
- package/dist/lib/binding.js.map +1 -1
- package/dist/lib/bitstream-filter-context.d.ts +139 -184
- package/dist/lib/bitstream-filter-context.js +139 -188
- package/dist/lib/bitstream-filter-context.js.map +1 -1
- package/dist/lib/bitstream-filter.d.ts +68 -54
- package/dist/lib/bitstream-filter.js +68 -54
- package/dist/lib/bitstream-filter.js.map +1 -1
- package/dist/lib/codec-context.d.ts +316 -380
- package/dist/lib/codec-context.js +316 -381
- package/dist/lib/codec-context.js.map +1 -1
- package/dist/lib/codec-parameters.d.ts +160 -170
- package/dist/lib/codec-parameters.js +162 -172
- package/dist/lib/codec-parameters.js.map +1 -1
- package/dist/lib/codec-parser.d.ts +91 -104
- package/dist/lib/codec-parser.js +92 -103
- package/dist/lib/codec-parser.js.map +1 -1
- package/dist/lib/codec.d.ts +264 -281
- package/dist/lib/codec.js +268 -285
- package/dist/lib/codec.js.map +1 -1
- package/dist/lib/dictionary.d.ts +149 -203
- package/dist/lib/dictionary.js +158 -212
- package/dist/lib/dictionary.js.map +1 -1
- package/dist/lib/error.d.ts +96 -130
- package/dist/lib/error.js +98 -128
- package/dist/lib/error.js.map +1 -1
- package/dist/lib/filter-context.d.ts +284 -218
- package/dist/lib/filter-context.js +290 -227
- package/dist/lib/filter-context.js.map +1 -1
- package/dist/lib/filter-graph.d.ts +251 -292
- package/dist/lib/filter-graph.js +253 -294
- package/dist/lib/filter-graph.js.map +1 -1
- package/dist/lib/filter-inout.d.ts +87 -95
- package/dist/lib/filter-inout.js +87 -95
- package/dist/lib/filter-inout.js.map +1 -1
- package/dist/lib/filter.d.ts +93 -111
- package/dist/lib/filter.js +93 -111
- package/dist/lib/filter.js.map +1 -1
- package/dist/lib/format-context.d.ts +320 -428
- package/dist/lib/format-context.js +313 -385
- package/dist/lib/format-context.js.map +1 -1
- package/dist/lib/frame.d.ts +262 -405
- package/dist/lib/frame.js +263 -408
- package/dist/lib/frame.js.map +1 -1
- package/dist/lib/hardware-device-context.d.ts +149 -203
- package/dist/lib/hardware-device-context.js +149 -203
- package/dist/lib/hardware-device-context.js.map +1 -1
- package/dist/lib/hardware-frames-context.d.ts +170 -180
- package/dist/lib/hardware-frames-context.js +171 -181
- package/dist/lib/hardware-frames-context.js.map +1 -1
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/index.js +2 -2
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/input-format.d.ts +89 -117
- package/dist/lib/input-format.js +89 -117
- package/dist/lib/input-format.js.map +1 -1
- package/dist/lib/io-context.d.ts +209 -241
- package/dist/lib/io-context.js +220 -252
- package/dist/lib/io-context.js.map +1 -1
- package/dist/lib/log.d.ts +85 -119
- package/dist/lib/log.js +85 -122
- package/dist/lib/log.js.map +1 -1
- package/dist/lib/native-types.d.ts +117 -106
- package/dist/lib/native-types.js +0 -7
- package/dist/lib/native-types.js.map +1 -1
- package/dist/lib/option.d.ts +284 -241
- package/dist/lib/option.js +309 -249
- package/dist/lib/option.js.map +1 -1
- package/dist/lib/output-format.d.ts +77 -101
- package/dist/lib/output-format.js +77 -101
- package/dist/lib/output-format.js.map +1 -1
- package/dist/lib/packet.d.ts +172 -240
- package/dist/lib/packet.js +172 -241
- package/dist/lib/packet.js.map +1 -1
- package/dist/lib/rational.d.ts +0 -2
- package/dist/lib/rational.js +0 -2
- package/dist/lib/rational.js.map +1 -1
- package/dist/lib/software-resample-context.d.ts +241 -325
- package/dist/lib/software-resample-context.js +242 -326
- package/dist/lib/software-resample-context.js.map +1 -1
- package/dist/lib/software-scale-context.d.ts +129 -173
- package/dist/lib/software-scale-context.js +131 -175
- package/dist/lib/software-scale-context.js.map +1 -1
- package/dist/lib/stream.d.ts +87 -197
- package/dist/lib/stream.js +87 -197
- package/dist/lib/stream.js.map +1 -1
- package/dist/lib/utilities.d.ts +372 -181
- package/dist/lib/utilities.js +373 -182
- package/dist/lib/utilities.js.map +1 -1
- package/install/check.js +0 -1
- package/package.json +21 -12
- package/release_notes.md +43 -59
- package/CHANGELOG.md +0 -8
|
@@ -1,72 +1,61 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MediaOutput - Unified Output Handler for FFmpeg
|
|
3
|
-
*
|
|
4
|
-
* Provides a high-level interface for writing media to various destinations.
|
|
5
|
-
* Supports files, streams, and custom IO with automatic format configuration.
|
|
6
|
-
*
|
|
7
|
-
* Central entry point for all media output operations.
|
|
8
|
-
* Manages FormatContext lifecycle and provides stream management.
|
|
9
|
-
*
|
|
10
|
-
* @module api/media-output
|
|
11
|
-
*/
|
|
12
1
|
import { FormatContext } from '../lib/index.js';
|
|
13
2
|
import { Encoder } from './encoder.js';
|
|
14
3
|
import type { IRational, Packet, Stream } from '../lib/index.js';
|
|
15
4
|
import type { IOOutputCallbacks, MediaOutputOptions } from './types.js';
|
|
16
|
-
interface
|
|
5
|
+
export interface StreamDescription {
|
|
17
6
|
stream: Stream;
|
|
18
7
|
timeBase: IRational;
|
|
19
8
|
isStreamCopy: boolean;
|
|
20
9
|
sourceTimeBase?: IRational;
|
|
21
10
|
}
|
|
22
11
|
/**
|
|
23
|
-
*
|
|
12
|
+
* High-level media output for writing and muxing media files.
|
|
24
13
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* adding streams, writing packets, and finalizing output.
|
|
14
|
+
* Provides simplified access to media muxing and file writing operations.
|
|
15
|
+
* Handles stream configuration, packet writing, and format management.
|
|
16
|
+
* Supports files, URLs, and custom I/O with automatic cleanup.
|
|
17
|
+
* Essential component for media encoding pipelines and transcoding.
|
|
30
18
|
*
|
|
31
19
|
* @example
|
|
32
20
|
* ```typescript
|
|
33
|
-
* import { MediaOutput
|
|
21
|
+
* import { MediaOutput } from 'node-av/api';
|
|
34
22
|
*
|
|
35
|
-
* //
|
|
36
|
-
*
|
|
23
|
+
* // Create output file
|
|
24
|
+
* await using output = await MediaOutput.open('output.mp4');
|
|
37
25
|
*
|
|
38
|
-
* // Add
|
|
39
|
-
* const
|
|
40
|
-
*
|
|
41
|
-
* height: 1080,
|
|
42
|
-
* pixelFormat: AV_PIX_FMT_YUV420P
|
|
43
|
-
* });
|
|
44
|
-
* const streamIdx = output.addStream(encoder);
|
|
26
|
+
* // Add streams from encoders
|
|
27
|
+
* const videoIdx = output.addStream(videoEncoder);
|
|
28
|
+
* const audioIdx = output.addStream(audioEncoder);
|
|
45
29
|
*
|
|
46
|
-
* // Write header
|
|
30
|
+
* // Write header
|
|
47
31
|
* await output.writeHeader();
|
|
48
|
-
*
|
|
32
|
+
*
|
|
33
|
+
* // Write packets
|
|
34
|
+
* await output.writePacket(packet, videoIdx);
|
|
35
|
+
*
|
|
36
|
+
* // Write trailer and close
|
|
49
37
|
* await output.writeTrailer();
|
|
50
|
-
* await output.close();
|
|
51
38
|
* ```
|
|
52
39
|
*
|
|
53
40
|
* @example
|
|
54
41
|
* ```typescript
|
|
55
|
-
* // Stream copy
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* const videoStream = input.video();
|
|
60
|
-
* const streamIdx = output.addStream(videoStream);
|
|
42
|
+
* // Stream copy
|
|
43
|
+
* await using input = await MediaInput.open('input.mp4');
|
|
44
|
+
* await using output = await MediaOutput.open('output.mp4');
|
|
61
45
|
*
|
|
46
|
+
* // Copy stream configuration
|
|
47
|
+
* const videoIdx = output.addStream(input.video());
|
|
62
48
|
* await output.writeHeader();
|
|
49
|
+
*
|
|
63
50
|
* for await (const packet of input.packets()) {
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* }
|
|
51
|
+
* await output.writePacket(packet, videoIdx);
|
|
52
|
+
* packet.free();
|
|
67
53
|
* }
|
|
68
|
-
* await output.writeTrailer();
|
|
69
54
|
* ```
|
|
55
|
+
*
|
|
56
|
+
* @see {@link MediaInput} For reading media files
|
|
57
|
+
* @see {@link Encoder} For encoding frames to packets
|
|
58
|
+
* @see {@link FormatContext} For low-level API
|
|
70
59
|
*/
|
|
71
60
|
export declare class MediaOutput implements AsyncDisposable {
|
|
72
61
|
private formatContext;
|
|
@@ -76,199 +65,288 @@ export declare class MediaOutput implements AsyncDisposable {
|
|
|
76
65
|
private trailerWritten;
|
|
77
66
|
private closed;
|
|
78
67
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* Initializes the output with a new FormatContext.
|
|
82
|
-
* The actual format setup happens in the static factory method.
|
|
68
|
+
* @internal
|
|
83
69
|
*/
|
|
84
70
|
private constructor();
|
|
85
71
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* Creates a FormatContext and prepares the output for writing.
|
|
89
|
-
* Automatically detects format from filename/URL if not specified.
|
|
90
|
-
*
|
|
91
|
-
* If io callbacks is used, it creates a FormatContext with custom IO handling.
|
|
92
|
-
* Format must be explicitly specified for custom IO.
|
|
72
|
+
* Open media output for writing.
|
|
93
73
|
*
|
|
94
|
-
*
|
|
74
|
+
* Creates and configures output context for muxing.
|
|
75
|
+
* Automatically creates directories for file output.
|
|
76
|
+
* Supports files, URLs, and custom I/O callbacks.
|
|
95
77
|
*
|
|
96
|
-
*
|
|
97
|
-
* @param options - Optional configuration
|
|
78
|
+
* Direct mapping to avformat_alloc_output_context2() and avio_open2().
|
|
98
79
|
*
|
|
99
|
-
* @
|
|
80
|
+
* @param target - File path, URL, or I/O callbacks
|
|
81
|
+
* @param options - Output configuration options
|
|
82
|
+
* @returns Opened media output instance
|
|
100
83
|
*
|
|
101
|
-
* @throws {Error} If format
|
|
84
|
+
* @throws {Error} If format required for custom I/O
|
|
85
|
+
* @throws {FFmpegError} If allocation or opening fails
|
|
102
86
|
*
|
|
103
87
|
* @example
|
|
104
88
|
* ```typescript
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* seek: (offset, whence) => offset
|
|
108
|
-
* };
|
|
109
|
-
* const output = await MediaOutput.open(callbacks, { format: 'mp4' });
|
|
89
|
+
* // Create file output
|
|
90
|
+
* await using output = await MediaOutput.open('output.mp4');
|
|
110
91
|
* ```
|
|
111
92
|
*
|
|
112
93
|
* @example
|
|
113
94
|
* ```typescript
|
|
114
|
-
*
|
|
95
|
+
* // Create output with specific format
|
|
96
|
+
* await using output = await MediaOutput.open('output.ts', {
|
|
97
|
+
* format: 'mpegts'
|
|
98
|
+
* });
|
|
115
99
|
* ```
|
|
116
100
|
*
|
|
117
101
|
* @example
|
|
118
102
|
* ```typescript
|
|
119
|
-
*
|
|
103
|
+
* // Custom I/O callbacks
|
|
104
|
+
* const callbacks = {
|
|
105
|
+
* write: async (buffer: Buffer) => {
|
|
106
|
+
* // Write to custom destination
|
|
107
|
+
* return buffer.length;
|
|
108
|
+
* },
|
|
109
|
+
* seek: async (offset: bigint, whence: number) => {
|
|
110
|
+
* // Seek in custom destination
|
|
111
|
+
* return offset;
|
|
112
|
+
* }
|
|
113
|
+
* };
|
|
114
|
+
*
|
|
115
|
+
* await using output = await MediaOutput.open(callbacks, {
|
|
116
|
+
* format: 'mp4',
|
|
117
|
+
* bufferSize: 8192
|
|
118
|
+
* });
|
|
120
119
|
* ```
|
|
120
|
+
*
|
|
121
|
+
* @see {@link MediaOutputOptions} For configuration options
|
|
122
|
+
* @see {@link IOOutputCallbacks} For custom I/O interface
|
|
121
123
|
*/
|
|
122
124
|
static open(target: string | IOOutputCallbacks, options?: MediaOutputOptions): Promise<MediaOutput>;
|
|
123
125
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* Creates a new stream in the output format context.
|
|
127
|
-
* Copies codec parameters from encoder or input stream.
|
|
126
|
+
* Add a stream to the output.
|
|
128
127
|
*
|
|
129
|
-
*
|
|
128
|
+
* Configures output stream from encoder or input stream.
|
|
129
|
+
* Must be called before writeHeader().
|
|
130
|
+
* Returns stream index for packet writing.
|
|
130
131
|
*
|
|
131
|
-
*
|
|
132
|
-
* @param options - Optional stream configuration
|
|
133
|
-
* @param options.timeBase - Custom output timebase for the stream.
|
|
134
|
-
* If not specified, uses the source's timebase.
|
|
135
|
-
* When set, packets will be automatically rescaled
|
|
136
|
-
* from source timebase to this output timebase.
|
|
132
|
+
* Direct mapping to avformat_new_stream() and avcodec_parameters_copy().
|
|
137
133
|
*
|
|
134
|
+
* @param source - Encoder or stream to add
|
|
135
|
+
* @param options - Stream configuration options
|
|
136
|
+
* @param options.timeBase - Optional custom timebase for the stream
|
|
138
137
|
* @returns Stream index for packet writing
|
|
139
138
|
*
|
|
140
|
-
* @throws {Error} If called after header
|
|
141
|
-
*
|
|
142
|
-
* @example
|
|
143
|
-
* ```typescript
|
|
144
|
-
* // Add encoder stream (transcoding) - uses encoder's timebase
|
|
145
|
-
* const encoder = await Encoder.create('libx264', { width: 1920, height: 1080 });
|
|
146
|
-
* const streamIdx = output.addStream(encoder);
|
|
147
|
-
* ```
|
|
139
|
+
* @throws {Error} If called after header written or output closed
|
|
148
140
|
*
|
|
149
141
|
* @example
|
|
150
142
|
* ```typescript
|
|
151
|
-
* // Add stream
|
|
152
|
-
* const
|
|
153
|
-
* const
|
|
143
|
+
* // Add stream from encoder
|
|
144
|
+
* const videoIdx = output.addStream(videoEncoder);
|
|
145
|
+
* const audioIdx = output.addStream(audioEncoder);
|
|
154
146
|
* ```
|
|
155
147
|
*
|
|
156
148
|
* @example
|
|
157
149
|
* ```typescript
|
|
158
|
-
* //
|
|
159
|
-
* const streamIdx = output.addStream(
|
|
160
|
-
* timeBase: { num: 1, den: 90000 }
|
|
150
|
+
* // Stream copy with custom timebase
|
|
151
|
+
* const streamIdx = output.addStream(input.video(), {
|
|
152
|
+
* timeBase: { num: 1, den: 90000 }
|
|
161
153
|
* });
|
|
162
|
-
* // Packets from encoder will be automatically rescaled to 1/90000
|
|
163
154
|
* ```
|
|
155
|
+
*
|
|
156
|
+
* @see {@link writePacket} For writing packets to streams
|
|
157
|
+
* @see {@link Encoder} For transcoding source
|
|
164
158
|
*/
|
|
165
159
|
addStream(source: Encoder | Stream, options?: {
|
|
166
160
|
timeBase?: IRational;
|
|
167
161
|
}): number;
|
|
168
162
|
/**
|
|
169
|
-
*
|
|
163
|
+
* Write a packet to the output.
|
|
170
164
|
*
|
|
171
|
-
* Writes
|
|
172
|
-
* Automatically
|
|
165
|
+
* Writes muxed packet to the specified stream.
|
|
166
|
+
* Automatically handles timestamp rescaling.
|
|
167
|
+
* Must be called after writeHeader() and before writeTrailer().
|
|
173
168
|
*
|
|
174
|
-
*
|
|
169
|
+
* Direct mapping to av_interleaved_write_frame().
|
|
175
170
|
*
|
|
176
171
|
* @param packet - Packet to write
|
|
177
172
|
* @param streamIndex - Target stream index
|
|
173
|
+
* @throws {Error} If stream invalid or called at wrong time
|
|
174
|
+
* @throws {FFmpegError} If write fails
|
|
178
175
|
*
|
|
179
|
-
* @
|
|
176
|
+
* @example
|
|
177
|
+
* ```typescript
|
|
178
|
+
* // Write encoded packet
|
|
179
|
+
* const packet = await encoder.encode(frame);
|
|
180
|
+
* if (packet) {
|
|
181
|
+
* await output.writePacket(packet, videoIdx);
|
|
182
|
+
* packet.free();
|
|
183
|
+
* }
|
|
184
|
+
* ```
|
|
180
185
|
*
|
|
181
186
|
* @example
|
|
182
187
|
* ```typescript
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
188
|
+
* // Stream copy with packet processing
|
|
189
|
+
* for await (const packet of input.packets()) {
|
|
190
|
+
* if (packet.streamIndex === inputVideoIdx) {
|
|
191
|
+
* await output.writePacket(packet, outputVideoIdx);
|
|
192
|
+
* }
|
|
193
|
+
* packet.free();
|
|
187
194
|
* }
|
|
188
195
|
* ```
|
|
196
|
+
*
|
|
197
|
+
* @see {@link addStream} For adding streams
|
|
198
|
+
* @see {@link writeHeader} Must be called first
|
|
189
199
|
*/
|
|
190
200
|
writePacket(packet: Packet, streamIndex: number): Promise<void>;
|
|
191
201
|
/**
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
* Writes the container header with stream information.
|
|
195
|
-
* Must be called before writing any packets.
|
|
202
|
+
* Write file header.
|
|
196
203
|
*
|
|
197
|
-
*
|
|
204
|
+
* Writes format header with stream configuration.
|
|
205
|
+
* Must be called after adding all streams and before writing packets.
|
|
206
|
+
* Finalizes stream parameters and initializes muxer.
|
|
198
207
|
*
|
|
199
|
-
*
|
|
208
|
+
* Direct mapping to avformat_write_header().
|
|
200
209
|
*
|
|
201
|
-
* @throws {Error} If
|
|
210
|
+
* @throws {Error} If already written or output closed
|
|
211
|
+
* @throws {FFmpegError} If write fails
|
|
202
212
|
*
|
|
203
213
|
* @example
|
|
204
214
|
* ```typescript
|
|
215
|
+
* // Standard workflow
|
|
216
|
+
* const output = await MediaOutput.open('output.mp4');
|
|
217
|
+
* output.addStream(encoder);
|
|
205
218
|
* await output.writeHeader();
|
|
219
|
+
* // Now ready to write packets
|
|
206
220
|
* ```
|
|
221
|
+
*
|
|
222
|
+
* @see {@link addStream} Must add streams first
|
|
223
|
+
* @see {@link writePacket} Can write packets after
|
|
224
|
+
* @see {@link writeTrailer} Must call at end
|
|
207
225
|
*/
|
|
208
226
|
writeHeader(): Promise<void>;
|
|
209
227
|
/**
|
|
210
|
-
*
|
|
228
|
+
* Write file trailer.
|
|
211
229
|
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
230
|
+
* Writes format trailer and finalizes the file.
|
|
231
|
+
* Must be called after all packets are written.
|
|
232
|
+
* Flushes any buffered data and updates file headers.
|
|
214
233
|
*
|
|
215
|
-
*
|
|
234
|
+
* Direct mapping to av_write_trailer().
|
|
216
235
|
*
|
|
217
|
-
* @throws {Error} If header not written
|
|
236
|
+
* @throws {Error} If header not written or already written
|
|
237
|
+
* @throws {FFmpegError} If write fails
|
|
218
238
|
*
|
|
219
239
|
* @example
|
|
220
240
|
* ```typescript
|
|
241
|
+
* // Finalize output
|
|
221
242
|
* await output.writeTrailer();
|
|
243
|
+
* await output.close();
|
|
222
244
|
* ```
|
|
245
|
+
*
|
|
246
|
+
* @see {@link writeHeader} Must be called first
|
|
247
|
+
* @see {@link close} For cleanup after trailer
|
|
223
248
|
*/
|
|
224
249
|
writeTrailer(): Promise<void>;
|
|
225
250
|
/**
|
|
226
|
-
*
|
|
251
|
+
* Close media output and free resources.
|
|
227
252
|
*
|
|
228
|
-
* Writes trailer if needed
|
|
253
|
+
* Writes trailer if needed and releases all resources.
|
|
229
254
|
* Safe to call multiple times.
|
|
230
|
-
*
|
|
231
|
-
* Uses av_write_trailer(), avio_closep(), and avformat_free_context() internally.
|
|
255
|
+
* Automatically called by Symbol.asyncDispose.
|
|
232
256
|
*
|
|
233
257
|
* @example
|
|
234
258
|
* ```typescript
|
|
235
|
-
* await output.
|
|
259
|
+
* const output = await MediaOutput.open('output.mp4');
|
|
260
|
+
* try {
|
|
261
|
+
* // Use output
|
|
262
|
+
* } finally {
|
|
263
|
+
* await output.close();
|
|
264
|
+
* }
|
|
236
265
|
* ```
|
|
266
|
+
*
|
|
267
|
+
* @see {@link Symbol.asyncDispose} For automatic cleanup
|
|
237
268
|
*/
|
|
238
269
|
close(): Promise<void>;
|
|
239
270
|
/**
|
|
240
|
-
*
|
|
271
|
+
* Get stream information.
|
|
272
|
+
*
|
|
273
|
+
* Returns internal stream info for the specified index.
|
|
274
|
+
*
|
|
275
|
+
* @param streamIndex - Stream index
|
|
276
|
+
* @returns Stream info or undefined
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```typescript
|
|
280
|
+
* const info = output.getStreamInfo(0);
|
|
281
|
+
* console.log(`Stream 0 timebase: ${info?.timeBase.num}/${info?.timeBase.den}`);
|
|
282
|
+
* ```
|
|
241
283
|
*/
|
|
242
|
-
getStreamInfo(streamIndex: number):
|
|
284
|
+
getStreamInfo(streamIndex: number): StreamDescription | undefined;
|
|
243
285
|
/**
|
|
244
|
-
*
|
|
286
|
+
* Get all stream indices.
|
|
287
|
+
*
|
|
288
|
+
* Returns array of all added stream indices.
|
|
289
|
+
*
|
|
290
|
+
* @returns Array of stream indices
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```typescript
|
|
294
|
+
* const indices = output.getStreamIndices();
|
|
295
|
+
* console.log(`Output has ${indices.length} streams`);
|
|
296
|
+
* ```
|
|
245
297
|
*/
|
|
246
298
|
getStreamIndices(): number[];
|
|
247
299
|
/**
|
|
248
|
-
*
|
|
300
|
+
* Check if header has been written.
|
|
301
|
+
*
|
|
302
|
+
* @returns true if header written
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
* ```typescript
|
|
306
|
+
* if (!output.isHeaderWritten()) {
|
|
307
|
+
* await output.writeHeader();
|
|
308
|
+
* }
|
|
309
|
+
* ```
|
|
249
310
|
*/
|
|
250
311
|
isHeaderWritten(): boolean;
|
|
251
312
|
/**
|
|
252
|
-
*
|
|
313
|
+
* Check if trailer has been written.
|
|
314
|
+
*
|
|
315
|
+
* @returns true if trailer written
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* ```typescript
|
|
319
|
+
* if (!output.isTrailerWritten()) {
|
|
320
|
+
* await output.writeTrailer();
|
|
321
|
+
* }
|
|
322
|
+
* ```
|
|
253
323
|
*/
|
|
254
324
|
isTrailerWritten(): boolean;
|
|
255
325
|
/**
|
|
256
|
-
*
|
|
326
|
+
* Get underlying format context.
|
|
257
327
|
*
|
|
258
|
-
*
|
|
328
|
+
* Returns the internal format context for advanced operations.
|
|
329
|
+
*
|
|
330
|
+
* @returns Format context
|
|
331
|
+
*
|
|
332
|
+
* @internal
|
|
259
333
|
*/
|
|
260
334
|
getFormatContext(): FormatContext;
|
|
261
335
|
/**
|
|
262
|
-
*
|
|
336
|
+
* Dispose of media output.
|
|
263
337
|
*
|
|
264
|
-
*
|
|
338
|
+
* Implements AsyncDisposable interface for automatic cleanup.
|
|
339
|
+
* Equivalent to calling close().
|
|
265
340
|
*
|
|
266
341
|
* @example
|
|
267
342
|
* ```typescript
|
|
268
|
-
*
|
|
269
|
-
*
|
|
343
|
+
* {
|
|
344
|
+
* await using output = await MediaOutput.open('output.mp4');
|
|
345
|
+
* // Use output...
|
|
346
|
+
* } // Automatically closed
|
|
270
347
|
* ```
|
|
348
|
+
*
|
|
349
|
+
* @see {@link close} For manual cleanup
|
|
271
350
|
*/
|
|
272
351
|
[Symbol.asyncDispose](): Promise<void>;
|
|
273
352
|
}
|
|
274
|
-
export {};
|