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.
Files changed (175) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE.md +22 -0
  3. package/README.md +377 -0
  4. package/binding.gyp +78 -0
  5. package/dist/api/bitstream-filter.d.ts +246 -0
  6. package/dist/api/bitstream-filter.js +369 -0
  7. package/dist/api/bitstream-filter.js.map +1 -0
  8. package/dist/api/decoder.d.ts +257 -0
  9. package/dist/api/decoder.js +424 -0
  10. package/dist/api/decoder.js.map +1 -0
  11. package/dist/api/encoder.d.ts +298 -0
  12. package/dist/api/encoder.js +574 -0
  13. package/dist/api/encoder.js.map +1 -0
  14. package/dist/api/filter.d.ts +457 -0
  15. package/dist/api/filter.js +876 -0
  16. package/dist/api/filter.js.map +1 -0
  17. package/dist/api/hardware.d.ts +318 -0
  18. package/dist/api/hardware.js +558 -0
  19. package/dist/api/hardware.js.map +1 -0
  20. package/dist/api/index.d.ts +12 -0
  21. package/dist/api/index.js +20 -0
  22. package/dist/api/index.js.map +1 -0
  23. package/dist/api/io-stream.d.ts +109 -0
  24. package/dist/api/io-stream.js +124 -0
  25. package/dist/api/io-stream.js.map +1 -0
  26. package/dist/api/media-input.d.ts +295 -0
  27. package/dist/api/media-input.js +456 -0
  28. package/dist/api/media-input.js.map +1 -0
  29. package/dist/api/media-output.d.ts +274 -0
  30. package/dist/api/media-output.js +486 -0
  31. package/dist/api/media-output.js.map +1 -0
  32. package/dist/api/pipeline.d.ts +117 -0
  33. package/dist/api/pipeline.js +836 -0
  34. package/dist/api/pipeline.js.map +1 -0
  35. package/dist/api/types.d.ts +440 -0
  36. package/dist/api/types.js +2 -0
  37. package/dist/api/types.js.map +1 -0
  38. package/dist/api/utilities/audio-sample.d.ts +115 -0
  39. package/dist/api/utilities/audio-sample.js +110 -0
  40. package/dist/api/utilities/audio-sample.js.map +1 -0
  41. package/dist/api/utilities/channel-layout.d.ts +83 -0
  42. package/dist/api/utilities/channel-layout.js +87 -0
  43. package/dist/api/utilities/channel-layout.js.map +1 -0
  44. package/dist/api/utilities/image.d.ts +177 -0
  45. package/dist/api/utilities/image.js +183 -0
  46. package/dist/api/utilities/image.js.map +1 -0
  47. package/dist/api/utilities/index.d.ts +8 -0
  48. package/dist/api/utilities/index.js +17 -0
  49. package/dist/api/utilities/index.js.map +1 -0
  50. package/dist/api/utilities/media-type.d.ts +56 -0
  51. package/dist/api/utilities/media-type.js +60 -0
  52. package/dist/api/utilities/media-type.js.map +1 -0
  53. package/dist/api/utilities/pixel-format.d.ts +94 -0
  54. package/dist/api/utilities/pixel-format.js +102 -0
  55. package/dist/api/utilities/pixel-format.js.map +1 -0
  56. package/dist/api/utilities/sample-format.d.ts +132 -0
  57. package/dist/api/utilities/sample-format.js +144 -0
  58. package/dist/api/utilities/sample-format.js.map +1 -0
  59. package/dist/api/utilities/streaming.d.ts +104 -0
  60. package/dist/api/utilities/streaming.js +137 -0
  61. package/dist/api/utilities/streaming.js.map +1 -0
  62. package/dist/api/utilities/timestamp.d.ts +187 -0
  63. package/dist/api/utilities/timestamp.js +200 -0
  64. package/dist/api/utilities/timestamp.js.map +1 -0
  65. package/dist/api/utils.d.ts +61 -0
  66. package/dist/api/utils.js +330 -0
  67. package/dist/api/utils.js.map +1 -0
  68. package/dist/index.d.ts +2 -0
  69. package/dist/index.js +5 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/lib/audio-fifo.d.ts +339 -0
  72. package/dist/lib/audio-fifo.js +365 -0
  73. package/dist/lib/audio-fifo.js.map +1 -0
  74. package/dist/lib/binding.d.ts +192 -0
  75. package/dist/lib/binding.js +70 -0
  76. package/dist/lib/binding.js.map +1 -0
  77. package/dist/lib/bitstream-filter-context.d.ts +345 -0
  78. package/dist/lib/bitstream-filter-context.js +407 -0
  79. package/dist/lib/bitstream-filter-context.js.map +1 -0
  80. package/dist/lib/bitstream-filter.d.ts +124 -0
  81. package/dist/lib/bitstream-filter.js +138 -0
  82. package/dist/lib/bitstream-filter.js.map +1 -0
  83. package/dist/lib/channel-layouts.d.ts +51 -0
  84. package/dist/lib/channel-layouts.js +55 -0
  85. package/dist/lib/channel-layouts.js.map +1 -0
  86. package/dist/lib/codec-context.d.ts +763 -0
  87. package/dist/lib/codec-context.js +974 -0
  88. package/dist/lib/codec-context.js.map +1 -0
  89. package/dist/lib/codec-parameters.d.ts +362 -0
  90. package/dist/lib/codec-parameters.js +460 -0
  91. package/dist/lib/codec-parameters.js.map +1 -0
  92. package/dist/lib/codec-parser.d.ts +185 -0
  93. package/dist/lib/codec-parser.js +193 -0
  94. package/dist/lib/codec-parser.js.map +1 -0
  95. package/dist/lib/codec.d.ts +432 -0
  96. package/dist/lib/codec.js +492 -0
  97. package/dist/lib/codec.js.map +1 -0
  98. package/dist/lib/constants.d.ts +2037 -0
  99. package/dist/lib/constants.js +1659 -0
  100. package/dist/lib/constants.js.map +1 -0
  101. package/dist/lib/dictionary.d.ts +371 -0
  102. package/dist/lib/dictionary.js +406 -0
  103. package/dist/lib/dictionary.js.map +1 -0
  104. package/dist/lib/error.d.ts +216 -0
  105. package/dist/lib/error.js +254 -0
  106. package/dist/lib/error.js.map +1 -0
  107. package/dist/lib/filter-context.d.ts +445 -0
  108. package/dist/lib/filter-context.js +505 -0
  109. package/dist/lib/filter-context.js.map +1 -0
  110. package/dist/lib/filter-graph.d.ts +556 -0
  111. package/dist/lib/filter-graph.js +608 -0
  112. package/dist/lib/filter-graph.js.map +1 -0
  113. package/dist/lib/filter-inout.d.ts +205 -0
  114. package/dist/lib/filter-inout.js +264 -0
  115. package/dist/lib/filter-inout.js.map +1 -0
  116. package/dist/lib/filter.d.ts +231 -0
  117. package/dist/lib/filter.js +260 -0
  118. package/dist/lib/filter.js.map +1 -0
  119. package/dist/lib/format-context.d.ts +798 -0
  120. package/dist/lib/format-context.js +845 -0
  121. package/dist/lib/format-context.js.map +1 -0
  122. package/dist/lib/frame.d.ts +784 -0
  123. package/dist/lib/frame.js +933 -0
  124. package/dist/lib/frame.js.map +1 -0
  125. package/dist/lib/hardware-device-context.d.ts +407 -0
  126. package/dist/lib/hardware-device-context.js +429 -0
  127. package/dist/lib/hardware-device-context.js.map +1 -0
  128. package/dist/lib/hardware-frames-context.d.ts +374 -0
  129. package/dist/lib/hardware-frames-context.js +430 -0
  130. package/dist/lib/hardware-frames-context.js.map +1 -0
  131. package/dist/lib/index.d.ts +31 -0
  132. package/dist/lib/index.js +54 -0
  133. package/dist/lib/index.js.map +1 -0
  134. package/dist/lib/input-format.d.ts +216 -0
  135. package/dist/lib/input-format.js +246 -0
  136. package/dist/lib/input-format.js.map +1 -0
  137. package/dist/lib/io-context.d.ts +495 -0
  138. package/dist/lib/io-context.js +550 -0
  139. package/dist/lib/io-context.js.map +1 -0
  140. package/dist/lib/log.d.ts +201 -0
  141. package/dist/lib/log.js +219 -0
  142. package/dist/lib/log.js.map +1 -0
  143. package/dist/lib/native-types.d.ts +719 -0
  144. package/dist/lib/native-types.js +2 -0
  145. package/dist/lib/native-types.js.map +1 -0
  146. package/dist/lib/option.d.ts +589 -0
  147. package/dist/lib/option.js +853 -0
  148. package/dist/lib/option.js.map +1 -0
  149. package/dist/lib/output-format.d.ts +179 -0
  150. package/dist/lib/output-format.js +205 -0
  151. package/dist/lib/output-format.js.map +1 -0
  152. package/dist/lib/packet.d.ts +487 -0
  153. package/dist/lib/packet.js +558 -0
  154. package/dist/lib/packet.js.map +1 -0
  155. package/dist/lib/rational.d.ts +210 -0
  156. package/dist/lib/rational.js +233 -0
  157. package/dist/lib/rational.js.map +1 -0
  158. package/dist/lib/software-resample-context.d.ts +572 -0
  159. package/dist/lib/software-resample-context.js +610 -0
  160. package/dist/lib/software-resample-context.js.map +1 -0
  161. package/dist/lib/software-scale-context.d.ts +290 -0
  162. package/dist/lib/software-scale-context.js +308 -0
  163. package/dist/lib/software-scale-context.js.map +1 -0
  164. package/dist/lib/stream.d.ts +322 -0
  165. package/dist/lib/stream.js +408 -0
  166. package/dist/lib/stream.js.map +1 -0
  167. package/dist/lib/types.d.ts +59 -0
  168. package/dist/lib/types.js +8 -0
  169. package/dist/lib/types.js.map +1 -0
  170. package/dist/lib/utilities.d.ts +346 -0
  171. package/dist/lib/utilities.js +424 -0
  172. package/dist/lib/utilities.js.map +1 -0
  173. package/install/check.js +113 -0
  174. package/install/ffmpeg.js +163 -0
  175. package/package.json +107 -0
