node-av 1.0.3 → 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.
Files changed (162) hide show
  1. package/README.md +56 -41
  2. package/dist/api/bitstream-filter.d.ts +180 -123
  3. package/dist/api/bitstream-filter.js +182 -126
  4. package/dist/api/bitstream-filter.js.map +1 -1
  5. package/dist/api/decoder.d.ts +286 -130
  6. package/dist/api/decoder.js +321 -159
  7. package/dist/api/decoder.js.map +1 -1
  8. package/dist/api/encoder.d.ts +254 -158
  9. package/dist/api/encoder.js +326 -298
  10. package/dist/api/encoder.js.map +1 -1
  11. package/dist/api/filter-presets.d.ts +912 -0
  12. package/dist/api/filter-presets.js +1407 -0
  13. package/dist/api/filter-presets.js.map +1 -0
  14. package/dist/api/filter.d.ts +280 -284
  15. package/dist/api/filter.js +435 -509
  16. package/dist/api/filter.js.map +1 -1
  17. package/dist/api/hardware.d.ts +226 -159
  18. package/dist/api/hardware.js +405 -287
  19. package/dist/api/hardware.js.map +1 -1
  20. package/dist/api/index.d.ts +3 -2
  21. package/dist/api/index.js +1 -0
  22. package/dist/api/index.js.map +1 -1
  23. package/dist/api/io-stream.d.ts +65 -61
  24. package/dist/api/io-stream.js +45 -47
  25. package/dist/api/io-stream.js.map +1 -1
  26. package/dist/api/media-input.d.ts +244 -141
  27. package/dist/api/media-input.js +207 -104
  28. package/dist/api/media-input.js.map +1 -1
  29. package/dist/api/media-output.d.ts +206 -128
  30. package/dist/api/media-output.js +212 -129
  31. package/dist/api/media-output.js.map +1 -1
  32. package/dist/api/pipeline.d.ts +168 -38
  33. package/dist/api/pipeline.js +238 -14
  34. package/dist/api/pipeline.js.map +1 -1
  35. package/dist/api/types.d.ts +22 -182
  36. package/dist/api/utilities/audio-sample.d.ts +1 -1
  37. package/dist/api/utilities/image.d.ts +1 -1
  38. package/dist/api/utilities/media-type.d.ts +1 -1
  39. package/dist/api/utilities/pixel-format.d.ts +1 -1
  40. package/dist/api/utilities/sample-format.d.ts +1 -1
  41. package/dist/api/utilities/timestamp.d.ts +1 -1
  42. package/dist/api/utils.d.ts +1 -2
  43. package/dist/api/utils.js +9 -0
  44. package/dist/api/utils.js.map +1 -1
  45. package/dist/{lib → constants}/channel-layouts.d.ts +1 -1
  46. package/dist/constants/channel-layouts.js.map +1 -0
  47. package/dist/{lib → constants}/constants.d.ts +19 -4
  48. package/dist/{lib → constants}/constants.js +15 -1
  49. package/dist/constants/constants.js.map +1 -0
  50. package/dist/constants/decoders.d.ts +609 -0
  51. package/dist/constants/decoders.js +617 -0
  52. package/dist/constants/decoders.js.map +1 -0
  53. package/dist/constants/encoders.d.ts +285 -0
  54. package/dist/constants/encoders.js +298 -0
  55. package/dist/constants/encoders.js.map +1 -0
  56. package/dist/constants/index.d.ts +4 -0
  57. package/dist/constants/index.js +5 -0
  58. package/dist/constants/index.js.map +1 -0
  59. package/dist/index.d.ts +1 -0
  60. package/dist/index.js +2 -0
  61. package/dist/index.js.map +1 -1
  62. package/dist/lib/audio-fifo.d.ts +128 -171
  63. package/dist/lib/audio-fifo.js +130 -173
  64. package/dist/lib/audio-fifo.js.map +1 -1
  65. package/dist/lib/binding.d.ts +7 -5
  66. package/dist/lib/binding.js +5 -0
  67. package/dist/lib/binding.js.map +1 -1
  68. package/dist/lib/bitstream-filter-context.d.ts +139 -184
  69. package/dist/lib/bitstream-filter-context.js +139 -188
  70. package/dist/lib/bitstream-filter-context.js.map +1 -1
  71. package/dist/lib/bitstream-filter.d.ts +69 -55
  72. package/dist/lib/bitstream-filter.js +68 -54
  73. package/dist/lib/bitstream-filter.js.map +1 -1
  74. package/dist/lib/codec-context.d.ts +317 -381
  75. package/dist/lib/codec-context.js +316 -381
  76. package/dist/lib/codec-context.js.map +1 -1
  77. package/dist/lib/codec-parameters.d.ts +161 -171
  78. package/dist/lib/codec-parameters.js +162 -172
  79. package/dist/lib/codec-parameters.js.map +1 -1
  80. package/dist/lib/codec-parser.d.ts +92 -105
  81. package/dist/lib/codec-parser.js +92 -103
  82. package/dist/lib/codec-parser.js.map +1 -1
  83. package/dist/lib/codec.d.ts +328 -217
  84. package/dist/lib/codec.js +392 -218
  85. package/dist/lib/codec.js.map +1 -1
  86. package/dist/lib/dictionary.d.ts +150 -204
  87. package/dist/lib/dictionary.js +159 -213
  88. package/dist/lib/dictionary.js.map +1 -1
  89. package/dist/lib/error.d.ts +97 -131
  90. package/dist/lib/error.js +98 -128
  91. package/dist/lib/error.js.map +1 -1
  92. package/dist/lib/filter-context.d.ts +317 -194
  93. package/dist/lib/filter-context.js +335 -200
  94. package/dist/lib/filter-context.js.map +1 -1
  95. package/dist/lib/filter-graph.d.ts +252 -293
  96. package/dist/lib/filter-graph.js +253 -294
  97. package/dist/lib/filter-graph.js.map +1 -1
  98. package/dist/lib/filter-inout.d.ts +87 -95
  99. package/dist/lib/filter-inout.js +87 -95
  100. package/dist/lib/filter-inout.js.map +1 -1
  101. package/dist/lib/filter.d.ts +93 -111
  102. package/dist/lib/filter.js +94 -112
  103. package/dist/lib/filter.js.map +1 -1
  104. package/dist/lib/format-context.d.ts +321 -429
  105. package/dist/lib/format-context.js +314 -386
  106. package/dist/lib/format-context.js.map +1 -1
  107. package/dist/lib/frame.d.ts +263 -406
  108. package/dist/lib/frame.js +263 -408
  109. package/dist/lib/frame.js.map +1 -1
  110. package/dist/lib/hardware-device-context.d.ts +150 -204
  111. package/dist/lib/hardware-device-context.js +149 -203
  112. package/dist/lib/hardware-device-context.js.map +1 -1
  113. package/dist/lib/hardware-frames-context.d.ts +171 -181
  114. package/dist/lib/hardware-frames-context.js +171 -181
  115. package/dist/lib/hardware-frames-context.js.map +1 -1
  116. package/dist/lib/index.d.ts +2 -3
  117. package/dist/lib/index.js +2 -5
  118. package/dist/lib/index.js.map +1 -1
  119. package/dist/lib/input-format.d.ts +90 -118
  120. package/dist/lib/input-format.js +89 -117
  121. package/dist/lib/input-format.js.map +1 -1
  122. package/dist/lib/io-context.d.ts +210 -242
  123. package/dist/lib/io-context.js +221 -253
  124. package/dist/lib/io-context.js.map +1 -1
  125. package/dist/lib/log.d.ts +86 -120
  126. package/dist/lib/log.js +85 -122
  127. package/dist/lib/log.js.map +1 -1
  128. package/dist/lib/native-types.d.ts +127 -112
  129. package/dist/lib/native-types.js +9 -0
  130. package/dist/lib/native-types.js.map +1 -1
  131. package/dist/lib/option.d.ts +285 -242
  132. package/dist/lib/option.js +310 -250
  133. package/dist/lib/option.js.map +1 -1
  134. package/dist/lib/output-format.d.ts +78 -102
  135. package/dist/lib/output-format.js +77 -101
  136. package/dist/lib/output-format.js.map +1 -1
  137. package/dist/lib/packet.d.ts +173 -241
  138. package/dist/lib/packet.js +172 -241
  139. package/dist/lib/packet.js.map +1 -1
  140. package/dist/lib/rational.d.ts +0 -2
  141. package/dist/lib/rational.js +0 -2
  142. package/dist/lib/rational.js.map +1 -1
  143. package/dist/lib/software-resample-context.d.ts +242 -326
  144. package/dist/lib/software-resample-context.js +242 -326
  145. package/dist/lib/software-resample-context.js.map +1 -1
  146. package/dist/lib/software-scale-context.d.ts +130 -174
  147. package/dist/lib/software-scale-context.js +132 -176
  148. package/dist/lib/software-scale-context.js.map +1 -1
  149. package/dist/lib/stream.d.ts +88 -198
  150. package/dist/lib/stream.js +87 -197
  151. package/dist/lib/stream.js.map +1 -1
  152. package/dist/lib/types.d.ts +1 -1
  153. package/dist/lib/utilities.d.ts +372 -181
  154. package/dist/lib/utilities.js +373 -182
  155. package/dist/lib/utilities.js.map +1 -1
  156. package/install/check.js +0 -1
  157. package/package.json +32 -24
  158. package/release_notes.md +43 -13
  159. package/CHANGELOG.md +0 -8
  160. package/dist/lib/channel-layouts.js.map +0 -1
  161. package/dist/lib/constants.js.map +0 -1
  162. /package/dist/{lib → constants}/channel-layouts.js +0 -0
