@revizly/node-av 5.2.2-beta.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/BUILD_LINUX.md +61 -0
- package/LICENSE.md +22 -0
- package/README.md +662 -0
- package/build_mac_local.sh +69 -0
- package/dist/api/audio-frame-buffer.d.ts +205 -0
- package/dist/api/audio-frame-buffer.js +287 -0
- package/dist/api/audio-frame-buffer.js.map +1 -0
- package/dist/api/bitstream-filter.d.ts +820 -0
- package/dist/api/bitstream-filter.js +1242 -0
- package/dist/api/bitstream-filter.js.map +1 -0
- package/dist/api/constants.d.ts +44 -0
- package/dist/api/constants.js +45 -0
- package/dist/api/constants.js.map +1 -0
- package/dist/api/data/test_av1.ivf +0 -0
- package/dist/api/data/test_h264.h264 +0 -0
- package/dist/api/data/test_hevc.h265 +0 -0
- package/dist/api/data/test_mjpeg.mjpeg +0 -0
- package/dist/api/data/test_vp8.ivf +0 -0
- package/dist/api/data/test_vp9.ivf +0 -0
- package/dist/api/decoder.d.ts +1088 -0
- package/dist/api/decoder.js +1775 -0
- package/dist/api/decoder.js.map +1 -0
- package/dist/api/demuxer.d.ts +1219 -0
- package/dist/api/demuxer.js +2081 -0
- package/dist/api/demuxer.js.map +1 -0
- package/dist/api/device.d.ts +586 -0
- package/dist/api/device.js +961 -0
- package/dist/api/device.js.map +1 -0
- package/dist/api/encoder.d.ts +1132 -0
- package/dist/api/encoder.js +1988 -0
- package/dist/api/encoder.js.map +1 -0
- package/dist/api/filter-complex.d.ts +821 -0
- package/dist/api/filter-complex.js +1604 -0
- package/dist/api/filter-complex.js.map +1 -0
- package/dist/api/filter-presets.d.ts +1286 -0
- package/dist/api/filter-presets.js +2152 -0
- package/dist/api/filter-presets.js.map +1 -0
- package/dist/api/filter.d.ts +1234 -0
- package/dist/api/filter.js +1976 -0
- package/dist/api/filter.js.map +1 -0
- package/dist/api/fmp4-stream.d.ts +426 -0
- package/dist/api/fmp4-stream.js +739 -0
- package/dist/api/fmp4-stream.js.map +1 -0
- package/dist/api/hardware.d.ts +651 -0
- package/dist/api/hardware.js +1260 -0
- package/dist/api/hardware.js.map +1 -0
- package/dist/api/index.d.ts +17 -0
- package/dist/api/index.js +32 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/io-stream.d.ts +307 -0
- package/dist/api/io-stream.js +282 -0
- package/dist/api/io-stream.js.map +1 -0
- package/dist/api/muxer.d.ts +957 -0
- package/dist/api/muxer.js +2002 -0
- package/dist/api/muxer.js.map +1 -0
- package/dist/api/pipeline.d.ts +607 -0
- package/dist/api/pipeline.js +1145 -0
- package/dist/api/pipeline.js.map +1 -0
- package/dist/api/utilities/async-queue.d.ts +120 -0
- package/dist/api/utilities/async-queue.js +211 -0
- package/dist/api/utilities/async-queue.js.map +1 -0
- package/dist/api/utilities/audio-sample.d.ts +117 -0
- package/dist/api/utilities/audio-sample.js +112 -0
- package/dist/api/utilities/audio-sample.js.map +1 -0
- package/dist/api/utilities/channel-layout.d.ts +76 -0
- package/dist/api/utilities/channel-layout.js +80 -0
- package/dist/api/utilities/channel-layout.js.map +1 -0
- package/dist/api/utilities/electron-shared-texture.d.ts +328 -0
- package/dist/api/utilities/electron-shared-texture.js +503 -0
- package/dist/api/utilities/electron-shared-texture.js.map +1 -0
- package/dist/api/utilities/image.d.ts +207 -0
- package/dist/api/utilities/image.js +213 -0
- package/dist/api/utilities/image.js.map +1 -0
- package/dist/api/utilities/index.d.ts +12 -0
- package/dist/api/utilities/index.js +25 -0
- package/dist/api/utilities/index.js.map +1 -0
- package/dist/api/utilities/media-type.d.ts +49 -0
- package/dist/api/utilities/media-type.js +53 -0
- package/dist/api/utilities/media-type.js.map +1 -0
- package/dist/api/utilities/pixel-format.d.ts +89 -0
- package/dist/api/utilities/pixel-format.js +97 -0
- package/dist/api/utilities/pixel-format.js.map +1 -0
- package/dist/api/utilities/sample-format.d.ts +129 -0
- package/dist/api/utilities/sample-format.js +141 -0
- package/dist/api/utilities/sample-format.js.map +1 -0
- package/dist/api/utilities/scheduler.d.ts +138 -0
- package/dist/api/utilities/scheduler.js +98 -0
- package/dist/api/utilities/scheduler.js.map +1 -0
- package/dist/api/utilities/streaming.d.ts +186 -0
- package/dist/api/utilities/streaming.js +309 -0
- package/dist/api/utilities/streaming.js.map +1 -0
- package/dist/api/utilities/timestamp.d.ts +193 -0
- package/dist/api/utilities/timestamp.js +206 -0
- package/dist/api/utilities/timestamp.js.map +1 -0
- package/dist/api/utilities/whisper-model.d.ts +310 -0
- package/dist/api/utilities/whisper-model.js +528 -0
- package/dist/api/utilities/whisper-model.js.map +1 -0
- package/dist/api/utils.d.ts +19 -0
- package/dist/api/utils.js +39 -0
- package/dist/api/utils.js.map +1 -0
- package/dist/api/whisper.d.ts +324 -0
- package/dist/api/whisper.js +362 -0
- package/dist/api/whisper.js.map +1 -0
- package/dist/constants/channel-layouts.d.ts +53 -0
- package/dist/constants/channel-layouts.js +57 -0
- package/dist/constants/channel-layouts.js.map +1 -0
- package/dist/constants/constants.d.ts +2325 -0
- package/dist/constants/constants.js +1887 -0
- package/dist/constants/constants.js.map +1 -0
- package/dist/constants/decoders.d.ts +633 -0
- package/dist/constants/decoders.js +641 -0
- package/dist/constants/decoders.js.map +1 -0
- package/dist/constants/encoders.d.ts +295 -0
- package/dist/constants/encoders.js +308 -0
- package/dist/constants/encoders.js.map +1 -0
- package/dist/constants/hardware.d.ts +26 -0
- package/dist/constants/hardware.js +27 -0
- package/dist/constants/hardware.js.map +1 -0
- package/dist/constants/index.d.ts +5 -0
- package/dist/constants/index.js +6 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/ffmpeg/index.d.ts +99 -0
- package/dist/ffmpeg/index.js +115 -0
- package/dist/ffmpeg/index.js.map +1 -0
- package/dist/ffmpeg/utils.d.ts +31 -0
- package/dist/ffmpeg/utils.js +68 -0
- package/dist/ffmpeg/utils.js.map +1 -0
- package/dist/ffmpeg/version.d.ts +6 -0
- package/dist/ffmpeg/version.js +7 -0
- package/dist/ffmpeg/version.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/audio-fifo.d.ts +399 -0
- package/dist/lib/audio-fifo.js +431 -0
- package/dist/lib/audio-fifo.js.map +1 -0
- package/dist/lib/binding.d.ts +228 -0
- package/dist/lib/binding.js +60 -0
- package/dist/lib/binding.js.map +1 -0
- package/dist/lib/bitstream-filter-context.d.ts +379 -0
- package/dist/lib/bitstream-filter-context.js +441 -0
- package/dist/lib/bitstream-filter-context.js.map +1 -0
- package/dist/lib/bitstream-filter.d.ts +140 -0
- package/dist/lib/bitstream-filter.js +154 -0
- package/dist/lib/bitstream-filter.js.map +1 -0
- package/dist/lib/codec-context.d.ts +1071 -0
- package/dist/lib/codec-context.js +1354 -0
- package/dist/lib/codec-context.js.map +1 -0
- package/dist/lib/codec-parameters.d.ts +616 -0
- package/dist/lib/codec-parameters.js +761 -0
- package/dist/lib/codec-parameters.js.map +1 -0
- package/dist/lib/codec-parser.d.ts +201 -0
- package/dist/lib/codec-parser.js +213 -0
- package/dist/lib/codec-parser.js.map +1 -0
- package/dist/lib/codec.d.ts +586 -0
- package/dist/lib/codec.js +713 -0
- package/dist/lib/codec.js.map +1 -0
- package/dist/lib/device.d.ts +291 -0
- package/dist/lib/device.js +324 -0
- package/dist/lib/device.js.map +1 -0
- package/dist/lib/dictionary.d.ts +333 -0
- package/dist/lib/dictionary.js +372 -0
- package/dist/lib/dictionary.js.map +1 -0
- package/dist/lib/error.d.ts +242 -0
- package/dist/lib/error.js +303 -0
- package/dist/lib/error.js.map +1 -0
- package/dist/lib/fifo.d.ts +416 -0
- package/dist/lib/fifo.js +453 -0
- package/dist/lib/fifo.js.map +1 -0
- package/dist/lib/filter-context.d.ts +712 -0
- package/dist/lib/filter-context.js +789 -0
- package/dist/lib/filter-context.js.map +1 -0
- package/dist/lib/filter-graph-segment.d.ts +160 -0
- package/dist/lib/filter-graph-segment.js +171 -0
- package/dist/lib/filter-graph-segment.js.map +1 -0
- package/dist/lib/filter-graph.d.ts +641 -0
- package/dist/lib/filter-graph.js +704 -0
- package/dist/lib/filter-graph.js.map +1 -0
- package/dist/lib/filter-inout.d.ts +198 -0
- package/dist/lib/filter-inout.js +257 -0
- package/dist/lib/filter-inout.js.map +1 -0
- package/dist/lib/filter.d.ts +243 -0
- package/dist/lib/filter.js +272 -0
- package/dist/lib/filter.js.map +1 -0
- package/dist/lib/format-context.d.ts +1254 -0
- package/dist/lib/format-context.js +1379 -0
- package/dist/lib/format-context.js.map +1 -0
- package/dist/lib/frame-utils.d.ts +116 -0
- package/dist/lib/frame-utils.js +98 -0
- package/dist/lib/frame-utils.js.map +1 -0
- package/dist/lib/frame.d.ts +1222 -0
- package/dist/lib/frame.js +1435 -0
- package/dist/lib/frame.js.map +1 -0
- package/dist/lib/hardware-device-context.d.ts +362 -0
- package/dist/lib/hardware-device-context.js +383 -0
- package/dist/lib/hardware-device-context.js.map +1 -0
- package/dist/lib/hardware-frames-context.d.ts +419 -0
- package/dist/lib/hardware-frames-context.js +477 -0
- package/dist/lib/hardware-frames-context.js.map +1 -0
- package/dist/lib/index.d.ts +35 -0
- package/dist/lib/index.js +60 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/input-format.d.ts +249 -0
- package/dist/lib/input-format.js +306 -0
- package/dist/lib/input-format.js.map +1 -0
- package/dist/lib/io-context.d.ts +696 -0
- package/dist/lib/io-context.js +769 -0
- package/dist/lib/io-context.js.map +1 -0
- package/dist/lib/log.d.ts +174 -0
- package/dist/lib/log.js +184 -0
- package/dist/lib/log.js.map +1 -0
- package/dist/lib/native-types.d.ts +946 -0
- package/dist/lib/native-types.js +2 -0
- package/dist/lib/native-types.js.map +1 -0
- package/dist/lib/option.d.ts +927 -0
- package/dist/lib/option.js +1583 -0
- package/dist/lib/option.js.map +1 -0
- package/dist/lib/output-format.d.ts +180 -0
- package/dist/lib/output-format.js +213 -0
- package/dist/lib/output-format.js.map +1 -0
- package/dist/lib/packet.d.ts +501 -0
- package/dist/lib/packet.js +590 -0
- package/dist/lib/packet.js.map +1 -0
- package/dist/lib/rational.d.ts +251 -0
- package/dist/lib/rational.js +278 -0
- package/dist/lib/rational.js.map +1 -0
- package/dist/lib/software-resample-context.d.ts +552 -0
- package/dist/lib/software-resample-context.js +592 -0
- package/dist/lib/software-resample-context.js.map +1 -0
- package/dist/lib/software-scale-context.d.ts +344 -0
- package/dist/lib/software-scale-context.js +366 -0
- package/dist/lib/software-scale-context.js.map +1 -0
- package/dist/lib/stream.d.ts +379 -0
- package/dist/lib/stream.js +526 -0
- package/dist/lib/stream.js.map +1 -0
- package/dist/lib/sync-queue.d.ts +179 -0
- package/dist/lib/sync-queue.js +197 -0
- package/dist/lib/sync-queue.js.map +1 -0
- package/dist/lib/types.d.ts +34 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utilities.d.ts +1127 -0
- package/dist/lib/utilities.js +1225 -0
- package/dist/lib/utilities.js.map +1 -0
- package/dist/utils/electron.d.ts +49 -0
- package/dist/utils/electron.js +63 -0
- package/dist/utils/electron.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/install/check.js +121 -0
- package/install/ffmpeg.js +66 -0
- package/jellyfin-ffmpeg.patch +181 -0
- package/package.json +129 -0
|
@@ -0,0 +1,1254 @@
|
|
|
1
|
+
import { Codec } from './codec.js';
|
|
2
|
+
import { Dictionary } from './dictionary.js';
|
|
3
|
+
import { InputFormat } from './input-format.js';
|
|
4
|
+
import { OptionMember } from './option.js';
|
|
5
|
+
import { OutputFormat } from './output-format.js';
|
|
6
|
+
import { Stream } from './stream.js';
|
|
7
|
+
import type { AVCodecID, AVFormatFlag, AVMediaType, AVSeekFlag } from '../constants/constants.js';
|
|
8
|
+
import type { IOContext } from './io-context.js';
|
|
9
|
+
import type { NativeFormatContext, NativeWrapper } from './native-types.js';
|
|
10
|
+
import type { Packet } from './packet.js';
|
|
11
|
+
/**
|
|
12
|
+
* RTSP stream information interface
|
|
13
|
+
*/
|
|
14
|
+
export interface RTSPStreamInfo {
|
|
15
|
+
streamIndex: number;
|
|
16
|
+
controlUrl: string;
|
|
17
|
+
transport: 'tcp' | 'udp' | 'udp_multicast' | 'unknown';
|
|
18
|
+
payloadType: number;
|
|
19
|
+
codecId: AVCodecID;
|
|
20
|
+
mediaType: 'video' | 'audio' | 'data' | 'subtitle' | 'unknown';
|
|
21
|
+
mimeType: string;
|
|
22
|
+
sampleRate?: number;
|
|
23
|
+
channels?: number;
|
|
24
|
+
direction: 'sendonly' | 'recvonly' | 'sendrecv' | 'inactive';
|
|
25
|
+
fmtp?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Container format context for reading/writing multimedia files.
|
|
29
|
+
*
|
|
30
|
+
* Central structure for demuxing (reading) and muxing (writing) media files.
|
|
31
|
+
* Manages streams, packets, metadata, and format-specific operations.
|
|
32
|
+
* Supports both file-based and custom I/O through IOContext.
|
|
33
|
+
* Essential for all file-based media operations.
|
|
34
|
+
*
|
|
35
|
+
* Direct mapping to FFmpeg's AVFormatContext.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* import { FormatContext, FFmpegError } from 'node-av';
|
|
40
|
+
* import { AVMEDIA_TYPE_VIDEO } from 'node-av/constants';
|
|
41
|
+
*
|
|
42
|
+
* // Open input file
|
|
43
|
+
* const ctx = new FormatContext();
|
|
44
|
+
* let ret = await ctx.openInput('input.mp4');
|
|
45
|
+
* FFmpegError.throwIfError(ret, 'openInput');
|
|
46
|
+
*
|
|
47
|
+
* ret = await ctx.findStreamInfo();
|
|
48
|
+
* FFmpegError.throwIfError(ret, 'findStreamInfo');
|
|
49
|
+
*
|
|
50
|
+
* // Find video stream
|
|
51
|
+
* const videoIndex = ctx.findBestStream(AVMEDIA_TYPE_VIDEO);
|
|
52
|
+
* if (videoIndex < 0) {
|
|
53
|
+
* throw new Error('No video stream found');
|
|
54
|
+
* }
|
|
55
|
+
*
|
|
56
|
+
* // Read packets
|
|
57
|
+
* const packet = new Packet();
|
|
58
|
+
* packet.alloc();
|
|
59
|
+
* while ((ret = await ctx.readFrame(packet)) >= 0) {
|
|
60
|
+
* if (packet.streamIndex === videoIndex) {
|
|
61
|
+
* // Process video packet
|
|
62
|
+
* }
|
|
63
|
+
* packet.unref();
|
|
64
|
+
* }
|
|
65
|
+
*
|
|
66
|
+
* // Cleanup
|
|
67
|
+
* await ctx.closeInput();
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @see [AVFormatContext](https://ffmpeg.org/doxygen/trunk/structAVFormatContext.html) - FFmpeg Doxygen
|
|
71
|
+
* @see {@link InputFormat} For supported input formats
|
|
72
|
+
* @see {@link OutputFormat} For supported output formats
|
|
73
|
+
* @see {@link Stream} For stream management
|
|
74
|
+
*/
|
|
75
|
+
export declare class FormatContext extends OptionMember<NativeFormatContext> implements AsyncDisposable, NativeWrapper<NativeFormatContext> {
|
|
76
|
+
private _metadata?;
|
|
77
|
+
private _ioContext;
|
|
78
|
+
constructor();
|
|
79
|
+
/**
|
|
80
|
+
* URL or filename of the media.
|
|
81
|
+
*
|
|
82
|
+
* For input: the opened file path.
|
|
83
|
+
* For output: the target file path.
|
|
84
|
+
*
|
|
85
|
+
* Direct mapping to AVFormatContext->url.
|
|
86
|
+
*/
|
|
87
|
+
get url(): string | null;
|
|
88
|
+
set url(value: string | null);
|
|
89
|
+
/**
|
|
90
|
+
* Start time of the stream.
|
|
91
|
+
*
|
|
92
|
+
* Position of the first frame in microseconds.
|
|
93
|
+
* AV_NOPTS_VALUE if unknown.
|
|
94
|
+
*
|
|
95
|
+
* Direct mapping to AVFormatContext->start_time.
|
|
96
|
+
*/
|
|
97
|
+
get startTime(): bigint;
|
|
98
|
+
/**
|
|
99
|
+
* Duration of the stream.
|
|
100
|
+
*
|
|
101
|
+
* Total stream duration in microseconds.
|
|
102
|
+
* AV_NOPTS_VALUE if unknown.
|
|
103
|
+
*
|
|
104
|
+
* Direct mapping to AVFormatContext->duration.
|
|
105
|
+
*/
|
|
106
|
+
get duration(): bigint;
|
|
107
|
+
/**
|
|
108
|
+
* Total stream bitrate.
|
|
109
|
+
*
|
|
110
|
+
* Bitrate in bits per second.
|
|
111
|
+
* 0 if unknown.
|
|
112
|
+
*
|
|
113
|
+
* Direct mapping to AVFormatContext->bit_rate.
|
|
114
|
+
*/
|
|
115
|
+
get bitRate(): bigint;
|
|
116
|
+
/**
|
|
117
|
+
* Format-specific flags.
|
|
118
|
+
*
|
|
119
|
+
* Combination of AVFMT_FLAG_* values controlling
|
|
120
|
+
* format behavior (e.g., AVFMT_FLAG_GENPTS).
|
|
121
|
+
*
|
|
122
|
+
* Direct mapping to AVFormatContext->flags.
|
|
123
|
+
*/
|
|
124
|
+
get flags(): AVFormatFlag;
|
|
125
|
+
set flags(value: AVFormatFlag);
|
|
126
|
+
/**
|
|
127
|
+
* Maximum bytes to probe for format detection.
|
|
128
|
+
*
|
|
129
|
+
* Larger values improve format detection accuracy
|
|
130
|
+
* but increase startup time.
|
|
131
|
+
*
|
|
132
|
+
* Direct mapping to AVFormatContext->probesize.
|
|
133
|
+
*/
|
|
134
|
+
get probesize(): bigint;
|
|
135
|
+
set probesize(value: bigint);
|
|
136
|
+
/**
|
|
137
|
+
* Maximum duration to analyze streams.
|
|
138
|
+
*
|
|
139
|
+
* Time in microseconds to spend analyzing streams.
|
|
140
|
+
* Larger values improve stream detection accuracy.
|
|
141
|
+
*
|
|
142
|
+
* Direct mapping to AVFormatContext->max_analyze_duration.
|
|
143
|
+
*/
|
|
144
|
+
get maxAnalyzeDuration(): bigint;
|
|
145
|
+
set maxAnalyzeDuration(value: bigint);
|
|
146
|
+
/**
|
|
147
|
+
* Maximum buffering duration for interleaving.
|
|
148
|
+
*
|
|
149
|
+
* Specifies the maximum difference between the timestamps of the
|
|
150
|
+
* first and the last packet in the muxing queue, above which libavformat
|
|
151
|
+
* will output a packet regardless of whether it has queued a packet for all
|
|
152
|
+
* the streams.
|
|
153
|
+
*
|
|
154
|
+
* Set to 0 for unlimited buffering
|
|
155
|
+
*
|
|
156
|
+
* Default: 10000000 (10 seconds in microseconds)
|
|
157
|
+
*
|
|
158
|
+
* Muxing only, set before avformat_write_header().
|
|
159
|
+
*
|
|
160
|
+
* Direct mapping to AVFormatContext->max_interleave_delta.
|
|
161
|
+
*/
|
|
162
|
+
get maxInterleaveDelta(): bigint;
|
|
163
|
+
set maxInterleaveDelta(value: bigint);
|
|
164
|
+
/**
|
|
165
|
+
* Container metadata.
|
|
166
|
+
*
|
|
167
|
+
* Key-value pairs of metadata (title, author, etc.).
|
|
168
|
+
*
|
|
169
|
+
* Direct mapping to AVFormatContext->metadata.
|
|
170
|
+
*/
|
|
171
|
+
get metadata(): Dictionary | null;
|
|
172
|
+
set metadata(value: Dictionary | null);
|
|
173
|
+
/**
|
|
174
|
+
* Input format descriptor.
|
|
175
|
+
*
|
|
176
|
+
* Format used for demuxing. Null for output contexts.
|
|
177
|
+
*
|
|
178
|
+
* Direct mapping to AVFormatContext->iformat.
|
|
179
|
+
*/
|
|
180
|
+
get iformat(): InputFormat | null;
|
|
181
|
+
/**
|
|
182
|
+
* Output format descriptor.
|
|
183
|
+
*
|
|
184
|
+
* Format used for muxing. Null for input contexts.
|
|
185
|
+
*
|
|
186
|
+
* Direct mapping to AVFormatContext->oformat.
|
|
187
|
+
*/
|
|
188
|
+
get oformat(): OutputFormat | null;
|
|
189
|
+
set oformat(value: OutputFormat | null);
|
|
190
|
+
/**
|
|
191
|
+
* Custom I/O context.
|
|
192
|
+
*
|
|
193
|
+
* For custom I/O operations instead of file I/O.
|
|
194
|
+
*
|
|
195
|
+
* Direct mapping to AVFormatContext->pb.
|
|
196
|
+
*/
|
|
197
|
+
get pb(): IOContext | null;
|
|
198
|
+
set pb(value: IOContext | null);
|
|
199
|
+
/**
|
|
200
|
+
* Number of streams in the container.
|
|
201
|
+
*
|
|
202
|
+
* Direct mapping to AVFormatContext->nb_streams.
|
|
203
|
+
*/
|
|
204
|
+
get nbStreams(): number;
|
|
205
|
+
/**
|
|
206
|
+
* Array of streams in the container.
|
|
207
|
+
*
|
|
208
|
+
* All audio, video, subtitle, and data streams.
|
|
209
|
+
*
|
|
210
|
+
* Direct mapping to AVFormatContext->streams.
|
|
211
|
+
*/
|
|
212
|
+
get streams(): Stream[];
|
|
213
|
+
/**
|
|
214
|
+
* Strictness level for standards compliance.
|
|
215
|
+
*
|
|
216
|
+
* FF_COMPLIANCE_* value controlling how strictly
|
|
217
|
+
* to follow specifications.
|
|
218
|
+
*
|
|
219
|
+
* Direct mapping to AVFormatContext->strict_std_compliance.
|
|
220
|
+
*/
|
|
221
|
+
get strictStdCompliance(): number;
|
|
222
|
+
set strictStdCompliance(value: number);
|
|
223
|
+
/**
|
|
224
|
+
* Maximum number of streams.
|
|
225
|
+
*
|
|
226
|
+
* Limit on stream count for security/resource reasons.
|
|
227
|
+
*
|
|
228
|
+
* Direct mapping to AVFormatContext->max_streams.
|
|
229
|
+
*/
|
|
230
|
+
get maxStreams(): number;
|
|
231
|
+
set maxStreams(value: number);
|
|
232
|
+
/**
|
|
233
|
+
* Number of programs.
|
|
234
|
+
*
|
|
235
|
+
* For containers with multiple programs (e.g., MPEG-TS).
|
|
236
|
+
*
|
|
237
|
+
* Direct mapping to AVFormatContext->nb_programs.
|
|
238
|
+
*/
|
|
239
|
+
get nbPrograms(): number;
|
|
240
|
+
/**
|
|
241
|
+
* Number of bytes read/written through I/O context.
|
|
242
|
+
*
|
|
243
|
+
* Direct mapping to avio_tell(AVFormatContext->pb).
|
|
244
|
+
*/
|
|
245
|
+
get pbBytes(): bigint;
|
|
246
|
+
/**
|
|
247
|
+
* Format probe score.
|
|
248
|
+
*
|
|
249
|
+
* Confidence score from format detection (0-100).
|
|
250
|
+
* Higher values indicate more confident detection.
|
|
251
|
+
*
|
|
252
|
+
* Direct mapping to AVFormatContext->probe_score.
|
|
253
|
+
*/
|
|
254
|
+
get probeScore(): number;
|
|
255
|
+
/**
|
|
256
|
+
* Allocate a format context.
|
|
257
|
+
*
|
|
258
|
+
* Allocates the context structure. Usually not needed
|
|
259
|
+
* as openInput/allocOutputContext2 handle this.
|
|
260
|
+
*
|
|
261
|
+
* Direct mapping to avformat_alloc_context().
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```typescript
|
|
265
|
+
* const ctx = new FormatContext();
|
|
266
|
+
* ctx.allocContext();
|
|
267
|
+
* // Context is now allocated
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
allocContext(): void;
|
|
271
|
+
/**
|
|
272
|
+
* Allocate an output format context.
|
|
273
|
+
*
|
|
274
|
+
* Allocates and configures context for writing.
|
|
275
|
+
* Format is determined by parameters in priority order.
|
|
276
|
+
*
|
|
277
|
+
* Direct mapping to avformat_alloc_output_context2().
|
|
278
|
+
*
|
|
279
|
+
* @param oformat - Specific output format to use
|
|
280
|
+
*
|
|
281
|
+
* @param formatName - Format name (e.g., 'mp4', 'mkv')
|
|
282
|
+
*
|
|
283
|
+
* @param filename - Filename to guess format from extension
|
|
284
|
+
*
|
|
285
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
286
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
287
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```typescript
|
|
291
|
+
* import { FFmpegError } from 'node-av';
|
|
292
|
+
*
|
|
293
|
+
* const ctx = new FormatContext();
|
|
294
|
+
* const ret = ctx.allocOutputContext2(null, 'mp4', 'output.mp4');
|
|
295
|
+
* FFmpegError.throwIfError(ret, 'allocOutputContext2');
|
|
296
|
+
* ```
|
|
297
|
+
*
|
|
298
|
+
* @see {@link openOutput} To open output file
|
|
299
|
+
* @see {@link writeHeader} To write file header
|
|
300
|
+
*/
|
|
301
|
+
allocOutputContext2(oformat: OutputFormat | null, formatName: string | null, filename: string | null): number;
|
|
302
|
+
/**
|
|
303
|
+
* Free the format context.
|
|
304
|
+
*
|
|
305
|
+
* Releases all resources. The context becomes invalid.
|
|
306
|
+
*
|
|
307
|
+
* Direct mapping to avformat_free_context().
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* ```typescript
|
|
311
|
+
* ctx.freeContext();
|
|
312
|
+
* // Context is now invalid
|
|
313
|
+
* ```
|
|
314
|
+
*
|
|
315
|
+
* @see {@link Symbol.asyncDispose} For automatic cleanup
|
|
316
|
+
*/
|
|
317
|
+
freeContext(): void;
|
|
318
|
+
/**
|
|
319
|
+
* Open output file for writing.
|
|
320
|
+
*
|
|
321
|
+
* Opens the output file specified in url.
|
|
322
|
+
* Must call allocOutputContext2 first.
|
|
323
|
+
*
|
|
324
|
+
* Direct mapping to avio_open2().
|
|
325
|
+
*
|
|
326
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
327
|
+
* - AVERROR_ENOENT: File not found
|
|
328
|
+
* - AVERROR_EACCES: Permission denied
|
|
329
|
+
* - AVERROR_EIO: I/O error
|
|
330
|
+
*
|
|
331
|
+
* @example
|
|
332
|
+
* ```typescript
|
|
333
|
+
* import { FFmpegError } from 'node-av';
|
|
334
|
+
*
|
|
335
|
+
* const ret = await ctx.openOutput();
|
|
336
|
+
* FFmpegError.throwIfError(ret, 'openOutput');
|
|
337
|
+
* ```
|
|
338
|
+
*
|
|
339
|
+
* @see {@link allocOutputContext2} Must be called first
|
|
340
|
+
* @see {@link closeOutput} To close output
|
|
341
|
+
*/
|
|
342
|
+
openOutput(): Promise<number>;
|
|
343
|
+
/**
|
|
344
|
+
* Open output file synchronously.
|
|
345
|
+
* Synchronous version of openOutput.
|
|
346
|
+
*
|
|
347
|
+
* Opens output file for writing.
|
|
348
|
+
* I/O context must be set before calling.
|
|
349
|
+
*
|
|
350
|
+
* Direct mapping to avio_open2().
|
|
351
|
+
*
|
|
352
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
353
|
+
* - AVERROR(EIO): I/O error
|
|
354
|
+
* - AVERROR(ENOMEM): Memory allocation failure
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* ```typescript
|
|
358
|
+
* import { FFmpegError } from 'node-av';
|
|
359
|
+
*
|
|
360
|
+
* const ret = ctx.openOutputSync();
|
|
361
|
+
* FFmpegError.throwIfError(ret, 'openOutputSync');
|
|
362
|
+
* ```
|
|
363
|
+
*
|
|
364
|
+
* @see {@link openOutput} For async version
|
|
365
|
+
*/
|
|
366
|
+
openOutputSync(): number;
|
|
367
|
+
/**
|
|
368
|
+
* Close output file.
|
|
369
|
+
*
|
|
370
|
+
* Closes the output file and releases I/O resources.
|
|
371
|
+
*
|
|
372
|
+
* Direct mapping to avio_closep().
|
|
373
|
+
*
|
|
374
|
+
* @returns Promise that resolves when closed
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* ```typescript
|
|
378
|
+
* await ctx.closeOutput();
|
|
379
|
+
* // Output file closed
|
|
380
|
+
* ```
|
|
381
|
+
*
|
|
382
|
+
* @see {@link openOutput} To open output
|
|
383
|
+
*/
|
|
384
|
+
closeOutput(): Promise<void>;
|
|
385
|
+
/**
|
|
386
|
+
* Close output file synchronously.
|
|
387
|
+
* Synchronous version of closeOutput.
|
|
388
|
+
*
|
|
389
|
+
* Closes the output file and releases I/O resources.
|
|
390
|
+
*
|
|
391
|
+
* Direct mapping to avio_closep().
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```typescript
|
|
395
|
+
* ctx.closeOutputSync();
|
|
396
|
+
* // Output file closed
|
|
397
|
+
* ```
|
|
398
|
+
*
|
|
399
|
+
* @see {@link closeOutput} For async version
|
|
400
|
+
*/
|
|
401
|
+
closeOutputSync(): void;
|
|
402
|
+
/**
|
|
403
|
+
* Open input file for reading.
|
|
404
|
+
*
|
|
405
|
+
* Opens and probes the input file, detecting format automatically
|
|
406
|
+
* unless specified.
|
|
407
|
+
*
|
|
408
|
+
* Direct mapping to avformat_open_input().
|
|
409
|
+
*
|
|
410
|
+
* @param url - URL or file path to open
|
|
411
|
+
*
|
|
412
|
+
* @param fmt - Force specific input format (null for auto-detect)
|
|
413
|
+
*
|
|
414
|
+
* @param options - Format-specific options
|
|
415
|
+
*
|
|
416
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
417
|
+
* - AVERROR_ENOENT: File not found
|
|
418
|
+
* - AVERROR_INVALIDDATA: Invalid file format
|
|
419
|
+
* - AVERROR_EIO: I/O error
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
* ```typescript
|
|
423
|
+
* import { FFmpegError } from 'node-av';
|
|
424
|
+
*
|
|
425
|
+
* const ret = await ctx.openInput('input.mp4');
|
|
426
|
+
* FFmpegError.throwIfError(ret, 'openInput');
|
|
427
|
+
* ```
|
|
428
|
+
*
|
|
429
|
+
* @see {@link findStreamInfo} To analyze streams after opening
|
|
430
|
+
* @see {@link closeInput} To close input
|
|
431
|
+
*/
|
|
432
|
+
openInput(url: string, fmt?: InputFormat | null, options?: Dictionary | null): Promise<number>;
|
|
433
|
+
/**
|
|
434
|
+
* Open an input file or URL synchronously.
|
|
435
|
+
* Synchronous version of openInput.
|
|
436
|
+
*
|
|
437
|
+
* Opens a media file or stream for reading.
|
|
438
|
+
* The format is auto-detected if not specified.
|
|
439
|
+
*
|
|
440
|
+
* Direct mapping to avformat_open_input().
|
|
441
|
+
*
|
|
442
|
+
* @param url - File path or URL to open
|
|
443
|
+
*
|
|
444
|
+
* @param fmt - Force specific format (null for auto-detect)
|
|
445
|
+
*
|
|
446
|
+
* @param options - Format-specific options
|
|
447
|
+
*
|
|
448
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
449
|
+
* - AVERROR_EINVAL: Invalid arguments
|
|
450
|
+
* - AVERROR(EIO): I/O error
|
|
451
|
+
* - AVERROR(ENOMEM): Memory allocation failure
|
|
452
|
+
*
|
|
453
|
+
* @example
|
|
454
|
+
* ```typescript
|
|
455
|
+
* import { FFmpegError } from 'node-av';
|
|
456
|
+
*
|
|
457
|
+
* const ret = ctx.openInputSync('input.mp4');
|
|
458
|
+
* FFmpegError.throwIfError(ret, 'openInputSync');
|
|
459
|
+
* ```
|
|
460
|
+
*
|
|
461
|
+
* @see {@link openInput} For async version
|
|
462
|
+
*/
|
|
463
|
+
openInputSync(url: string, fmt?: InputFormat | null, options?: Dictionary | null): number;
|
|
464
|
+
/**
|
|
465
|
+
* Close an input format context.
|
|
466
|
+
*
|
|
467
|
+
* Closes input file and releases resources.
|
|
468
|
+
*
|
|
469
|
+
* Direct mapping to avformat_close_input().
|
|
470
|
+
*
|
|
471
|
+
* @returns Promise that resolves when closed
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* ```typescript
|
|
475
|
+
* await ctx.closeInput();
|
|
476
|
+
* // Input closed and context freed
|
|
477
|
+
* ```
|
|
478
|
+
*
|
|
479
|
+
* @see {@link openInput} To open input
|
|
480
|
+
*/
|
|
481
|
+
closeInput(): Promise<void>;
|
|
482
|
+
/**
|
|
483
|
+
* Close an input format context synchronously.
|
|
484
|
+
* Synchronous version of closeInput.
|
|
485
|
+
*
|
|
486
|
+
* Closes input file and releases resources.
|
|
487
|
+
*
|
|
488
|
+
* Direct mapping to avformat_close_input().
|
|
489
|
+
*
|
|
490
|
+
* @example
|
|
491
|
+
* ```typescript
|
|
492
|
+
* ctx.closeInputSync();
|
|
493
|
+
* // Input closed and context freed
|
|
494
|
+
* ```
|
|
495
|
+
*
|
|
496
|
+
* @see {@link closeInput} For async version
|
|
497
|
+
*/
|
|
498
|
+
closeInputSync(): void;
|
|
499
|
+
/**
|
|
500
|
+
* Analyze streams to get stream info.
|
|
501
|
+
*
|
|
502
|
+
* Reads packet headers to fill in stream information.
|
|
503
|
+
* Should be called after openInput for accurate stream data.
|
|
504
|
+
*
|
|
505
|
+
* Direct mapping to avformat_find_stream_info().
|
|
506
|
+
*
|
|
507
|
+
* @param options - Per-stream options array
|
|
508
|
+
*
|
|
509
|
+
* @returns >=0 on success, negative AVERROR on error:
|
|
510
|
+
* - AVERROR_EOF: End of file reached
|
|
511
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
512
|
+
*
|
|
513
|
+
* @example
|
|
514
|
+
* ```typescript
|
|
515
|
+
* import { FFmpegError } from 'node-av';
|
|
516
|
+
*
|
|
517
|
+
* const ret = await ctx.findStreamInfo();
|
|
518
|
+
* FFmpegError.throwIfError(ret, 'findStreamInfo');
|
|
519
|
+
* console.log(`Found ${ctx.nbStreams} streams`);
|
|
520
|
+
* ```
|
|
521
|
+
*
|
|
522
|
+
* @see {@link openInput} Must be called first
|
|
523
|
+
*/
|
|
524
|
+
findStreamInfo(options?: Dictionary[] | null): Promise<number>;
|
|
525
|
+
/**
|
|
526
|
+
* Analyze streams to get stream info synchronously.
|
|
527
|
+
* Synchronous version of findStreamInfo.
|
|
528
|
+
*
|
|
529
|
+
* Reads packet headers to fill in stream information.
|
|
530
|
+
* Should be called after openInputSync for accurate stream data.
|
|
531
|
+
*
|
|
532
|
+
* Direct mapping to avformat_find_stream_info().
|
|
533
|
+
*
|
|
534
|
+
* @param options - Options dictionary (single, not array for sync version)
|
|
535
|
+
*
|
|
536
|
+
* @returns >=0 on success, negative AVERROR on error:
|
|
537
|
+
* - AVERROR_EOF: End of file reached
|
|
538
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* ```typescript
|
|
542
|
+
* import { FFmpegError } from 'node-av';
|
|
543
|
+
*
|
|
544
|
+
* const ret = ctx.findStreamInfoSync();
|
|
545
|
+
* FFmpegError.throwIfError(ret, 'findStreamInfoSync');
|
|
546
|
+
* console.log(`Found ${ctx.nbStreams} streams`);
|
|
547
|
+
* ```
|
|
548
|
+
*
|
|
549
|
+
* @see {@link findStreamInfo} For async version
|
|
550
|
+
*/
|
|
551
|
+
findStreamInfoSync(options?: Dictionary | null): number;
|
|
552
|
+
/**
|
|
553
|
+
* Read next packet from the input.
|
|
554
|
+
*
|
|
555
|
+
* Reads and returns the next packet in the stream.
|
|
556
|
+
* Packet must be unreferenced after use.
|
|
557
|
+
*
|
|
558
|
+
* Direct mapping to av_read_frame().
|
|
559
|
+
*
|
|
560
|
+
* @param pkt - Packet to read into
|
|
561
|
+
*
|
|
562
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
563
|
+
* - AVERROR_EOF: End of file
|
|
564
|
+
* - AVERROR_EAGAIN: Temporarily unavailable
|
|
565
|
+
*
|
|
566
|
+
* @example
|
|
567
|
+
* ```typescript
|
|
568
|
+
* import { FFmpegError } from 'node-av';
|
|
569
|
+
* import { AVERROR_EOF } from 'node-av';
|
|
570
|
+
*
|
|
571
|
+
* const packet = new Packet();
|
|
572
|
+
* packet.alloc();
|
|
573
|
+
*
|
|
574
|
+
* let ret;
|
|
575
|
+
* while ((ret = await ctx.readFrame(packet)) >= 0) {
|
|
576
|
+
* // Process packet
|
|
577
|
+
* console.log(`Stream ${packet.streamIndex}, PTS: ${packet.pts}`);
|
|
578
|
+
* packet.unref();
|
|
579
|
+
* }
|
|
580
|
+
*
|
|
581
|
+
* if (ret !== AVERROR_EOF) {
|
|
582
|
+
* FFmpegError.throwIfError(ret, 'readFrame');
|
|
583
|
+
* }
|
|
584
|
+
* ```
|
|
585
|
+
*
|
|
586
|
+
* @see {@link seekFrame} To seek before reading
|
|
587
|
+
*/
|
|
588
|
+
readFrame(pkt: Packet): Promise<number>;
|
|
589
|
+
/**
|
|
590
|
+
* Read next packet from the input synchronously.
|
|
591
|
+
* Synchronous version of readFrame.
|
|
592
|
+
*
|
|
593
|
+
* Reads and returns the next packet in the stream.
|
|
594
|
+
* Packet must be unreferenced after use.
|
|
595
|
+
*
|
|
596
|
+
* Direct mapping to av_read_frame().
|
|
597
|
+
*
|
|
598
|
+
* @param pkt - Packet to read into
|
|
599
|
+
*
|
|
600
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
601
|
+
* - AVERROR_EOF: End of file
|
|
602
|
+
* - AVERROR_EAGAIN: Temporarily unavailable
|
|
603
|
+
*
|
|
604
|
+
* @example
|
|
605
|
+
* ```typescript
|
|
606
|
+
* import { FFmpegError } from 'node-av';
|
|
607
|
+
* import { AVERROR_EOF } from 'node-av';
|
|
608
|
+
*
|
|
609
|
+
* const packet = new Packet();
|
|
610
|
+
* packet.alloc();
|
|
611
|
+
*
|
|
612
|
+
* let ret;
|
|
613
|
+
* while ((ret = ctx.readFrameSync(packet)) >= 0) {
|
|
614
|
+
* // Process packet
|
|
615
|
+
* console.log(`Stream ${packet.streamIndex}, PTS: ${packet.pts}`);
|
|
616
|
+
* packet.unref();
|
|
617
|
+
* }
|
|
618
|
+
*
|
|
619
|
+
* if (ret !== AVERROR_EOF) {
|
|
620
|
+
* FFmpegError.throwIfError(ret, 'readFrameSync');
|
|
621
|
+
* }
|
|
622
|
+
* ```
|
|
623
|
+
*
|
|
624
|
+
* @see {@link readFrame} For async version
|
|
625
|
+
*/
|
|
626
|
+
readFrameSync(pkt: Packet): number;
|
|
627
|
+
/**
|
|
628
|
+
* Seek to timestamp in stream.
|
|
629
|
+
*
|
|
630
|
+
* Seeks to the keyframe at or before the given timestamp.
|
|
631
|
+
*
|
|
632
|
+
* Direct mapping to av_seek_frame().
|
|
633
|
+
*
|
|
634
|
+
* @param streamIndex - Stream to seek in (-1 for default)
|
|
635
|
+
*
|
|
636
|
+
* @param timestamp - Target timestamp in stream time base
|
|
637
|
+
*
|
|
638
|
+
* @param flags - Seek flags (AVSEEK_FLAG_*)
|
|
639
|
+
*
|
|
640
|
+
* @returns >=0 on success, negative AVERROR on error:
|
|
641
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
642
|
+
* - AVERROR_EOF: Seek beyond file
|
|
643
|
+
*
|
|
644
|
+
* @example
|
|
645
|
+
* ```typescript
|
|
646
|
+
* import { FFmpegError } from 'node-av';
|
|
647
|
+
* import { AVSEEK_FLAG_BACKWARD } from 'node-av/constants';
|
|
648
|
+
*
|
|
649
|
+
* // Seek to 10 seconds (assuming 1/1000 time base)
|
|
650
|
+
* const ret = await ctx.seekFrame(videoStreamIndex, 10000n, AVSEEK_FLAG_BACKWARD);
|
|
651
|
+
* FFmpegError.throwIfError(ret, 'seekFrame');
|
|
652
|
+
* ```
|
|
653
|
+
*
|
|
654
|
+
* @see {@link seekFile} For more precise seeking
|
|
655
|
+
*/
|
|
656
|
+
seekFrame(streamIndex: number, timestamp: bigint, flags?: AVSeekFlag): Promise<number>;
|
|
657
|
+
/**
|
|
658
|
+
* Seek to timestamp in stream synchronously.
|
|
659
|
+
* Synchronous version of seekFrame.
|
|
660
|
+
*
|
|
661
|
+
* Seeks to closest keyframe at or before timestamp.
|
|
662
|
+
* Timestamp is in stream timebase units.
|
|
663
|
+
*
|
|
664
|
+
* Direct mapping to av_seek_frame().
|
|
665
|
+
*
|
|
666
|
+
* @param streamIndex - Stream to seek in (-1 for default)
|
|
667
|
+
*
|
|
668
|
+
* @param timestamp - Target timestamp in stream timebase
|
|
669
|
+
*
|
|
670
|
+
* @param flags - Seek flags (AVSEEK_FLAG_*)
|
|
671
|
+
*
|
|
672
|
+
* @returns >=0 on success, negative AVERROR on error:
|
|
673
|
+
* - AVERROR_EINVAL: Invalid arguments
|
|
674
|
+
* - AVERROR(EIO): I/O error
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
* ```typescript
|
|
678
|
+
* import { FFmpegError } from 'node-av';
|
|
679
|
+
* import { AVSEEK_FLAG_BACKWARD } from 'node-av/constants';
|
|
680
|
+
*
|
|
681
|
+
* // Seek to 10 seconds
|
|
682
|
+
* const timestamp = 10n * 1000000n; // Assuming microsecond timebase
|
|
683
|
+
* const ret = ctx.seekFrameSync(-1, timestamp, AVSEEK_FLAG_BACKWARD);
|
|
684
|
+
* FFmpegError.throwIfError(ret, 'seekFrameSync');
|
|
685
|
+
* ```
|
|
686
|
+
*
|
|
687
|
+
* @see {@link seekFrame} For async version
|
|
688
|
+
*/
|
|
689
|
+
seekFrameSync(streamIndex: number, timestamp: bigint, flags?: AVSeekFlag): number;
|
|
690
|
+
/**
|
|
691
|
+
* Seek to timestamp with bounds.
|
|
692
|
+
*
|
|
693
|
+
* More precise seeking with min/max timestamp bounds.
|
|
694
|
+
*
|
|
695
|
+
* Direct mapping to avformat_seek_file().
|
|
696
|
+
*
|
|
697
|
+
* @param streamIndex - Stream to seek in (-1 for default)
|
|
698
|
+
*
|
|
699
|
+
* @param minTs - Minimum acceptable timestamp
|
|
700
|
+
*
|
|
701
|
+
* @param ts - Target timestamp
|
|
702
|
+
*
|
|
703
|
+
* @param maxTs - Maximum acceptable timestamp
|
|
704
|
+
*
|
|
705
|
+
* @param flags - Seek flags
|
|
706
|
+
*
|
|
707
|
+
* @returns >=0 on success, negative AVERROR on error
|
|
708
|
+
*
|
|
709
|
+
* @example
|
|
710
|
+
* ```typescript
|
|
711
|
+
* import { FFmpegError } from 'node-av';
|
|
712
|
+
*
|
|
713
|
+
* // Seek to 10s with 0.5s tolerance
|
|
714
|
+
* const target = 10000n;
|
|
715
|
+
* const ret = await ctx.seekFile(
|
|
716
|
+
* -1,
|
|
717
|
+
* target - 500n,
|
|
718
|
+
* target,
|
|
719
|
+
* target + 500n
|
|
720
|
+
* );
|
|
721
|
+
* FFmpegError.throwIfError(ret, 'seekFile');
|
|
722
|
+
* ```
|
|
723
|
+
*
|
|
724
|
+
* @see {@link seekFrame} For simpler seeking
|
|
725
|
+
*/
|
|
726
|
+
seekFile(streamIndex: number, minTs: bigint, ts: bigint, maxTs: bigint, flags?: AVSeekFlag): Promise<number>;
|
|
727
|
+
/**
|
|
728
|
+
* Write file header.
|
|
729
|
+
*
|
|
730
|
+
* Writes the file header and initializes output.
|
|
731
|
+
* Must be called before writing packets.
|
|
732
|
+
*
|
|
733
|
+
* Direct mapping to avformat_write_header().
|
|
734
|
+
*
|
|
735
|
+
* @param options - Muxer-specific options
|
|
736
|
+
*
|
|
737
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
738
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
739
|
+
* - AVERROR_EIO: I/O error
|
|
740
|
+
*
|
|
741
|
+
* @example
|
|
742
|
+
* ```typescript
|
|
743
|
+
* import { FFmpegError } from 'node-av';
|
|
744
|
+
*
|
|
745
|
+
* const ret = await ctx.writeHeader();
|
|
746
|
+
* FFmpegError.throwIfError(ret, 'writeHeader');
|
|
747
|
+
* // Now ready to write packets
|
|
748
|
+
* ```
|
|
749
|
+
*
|
|
750
|
+
* @see {@link writeTrailer} To finalize file
|
|
751
|
+
* @see {@link writeFrame} To write packets
|
|
752
|
+
*/
|
|
753
|
+
writeHeader(options?: Dictionary | null): Promise<number>;
|
|
754
|
+
/**
|
|
755
|
+
* Write file header synchronously.
|
|
756
|
+
* Synchronous version of writeHeader.
|
|
757
|
+
*
|
|
758
|
+
* Writes format header to output file.
|
|
759
|
+
* Must be called before writing packets.
|
|
760
|
+
*
|
|
761
|
+
* Direct mapping to avformat_write_header().
|
|
762
|
+
*
|
|
763
|
+
* @param options - Muxer-specific options
|
|
764
|
+
*
|
|
765
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
766
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
767
|
+
*
|
|
768
|
+
* @example
|
|
769
|
+
* ```typescript
|
|
770
|
+
* import { FFmpegError } from 'node-av';
|
|
771
|
+
*
|
|
772
|
+
* const ret = ctx.writeHeaderSync();
|
|
773
|
+
* FFmpegError.throwIfError(ret, 'writeHeaderSync');
|
|
774
|
+
* ```
|
|
775
|
+
*
|
|
776
|
+
* @see {@link writeHeader} For async version
|
|
777
|
+
*/
|
|
778
|
+
writeHeaderSync(options?: Dictionary | null): number;
|
|
779
|
+
/**
|
|
780
|
+
* Write packet to output.
|
|
781
|
+
*
|
|
782
|
+
* Writes a packet directly without interleaving.
|
|
783
|
+
* Caller must handle correct interleaving.
|
|
784
|
+
*
|
|
785
|
+
* Direct mapping to av_write_frame().
|
|
786
|
+
*
|
|
787
|
+
* @param pkt - Packet to write (null to flush)
|
|
788
|
+
*
|
|
789
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
790
|
+
* - AVERROR_EINVAL: Invalid packet
|
|
791
|
+
* - AVERROR_EIO: I/O error
|
|
792
|
+
*
|
|
793
|
+
* @example
|
|
794
|
+
* ```typescript
|
|
795
|
+
* import { FFmpegError } from 'node-av';
|
|
796
|
+
*
|
|
797
|
+
* const ret = await ctx.writeFrame(packet);
|
|
798
|
+
* FFmpegError.throwIfError(ret, 'writeFrame');
|
|
799
|
+
* ```
|
|
800
|
+
*
|
|
801
|
+
* @see {@link interleavedWriteFrame} For automatic interleaving
|
|
802
|
+
*/
|
|
803
|
+
writeFrame(pkt: Packet | null): Promise<number>;
|
|
804
|
+
/**
|
|
805
|
+
* Write packet to output synchronously.
|
|
806
|
+
* Synchronous version of writeFrame.
|
|
807
|
+
*
|
|
808
|
+
* Writes a packet directly without interleaving.
|
|
809
|
+
* Caller must handle correct interleaving.
|
|
810
|
+
*
|
|
811
|
+
* Direct mapping to av_write_frame().
|
|
812
|
+
*
|
|
813
|
+
* @param pkt - Packet to write (null to flush)
|
|
814
|
+
*
|
|
815
|
+
* @returns 0 on success, negative AVERROR on error
|
|
816
|
+
*
|
|
817
|
+
* @example
|
|
818
|
+
* ```typescript
|
|
819
|
+
* import { FFmpegError } from 'node-av';
|
|
820
|
+
*
|
|
821
|
+
* const ret = ctx.writeFrameSync(packet);
|
|
822
|
+
* FFmpegError.throwIfError(ret, 'writeFrameSync');
|
|
823
|
+
* ```
|
|
824
|
+
*
|
|
825
|
+
* @see {@link writeFrame} For async version
|
|
826
|
+
*/
|
|
827
|
+
writeFrameSync(pkt: Packet | null): number;
|
|
828
|
+
/**
|
|
829
|
+
* Write packet with automatic interleaving.
|
|
830
|
+
*
|
|
831
|
+
* Writes packet with proper interleaving for muxing.
|
|
832
|
+
* Preferred method for writing packets.
|
|
833
|
+
*
|
|
834
|
+
* Direct mapping to av_interleaved_write_frame().
|
|
835
|
+
*
|
|
836
|
+
* @param pkt - Packet to write (null to flush)
|
|
837
|
+
*
|
|
838
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
839
|
+
* - AVERROR_EINVAL: Invalid packet
|
|
840
|
+
* - AVERROR_EIO: I/O error
|
|
841
|
+
*
|
|
842
|
+
* @example
|
|
843
|
+
* ```typescript
|
|
844
|
+
* import { FFmpegError } from 'node-av';
|
|
845
|
+
*
|
|
846
|
+
* // Write with proper interleaving
|
|
847
|
+
* const ret = await ctx.interleavedWriteFrame(packet);
|
|
848
|
+
* FFmpegError.throwIfError(ret, 'interleavedWriteFrame');
|
|
849
|
+
*
|
|
850
|
+
* // Flush buffered packets
|
|
851
|
+
* await ctx.interleavedWriteFrame(null);
|
|
852
|
+
* ```
|
|
853
|
+
*
|
|
854
|
+
* @see {@link writeFrame} For direct writing
|
|
855
|
+
*/
|
|
856
|
+
interleavedWriteFrame(pkt: Packet | null): Promise<number>;
|
|
857
|
+
/**
|
|
858
|
+
* Write packet with automatic interleaving synchronously.
|
|
859
|
+
* Synchronous version of interleavedWriteFrame.
|
|
860
|
+
*
|
|
861
|
+
* Writes packet with proper interleaving for muxing.
|
|
862
|
+
* Preferred method for writing packets.
|
|
863
|
+
*
|
|
864
|
+
* Direct mapping to av_interleaved_write_frame().
|
|
865
|
+
*
|
|
866
|
+
* @param pkt - Packet to write (null to flush)
|
|
867
|
+
*
|
|
868
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
869
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
870
|
+
* - AVERROR(EIO): I/O error
|
|
871
|
+
*
|
|
872
|
+
* @example
|
|
873
|
+
* ```typescript
|
|
874
|
+
* import { FFmpegError } from 'node-av';
|
|
875
|
+
*
|
|
876
|
+
* // Write packet
|
|
877
|
+
* const ret = ctx.interleavedWriteFrameSync(packet);
|
|
878
|
+
* FFmpegError.throwIfError(ret, 'interleavedWriteFrameSync');
|
|
879
|
+
*
|
|
880
|
+
* // Flush interleaved packets
|
|
881
|
+
* ctx.interleavedWriteFrameSync(null);
|
|
882
|
+
* ```
|
|
883
|
+
*
|
|
884
|
+
* @see {@link interleavedWriteFrame} For async version
|
|
885
|
+
*/
|
|
886
|
+
interleavedWriteFrameSync(pkt: Packet | null): number;
|
|
887
|
+
/**
|
|
888
|
+
* Write file trailer.
|
|
889
|
+
*
|
|
890
|
+
* Finalizes the output file, writing index and metadata.
|
|
891
|
+
* Must be called to properly close output files.
|
|
892
|
+
*
|
|
893
|
+
* Direct mapping to av_write_trailer().
|
|
894
|
+
*
|
|
895
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
896
|
+
* - AVERROR_EIO: I/O error
|
|
897
|
+
*
|
|
898
|
+
* @example
|
|
899
|
+
* ```typescript
|
|
900
|
+
* import { FFmpegError } from 'node-av';
|
|
901
|
+
*
|
|
902
|
+
* const ret = await ctx.writeTrailer();
|
|
903
|
+
* FFmpegError.throwIfError(ret, 'writeTrailer');
|
|
904
|
+
* // File is now finalized
|
|
905
|
+
* ```
|
|
906
|
+
*
|
|
907
|
+
* @see {@link writeHeader} Must be called first
|
|
908
|
+
*/
|
|
909
|
+
writeTrailer(): Promise<number>;
|
|
910
|
+
/**
|
|
911
|
+
* Write file trailer synchronously.
|
|
912
|
+
* Synchronous version of writeTrailer.
|
|
913
|
+
*
|
|
914
|
+
* Finalizes the output file, writing index and metadata.
|
|
915
|
+
* Must be called to properly close output files.
|
|
916
|
+
*
|
|
917
|
+
* Direct mapping to av_write_trailer().
|
|
918
|
+
*
|
|
919
|
+
* @returns 0 on success, negative AVERROR on error
|
|
920
|
+
*
|
|
921
|
+
* @example
|
|
922
|
+
* ```typescript
|
|
923
|
+
* import { FFmpegError } from 'node-av';
|
|
924
|
+
*
|
|
925
|
+
* const ret = ctx.writeTrailerSync();
|
|
926
|
+
* FFmpegError.throwIfError(ret, 'writeTrailerSync');
|
|
927
|
+
* // File is now finalized
|
|
928
|
+
* ```
|
|
929
|
+
*
|
|
930
|
+
* @see {@link writeTrailer} For async version
|
|
931
|
+
*/
|
|
932
|
+
writeTrailerSync(): number;
|
|
933
|
+
/**
|
|
934
|
+
* Flush buffered data.
|
|
935
|
+
*
|
|
936
|
+
* Flushes any buffered packets in muxers.
|
|
937
|
+
*
|
|
938
|
+
* Direct mapping to avio_flush().
|
|
939
|
+
*
|
|
940
|
+
* @example
|
|
941
|
+
* ```typescript
|
|
942
|
+
* await ctx.flush();
|
|
943
|
+
* // Buffered data written to output
|
|
944
|
+
* ```
|
|
945
|
+
*/
|
|
946
|
+
flush(): Promise<void>;
|
|
947
|
+
/**
|
|
948
|
+
* Flush buffered data synchronously.
|
|
949
|
+
* Synchronous version of flush.
|
|
950
|
+
*
|
|
951
|
+
* Flushes any buffered packets in muxers.
|
|
952
|
+
*
|
|
953
|
+
* Direct mapping to avio_flush().
|
|
954
|
+
*
|
|
955
|
+
* @example
|
|
956
|
+
* ```typescript
|
|
957
|
+
* ctx.flushSync();
|
|
958
|
+
* // Buffered data written to output
|
|
959
|
+
* ```
|
|
960
|
+
*
|
|
961
|
+
* @see {@link flush} For async version
|
|
962
|
+
*/
|
|
963
|
+
flushSync(): void;
|
|
964
|
+
/**
|
|
965
|
+
* Print format information.
|
|
966
|
+
*
|
|
967
|
+
* Dumps human-readable format info to stderr.
|
|
968
|
+
* Useful for debugging.
|
|
969
|
+
*
|
|
970
|
+
* Direct mapping to av_dump_format().
|
|
971
|
+
*
|
|
972
|
+
* @param index - Stream index to highlight (-1 for none)
|
|
973
|
+
*
|
|
974
|
+
* @param url - URL to display
|
|
975
|
+
*
|
|
976
|
+
* @param isOutput - True for output format, false for input
|
|
977
|
+
*
|
|
978
|
+
* @example
|
|
979
|
+
* ```typescript
|
|
980
|
+
* // Dump input format info
|
|
981
|
+
* ctx.dumpFormat(0, 'input.mp4', false);
|
|
982
|
+
*
|
|
983
|
+
* // Dump output format info
|
|
984
|
+
* ctx.dumpFormat(0, 'output.mp4', true);
|
|
985
|
+
* ```
|
|
986
|
+
*/
|
|
987
|
+
dumpFormat(index: number, url: string, isOutput: boolean): void;
|
|
988
|
+
/**
|
|
989
|
+
* Find the best stream of a given type.
|
|
990
|
+
*
|
|
991
|
+
* Selects the most suitable stream (e.g., default audio/video).
|
|
992
|
+
*
|
|
993
|
+
* Direct mapping to av_find_best_stream().
|
|
994
|
+
*
|
|
995
|
+
* @param type - Media type to find (AVMEDIA_TYPE_*)
|
|
996
|
+
*
|
|
997
|
+
* @param wantedStreamNb - Preferred stream index (-1 for auto)
|
|
998
|
+
*
|
|
999
|
+
* @param relatedStream - Related stream for audio/video sync (-1 for none)
|
|
1000
|
+
*
|
|
1001
|
+
* @returns Stream index, or negative AVERROR if not found
|
|
1002
|
+
*
|
|
1003
|
+
* @example
|
|
1004
|
+
* ```typescript
|
|
1005
|
+
* import { AVMEDIA_TYPE_VIDEO, AVMEDIA_TYPE_AUDIO } from 'node-av/constants';
|
|
1006
|
+
*
|
|
1007
|
+
* const videoIndex = ctx.findBestStream(AVMEDIA_TYPE_VIDEO);
|
|
1008
|
+
* if (videoIndex >= 0) {
|
|
1009
|
+
* console.log(`Best video stream: ${videoIndex}`);
|
|
1010
|
+
* }
|
|
1011
|
+
*
|
|
1012
|
+
* const audioIndex = ctx.findBestStream(AVMEDIA_TYPE_AUDIO);
|
|
1013
|
+
* if (audioIndex >= 0) {
|
|
1014
|
+
* console.log(`Best audio stream: ${audioIndex}`);
|
|
1015
|
+
* }
|
|
1016
|
+
* ```
|
|
1017
|
+
*/
|
|
1018
|
+
findBestStream(type: AVMediaType, wantedStreamNb?: number, relatedStream?: number): number;
|
|
1019
|
+
/**
|
|
1020
|
+
* Find the best stream and its decoder.
|
|
1021
|
+
*
|
|
1022
|
+
* @param type - Media type to find
|
|
1023
|
+
*
|
|
1024
|
+
* @param wantedStreamNb - Preferred stream index
|
|
1025
|
+
*
|
|
1026
|
+
* @param relatedStream - Related stream index
|
|
1027
|
+
*
|
|
1028
|
+
* @param wantDecoder - True to also find decoder
|
|
1029
|
+
*
|
|
1030
|
+
* @param flags - Reserved flags
|
|
1031
|
+
*
|
|
1032
|
+
* @returns Object with stream index and decoder
|
|
1033
|
+
*/
|
|
1034
|
+
findBestStream(type: AVMediaType, wantedStreamNb: number, relatedStream: number, wantDecoder: true, flags?: number): {
|
|
1035
|
+
streamIndex: number;
|
|
1036
|
+
decoder: Codec | null;
|
|
1037
|
+
};
|
|
1038
|
+
/**
|
|
1039
|
+
* Add a new stream to output context.
|
|
1040
|
+
*
|
|
1041
|
+
* Creates a new stream for writing.
|
|
1042
|
+
*
|
|
1043
|
+
* Direct mapping to avformat_new_stream().
|
|
1044
|
+
*
|
|
1045
|
+
* @param c - Codec for the stream (optional)
|
|
1046
|
+
*
|
|
1047
|
+
* @returns New stream instance
|
|
1048
|
+
*
|
|
1049
|
+
* @example
|
|
1050
|
+
* ```typescript
|
|
1051
|
+
* import { Codec } from 'node-av';
|
|
1052
|
+
* import { AV_CODEC_ID_H264 } from 'node-av/constants';
|
|
1053
|
+
*
|
|
1054
|
+
* const codec = Codec.findEncoder(AV_CODEC_ID_H264);
|
|
1055
|
+
* const stream = ctx.newStream(codec);
|
|
1056
|
+
* stream.id = ctx.nbStreams - 1;
|
|
1057
|
+
* ```
|
|
1058
|
+
*
|
|
1059
|
+
* @see {@link Stream} For stream configuration
|
|
1060
|
+
*/
|
|
1061
|
+
newStream(c?: Codec | null): Stream;
|
|
1062
|
+
/**
|
|
1063
|
+
* Set format flags.
|
|
1064
|
+
*
|
|
1065
|
+
* Sets one or more flags using bitwise OR. Allows setting multiple flags
|
|
1066
|
+
* without manually performing bitwise operations.
|
|
1067
|
+
*
|
|
1068
|
+
* @param flags - One or more flag values to set
|
|
1069
|
+
*
|
|
1070
|
+
* @example
|
|
1071
|
+
* ```typescript
|
|
1072
|
+
* import { AVFMT_FLAG_GENPTS, AVFMT_FLAG_IGNIDX } from 'node-av/constants';
|
|
1073
|
+
*
|
|
1074
|
+
* // Set multiple flags at once
|
|
1075
|
+
* formatContext.setFlags(AVFMT_FLAG_GENPTS, AVFMT_FLAG_IGNIDX);
|
|
1076
|
+
* ```
|
|
1077
|
+
*
|
|
1078
|
+
* @see {@link clearFlags} To unset flags
|
|
1079
|
+
* @see {@link hasFlags} To check flags
|
|
1080
|
+
* @see {@link flags} For direct flag access
|
|
1081
|
+
*/
|
|
1082
|
+
setFlags(...flags: AVFormatFlag[]): void;
|
|
1083
|
+
/**
|
|
1084
|
+
* Clear format flags.
|
|
1085
|
+
*
|
|
1086
|
+
* Clears one or more flags using bitwise AND NOT. Allows clearing multiple
|
|
1087
|
+
* flags without manually performing bitwise operations.
|
|
1088
|
+
*
|
|
1089
|
+
* @param flags - One or more flag values to clear
|
|
1090
|
+
*
|
|
1091
|
+
* @example
|
|
1092
|
+
* ```typescript
|
|
1093
|
+
* import { AVFMT_FLAG_IGNIDX } from 'node-av/constants';
|
|
1094
|
+
*
|
|
1095
|
+
* // Clear specific flag
|
|
1096
|
+
* formatContext.clearFlags(AVFMT_FLAG_IGNIDX);
|
|
1097
|
+
* ```
|
|
1098
|
+
*
|
|
1099
|
+
* @see {@link setFlags} To set flags
|
|
1100
|
+
* @see {@link hasFlags} To check flags
|
|
1101
|
+
* @see {@link flags} For direct flag access
|
|
1102
|
+
*/
|
|
1103
|
+
clearFlags(...flags: AVFormatFlag[]): void;
|
|
1104
|
+
/**
|
|
1105
|
+
* Check if format context has specific flags.
|
|
1106
|
+
*
|
|
1107
|
+
* Tests whether all specified flags are set using bitwise AND.
|
|
1108
|
+
*
|
|
1109
|
+
* @param flags - One or more flag values to check
|
|
1110
|
+
*
|
|
1111
|
+
* @returns true if all specified flags are set, false otherwise
|
|
1112
|
+
*
|
|
1113
|
+
* @example
|
|
1114
|
+
* ```typescript
|
|
1115
|
+
* import { AVFMT_FLAG_GENPTS } from 'node-av/constants';
|
|
1116
|
+
*
|
|
1117
|
+
* if (formatContext.hasFlags(AVFMT_FLAG_GENPTS)) {
|
|
1118
|
+
* console.log('GENPTS flag is set');
|
|
1119
|
+
* }
|
|
1120
|
+
* ```
|
|
1121
|
+
*
|
|
1122
|
+
* @see {@link setFlags} To set flags
|
|
1123
|
+
* @see {@link clearFlags} To unset flags
|
|
1124
|
+
* @see {@link flags} For direct flag access
|
|
1125
|
+
*/
|
|
1126
|
+
hasFlags(...flags: AVFormatFlag[]): boolean;
|
|
1127
|
+
/**
|
|
1128
|
+
* Get RTSP stream information.
|
|
1129
|
+
*
|
|
1130
|
+
* Returns information about all RTSP streams including codec details.
|
|
1131
|
+
* Only works with RTSP input contexts.
|
|
1132
|
+
*
|
|
1133
|
+
* @returns Array of stream information objects with codec details, or null if not RTSP
|
|
1134
|
+
*
|
|
1135
|
+
* @example
|
|
1136
|
+
* ```typescript
|
|
1137
|
+
* const ctx = new FormatContext();
|
|
1138
|
+
* await ctx.openInput('rtsp://camera/stream?backchannel=1');
|
|
1139
|
+
*
|
|
1140
|
+
* const rtspStreams = ctx.getRTSPStreamInfo();
|
|
1141
|
+
* if (rtspStreams) {
|
|
1142
|
+
* // Find sendonly stream (backchannel)
|
|
1143
|
+
* const backchannel = rtspStreams.find(s => s.direction === 'sendonly');
|
|
1144
|
+
* if (backchannel) {
|
|
1145
|
+
* console.log(`Transport: ${backchannel.transport}`);
|
|
1146
|
+
* console.log(`Codec ID: ${backchannel.codecId}`);
|
|
1147
|
+
* console.log(`MIME Type: ${backchannel.mimeType}`);
|
|
1148
|
+
* console.log(`Payload Type: ${backchannel.payloadType}`);
|
|
1149
|
+
* if (backchannel.sampleRate) {
|
|
1150
|
+
* console.log(`Audio: ${backchannel.sampleRate}Hz, ${backchannel.channels} channels`);
|
|
1151
|
+
* }
|
|
1152
|
+
* }
|
|
1153
|
+
* }
|
|
1154
|
+
* ```
|
|
1155
|
+
*/
|
|
1156
|
+
getRTSPStreamInfo(): RTSPStreamInfo[] | null;
|
|
1157
|
+
/**
|
|
1158
|
+
* Send RTP packet to RTSP stream (supports both TCP and UDP)
|
|
1159
|
+
*
|
|
1160
|
+
* Automatically handles transport-specific packet formatting:
|
|
1161
|
+
* - TCP: Sends with interleaved header ($channelId + length + RTP)
|
|
1162
|
+
* - UDP: Sends raw RTP packet directly to UDP socket
|
|
1163
|
+
*
|
|
1164
|
+
* Used for backchannel/talkback audio streaming.
|
|
1165
|
+
* Only works with RTSP input contexts.
|
|
1166
|
+
*
|
|
1167
|
+
* @param streamIndex - RTSP stream index
|
|
1168
|
+
*
|
|
1169
|
+
* @param rtpData - Raw RTP packet data (12-byte header + payload)
|
|
1170
|
+
*
|
|
1171
|
+
* @returns Promise resolving to number of bytes written on success, negative AVERROR on failure
|
|
1172
|
+
*
|
|
1173
|
+
* @example
|
|
1174
|
+
* ```typescript
|
|
1175
|
+
* // Get backchannel stream info
|
|
1176
|
+
* const streams = ctx.getRTSPStreamInfo();
|
|
1177
|
+
* const backchannel = streams.find(s => s.direction === 'sendonly');
|
|
1178
|
+
*
|
|
1179
|
+
* if (backchannel) {
|
|
1180
|
+
* // Send to camera (works with both TCP and UDP)
|
|
1181
|
+
* const ret = await ctx.sendRTSPPacket(backchannel.streamIndex, rtpPacket);
|
|
1182
|
+
* if (ret < 0) {
|
|
1183
|
+
* throw new Error(`Failed to send: ${ret}`);
|
|
1184
|
+
* }
|
|
1185
|
+
* }
|
|
1186
|
+
* ```
|
|
1187
|
+
*
|
|
1188
|
+
* @see {@link sendRTSPPacketSync} For synchronous version
|
|
1189
|
+
* @see {@link getRTSPStreamInfo} For getting stream info and transport type
|
|
1190
|
+
*/
|
|
1191
|
+
sendRTSPPacket(streamIndex: number, rtpData: Buffer): Promise<number>;
|
|
1192
|
+
/**
|
|
1193
|
+
* Send RTP packet to RTSP stream (supports both TCP and UDP) synchronously.
|
|
1194
|
+
* Synchronous version of sendRTSPPacket.
|
|
1195
|
+
*
|
|
1196
|
+
* Automatically handles transport-specific packet formatting:
|
|
1197
|
+
* - TCP: Sends with interleaved header ($channelId + length + RTP)
|
|
1198
|
+
* - UDP: Sends raw RTP packet directly to UDP socket
|
|
1199
|
+
*
|
|
1200
|
+
* Used for backchannel/talkback audio streaming.
|
|
1201
|
+
* Only works with RTSP input contexts.
|
|
1202
|
+
*
|
|
1203
|
+
* @param streamIndex - RTSP stream index
|
|
1204
|
+
*
|
|
1205
|
+
* @param rtpData - Raw RTP packet data (12-byte header + payload)
|
|
1206
|
+
*
|
|
1207
|
+
* @returns Number of bytes written on success, negative AVERROR on failure
|
|
1208
|
+
*
|
|
1209
|
+
* @example
|
|
1210
|
+
* ```typescript
|
|
1211
|
+
* // Get backchannel stream info
|
|
1212
|
+
* const streams = ctx.getRTSPStreamInfo();
|
|
1213
|
+
* const backchannel = streams.find(s => s.direction === 'sendonly');
|
|
1214
|
+
*
|
|
1215
|
+
* if (backchannel) {
|
|
1216
|
+
* // Send to camera (works with both TCP and UDP)
|
|
1217
|
+
* const ret = ctx.sendRTSPPacketSync(backchannel.streamIndex, rtpPacket);
|
|
1218
|
+
* if (ret < 0) {
|
|
1219
|
+
* throw new Error(`Failed to send: ${ret}`);
|
|
1220
|
+
* }
|
|
1221
|
+
* }
|
|
1222
|
+
* ```
|
|
1223
|
+
*
|
|
1224
|
+
* @see {@link sendRTSPPacket} For asynchronous version
|
|
1225
|
+
* @see {@link getRTSPStreamInfo} For getting stream info and transport type
|
|
1226
|
+
*/
|
|
1227
|
+
sendRTSPPacketSync(streamIndex: number, rtpData: Buffer): number;
|
|
1228
|
+
/**
|
|
1229
|
+
* Get the underlying native FormatContext object.
|
|
1230
|
+
*
|
|
1231
|
+
* @returns The native FormatContext binding object
|
|
1232
|
+
*
|
|
1233
|
+
* @internal
|
|
1234
|
+
*/
|
|
1235
|
+
getNative(): NativeFormatContext;
|
|
1236
|
+
/**
|
|
1237
|
+
* Dispose of the format context.
|
|
1238
|
+
*
|
|
1239
|
+
* Implements the AsyncDisposable interface for automatic cleanup.
|
|
1240
|
+
* Closes input/output and frees resources.
|
|
1241
|
+
*
|
|
1242
|
+
* @returns Promise that resolves when disposed
|
|
1243
|
+
*
|
|
1244
|
+
* @example
|
|
1245
|
+
* ```typescript
|
|
1246
|
+
* {
|
|
1247
|
+
* await using ctx = new FormatContext();
|
|
1248
|
+
* await ctx.openInput('input.mp4');
|
|
1249
|
+
* // Use context...
|
|
1250
|
+
* } // Automatically closed and freed
|
|
1251
|
+
* ```
|
|
1252
|
+
*/
|
|
1253
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
1254
|
+
}
|