@@ -0,0 +1,322 @@
1
+ import { CodecParameters } from './codec-parameters.js';
2
+ import { Dictionary } from './dictionary.js';
3
+ import { Rational } from './rational.js';
4
+ import type { AVDiscard, AVDisposition, AVStreamEventFlag } from './constants.js';
5
+ import type { NativeStream, NativeWrapper } from './native-types.js';
6
+ import type { Packet } from './packet.js';
7
+ /**
8
+ * Stream information within a media container.
9
+ *
10
+ * Represents a single stream (video, audio, subtitle, etc.) within a media file.
11
+ * Streams are created and managed by FormatContext and contain all the metadata
12
+ * and parameters needed to decode or encode the stream. Each stream has its own
13
+ * timebase, codec parameters, and metadata.
14
+ *
15
+ * Direct mapping to FFmpeg's AVStream.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import { FormatContext, FFmpegError } from 'node-av';
20
+ * import { AVMEDIA_TYPE_VIDEO, AVMEDIA_TYPE_AUDIO } from 'node-av/constants';
21
+ *
22
+ * // Streams are obtained from FormatContext
23
+ * const formatContext = new FormatContext();
24
+ * const ret = await formatContext.openInput('video.mp4', null, null);
25
+ * FFmpegError.throwIfError(ret, 'openInput');
26
+ *
27
+ * const infoRet = await formatContext.findStreamInfo(null);
28
+ * FFmpegError.throwIfError(infoRet, 'findStreamInfo');
29
+ *
30
+ * // Access streams
31
+ * const streams = formatContext.streams;
32
+ * for (const stream of streams) {
33
+ * console.log(`Stream ${stream.index}: ${stream.codecpar.codecType}`);
34
+ * console.log(`Time base: ${stream.timeBase.num}/${stream.timeBase.den}`);
35
+ *
36
+ * // Direct access to codec parameters
37
+ * const codecpar = stream.codecpar;
38
+ * if (codecpar.codecType === AVMEDIA_TYPE_VIDEO) {
39
+ * console.log(`Video: ${codecpar.width}x${codecpar.height}`);
40
+ * } else if (codecpar.codecType === AVMEDIA_TYPE_AUDIO) {
41
+ * console.log(`Audio: ${codecpar.sampleRate}Hz ${codecpar.channels} channels`);
42
+ * }
43
+ * }
44
+ * ```
45
+ *
46
+ * @see {@link FormatContext} For creating and managing streams
47
+ * @see {@link CodecParameters} For codec-specific stream parameters
48
+ */
49
+ export declare class Stream implements NativeWrapper<NativeStream> {
50
+ private native;
51
+ private _codecpar?;
52
+ /**
53
+ * Constructor is internal - use FormatContext to create streams.
54
+ *
55
+ * Streams are created and managed by FormatContext.
56
+ * For demuxing, streams are created automatically when opening input.
57
+ * For muxing, use formatContext.newStream() to create streams.
58
+ *
59
+ * @internal
60
+ *
61
+ * @param native - Native AVStream to wrap
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * // Don't create streams directly
66
+ * // const stream = new Stream(); // Wrong
67
+ *
68
+ * // For demuxing: streams are created automatically
69
+ * const streams = formatContext.streams; // Correct
70
+ *
71
+ * // For muxing: use newStream
72
+ * const stream = formatContext.newStream(null); // Correct
73
+ * ```
74
+ */
75
+ constructor(native: NativeStream);
76
+ /**
77
+ * Stream index in the format context.
78
+ *
79
+ * Zero-based index of this stream in the format context's stream array.
80
+ * This is the index used to identify the stream in packets.
81
+ *
82
+ * Direct mapping to AVStream->index
83
+ *
84
+ * @readonly
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * // Find video stream index
89
+ * const videoStreamIndex = streams.findIndex(
90
+ * s => s.codecpar.codecType === AVMEDIA_TYPE_VIDEO
91
+ * );
92
+ *
93
+ * // Check packet's stream
94
+ * if (packet.streamIndex === videoStreamIndex) {
95
+ * // This packet belongs to the video stream
96
+ * }
97
+ * ```
98
+ */
99
+ get index(): number;
100
+ /**
101
+ * Format-specific stream ID.
102
+ *
103
+ * Stream ID as defined by the container format.
104
+ * Different from index - this is format-specific.
105
+ *
106
+ * Direct mapping to AVStream->id
107
+ *
108
+ * - decoding: Set by libavformat
109
+ * - encoding: Set by the user, replaced by libavformat if left unset
110
+ */
111
+ get id(): number;
112
+ set id(value: number);
113
+ /**
114
+ * Codec parameters associated with this stream.
115
+ *
116
+ * Contains all the parameters needed to set up a codec for this stream,
117
+ * including codec ID, dimensions for video, sample rate for audio, etc.
118
+ *
119
+ * Direct mapping to AVStream->codecpar
120
+ *
121
+ * - demuxing: Filled by libavformat on stream creation or in findStreamInfo()
122
+ * - muxing: Must be filled by the caller before writeHeader()
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * // For video stream
127
+ * stream.codecpar.codecType = AVMEDIA_TYPE_VIDEO;
128
+ * stream.codecpar.codecId = AV_CODEC_ID_H264;
129
+ * stream.codecpar.width = 1920;
130
+ * stream.codecpar.height = 1080;
131
+ *
132
+ * // For audio stream
133
+ * stream.codecpar.codecType = AVMEDIA_TYPE_AUDIO;
134
+ * stream.codecpar.codecId = AV_CODEC_ID_AAC;
135
+ * stream.codecpar.sampleRate = 48000;
136
+ * stream.codecpar.channels = 2;
137
+ * ```
138
+ *
139
+ * @see {@link CodecParameters} For detailed parameter documentation
140
+ */
141
+ get codecpar(): CodecParameters;
142
+ set codecpar(value: CodecParameters);
143
+ /**
144
+ * Time base for this stream.
145
+ *
146
+ * The fundamental unit of time (in seconds) in terms of which frame
147
+ * timestamps are represented. For example, a time base of 1/25 means
148
+ * each time unit is 1/25 of a second (40ms).
149
+ *
150
+ * Direct mapping to AVStream->time_base
151
+ *
152
+ * - decoding: Set by libavformat
153
+ * - encoding: May be set before writeHeader() as a hint to the muxer.
154
+ * The muxer will overwrite with the actual timebase used.
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * import { Rational } from 'node-av';
159
+ *
160
+ * // Common time bases
161
+ * stream.timeBase = new Rational(1, 90000); // 90kHz (MPEG-TS)
162
+ * stream.timeBase = new Rational(1, 1000); // milliseconds
163
+ * stream.timeBase = new Rational(1, 25); // 25 fps video
164
+ *
165
+ * // Convert PTS to seconds
166
+ * const pts = 45000n;
167
+ * const seconds = Number(pts) * stream.timeBase.toDouble();
168
+ * ```
169
+ *
170
+ * @see {@link Rational} For time base representation
171
+ */
172
+ get timeBase(): Rational;
173
+ set timeBase(value: Rational);
174
+ /**
175
+ * Decoding: pts of the first frame of the stream in presentation order, in stream time base.
176
+ *
177
+ * Direct mapping to AVStream->start_time
178
+ *
179
+ * Only set this if you are absolutely 100% sure that the value you set
180
+ * it to really is the pts of the first frame.
181
+ * This may be undefined (AV_NOPTS_VALUE).
182
+ *
183
+ * @note The ASF header does NOT contain a correct start_time the ASF
184
+ * demuxer must NOT set this.
185
+ */
186
+ get startTime(): bigint;
187
+ set startTime(value: bigint);
188
+ /**
189
+ * Decoding: duration of the stream, in stream time base.
190
+ *
191
+ * Direct mapping to AVStream->duration
192
+ *
193
+ * If a source file does not specify a duration, but does specify
194
+ * a bitrate, this value will be estimated from bitrate and file size.
195
+ *
196
+ * Encoding: May be set by the caller before avformat_write_header() to
197
+ * provide a hint to the muxer about the estimated duration.
198
+ */
199
+ get duration(): bigint;
200
+ set duration(value: bigint);
201
+ /**
202
+ * Number of frames in this stream if known or 0.
203
+ *
204
+ * Direct mapping to AVStream->nb_frames
205
+ */
206
+ get nbFrames(): bigint;
207
+ set nbFrames(value: bigint);
208
+ /**
209
+ * Stream disposition - a combination of AV_DISPOSITION_* flags.
210
+ *
211
+ * Direct mapping to AVStream->disposition
212
+ *
213
+ * - demuxing: set by libavformat when creating the stream or in
214
+ * avformat_find_stream_info().
215
+ * - muxing: may be set by the caller before avformat_write_header().
216
+ *
217
+ * Common flags:
218
+ * - AV_DISPOSITION_DEFAULT: default track
219
+ * - AV_DISPOSITION_ATTACHED_PIC: stream is an attached picture (album art)
220
+ * - AV_DISPOSITION_CAPTIONS: stream contains captions
221
+ * - AV_DISPOSITION_DESCRIPTIONS: stream contains descriptions
222
+ * - AV_DISPOSITION_METADATA: stream contains metadata
223
+ */
224
+ get disposition(): AVDisposition;
225
+ set disposition(value: AVDisposition);
226
+ /**
227
+ * Selects which packets can be discarded at will and do not need to be demuxed.
228
+ *
229
+ * Direct mapping to AVStream->discard
230
+ *
231
+ * - AVDISCARD_NONE: discard nothing
232
+ * - AVDISCARD_DEFAULT: discard useless packets like 0 size packets in avi
233
+ * - AVDISCARD_NONREF: discard all non reference
234
+ * - AVDISCARD_BIDIR: discard all bidirectional frames
235
+ * - AVDISCARD_NONINTRA: discard all non intra frames
236
+ * - AVDISCARD_NONKEY: discard all frames except keyframes
237
+ * - AVDISCARD_ALL: discard all
238
+ */
239
+ get discard(): AVDiscard;
240
+ set discard(value: AVDiscard);
241
+ /**
242
+ * Sample aspect ratio (0 if unknown).
243
+ *
244
+ * Direct mapping to AVStream->sample_aspect_ratio
245
+ *
246
+ * This is the width of a pixel divided by the height of the pixel.
247
+ * - encoding: Set by user.
248
+ * - decoding: Set by libavformat.
249
+ */
250
+ get sampleAspectRatio(): Rational;
251
+ set sampleAspectRatio(value: Rational);
252
+ /**
253
+ * Average framerate.
254
+ *
255
+ * Direct mapping to AVStream->avg_frame_rate
256
+ *
257
+ * - demuxing: May be set by libavformat when creating the stream or in
258
+ * avformat_find_stream_info().
259
+ * - muxing: May be set by the caller before avformat_write_header().
260
+ */
261
+ get avgFrameRate(): Rational;
262
+ set avgFrameRate(value: Rational);
263
+ /**
264
+ * Real base framerate of the stream.
265
+ *
266
+ * Direct mapping to AVStream->r_frame_rate
267
+ *
268
+ * This is the lowest framerate with which all timestamps can be
269
+ * represented accurately (it is the least common multiple of all
270
+ * framerates in the stream). Note, this value is just a guess!
271
+ * For example, if the time base is 1/90000 and all frames have either
272
+ * approximately 3600 or 1800 timer ticks, then r_frame_rate will be 50/1.
273
+ */
274
+ get rFrameRate(): Rational;
275
+ set rFrameRate(value: Rational);
276
+ /**
277
+ * Metadata dictionary for this stream.
278
+ *
279
+ * Direct mapping to AVStream->metadata
280
+ *
281
+ * Contains key-value pairs of metadata.
282
+ */
283
+ get metadata(): Dictionary | null;
284
+ set metadata(value: Dictionary | null);
285
+ /**
286
+ * For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet
287
+ * will contain the attached picture (e.g., album art).
288
+ *
289
+ * Direct mapping to AVStream->attached_pic
290
+ *
291
+ * - decoding: set by libavformat, must not be modified by the caller.
292
+ * - encoding: unused
293
+ * @readonly
294
+ */
295
+ get attachedPic(): Packet | null;
296
+ /**
297
+ * Flags indicating events happening on the stream, a combination of
298
+ * AVSTREAM_EVENT_FLAG_*.
299
+ *
300
+ * Direct mapping to AVStream->event_flags
301
+ *
302
+ * - demuxing: may be set by the demuxer in avformat_open_input(),
303
+ * avformat_find_stream_info() and av_read_frame(). Flags must be cleared
304
+ * by the user once the event has been handled.
305
+ * - muxing: may be set by the user after avformat_write_header() to
306
+ * indicate a user-triggered event. The muxer will clear the flags for
307
+ * events it has handled in av_[interleaved]_write_frame().
308
+ *
309
+ * Flags:
310
+ * - AVSTREAM_EVENT_FLAG_METADATA_UPDATED: metadata was updated
311
+ * - AVSTREAM_EVENT_FLAG_NEW_PACKETS: new packets were read for this stream
312
+ */
313
+ get eventFlags(): AVStreamEventFlag;
314
+ set eventFlags(value: AVStreamEventFlag);
315
+ /**
316
+ * Get the native FFmpeg AVStream pointer.
317
+ *
318
+ * @internal For use by other wrapper classes
319
+ * @returns The underlying native stream object
320
+ */
321
+ getNative(): NativeStream;
322
+ }