@@ -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 StreamInfo {
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
- * MediaOutput - High-level media output handler.
12
+ * High-level media output for writing and muxing media files.
24
13
  *
25
- * Creates and manages media containers for writing encoded streams.
26
- * Automatically handles format setup and stream configuration.
27
- *
28
- * Manages the FormatContext and provides convenient methods for
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, Encoder } from 'node-av/api';
21
+ * import { MediaOutput } from 'node-av/api';
34
22
  *
35
- * // Open output file
36
- * const output = await MediaOutput.open('output.mp4');
23
+ * // Create output file
24
+ * await using output = await MediaOutput.open('output.mp4');
37
25
  *
38
- * // Add encoder stream
39
- * const encoder = await Encoder.create('libx264', {
40
- * width: 1920,
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, packets, trailer
30
+ * // Write header
47
31
  * await output.writeHeader();
48
- * await output.writePacket(packet, streamIdx);
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 without re-encoding
56
- * const input = await MediaInput.open('input.mp4');
57
- * const output = await MediaOutput.open('output.mkv');
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
- * if (packet.streamIndex === videoStream.index) {
65
- * await output.writePacket(packet, streamIdx);
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
- * Private constructor - use MediaOutput.open() instead.
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
- * Opens a media output for writing with custom IO callbacks or stream URL or file output
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
- * Uses avformat_alloc_output_context2() and avio_alloc_context() internally.
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
- * @param target - File path or stream URL or custom IO callbacks
97
- * @param options - Optional configuration
78
+ * Direct mapping to avformat_alloc_output_context2() and avio_open2().
98
79
  *
99
- * @returns Promise resolving to MediaOutput instance
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 not specified or context allocation fails
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
- * const callbacks = {
106
- * write: (buffer) => myStream.write(buffer),
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
- * const output = await MediaOutput.open('output.mp4');
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
- * const output = await MediaOutput.open('rtmp://server/live/streamkey', { format: 'flv' });
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
- * Adds a stream to the output container.
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
- * Uses avformat_new_stream() and avcodec_parameters_copy() internally.
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
- * @param source - Encoder for transcoding or Stream for copying
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 is written or output is closed
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 for direct copy - uses input stream's timebase
152
- * const inputStream = input.video();
153
- * const streamIdx = output.addStream(inputStream);
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
- * // Custom output timebase (e.g., for format requirements)
159
- * const streamIdx = output.addStream(encoder, {
160
- * timeBase: { num: 1, den: 90000 } // MPEG-TS standard
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
- * Writes a packet to the output container.
163
+ * Write a packet to the output.
170
164
  *
171
- * Writes an encoded packet to the specified stream.
172
- * Automatically sets the stream index on the packet.
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
- * Uses av_interleaved_write_frame() internally.
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
- * @throws {Error} If header not written, trailer already written, or invalid stream
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
- * const encoded = await encoder.encode(frame);
184
- * if (encoded) {
185
- * await output.writePacket(encoded, streamIdx);
186
- * encoded.free();
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
- * Writes the output file header.
193
- *
194
- * Writes the container header with stream information.
195
- * Must be called before writing any packets.
202
+ * Write file header.
196
203
  *
197
- * Uses avformat_write_header() internally.
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
- * @param options - Optional header options (format-specific)
208
+ * Direct mapping to avformat_write_header().
200
209
  *
201
- * @throws {Error} If header already written or output is closed
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
- * Writes the output file trailer.
228
+ * Write file trailer.
211
229
  *
212
- * Finalizes the output file with necessary metadata.
213
- * Should be called after all packets have been written.
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
- * Uses av_write_trailer() internally.
234
+ * Direct mapping to av_write_trailer().
216
235
  *
217
- * @throws {Error} If header not written, trailer already written, or output is closed
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
- * Closes the output and releases all resources.
251
+ * Close media output and free resources.
227
252
  *
228
- * Writes trailer if needed, closes IO context, and frees format context.
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.close();
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
- * Gets information about a specific stream.
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): StreamInfo | undefined;
284
+ getStreamInfo(streamIndex: number): StreamDescription | undefined;
243
285
  /**
244
- * Gets all stream indices.
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
- * Checks if header has been written.
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
- * Checks if trailer has been written.
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
- * Gets the underlying format context.
326
+ * Get underlying format context.
257
327
  *
258
- * For advanced use cases requiring direct format context access.
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
- * AsyncDisposable implementation for using statement.
336
+ * Dispose of media output.
263
337
  *
264
- * Enables automatic resource cleanup with await using syntax.
338
+ * Implements AsyncDisposable interface for automatic cleanup.
339
+ * Equivalent to calling close().
265
340
  *
266
341
  * @example
267
342
  * ```typescript
268
- * await using output = await MediaOutput.open('output.mp4');
269
- * // Output automatically closes when scope ends
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 {};