node-av 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -2
- package/binding.gyp +12 -0
- package/dist/api/bitstream-filter.d.ts +132 -0
- package/dist/api/bitstream-filter.js +198 -0
- package/dist/api/bitstream-filter.js.map +1 -1
- package/dist/api/decoder.d.ts +145 -0
- package/dist/api/decoder.js +225 -0
- package/dist/api/decoder.js.map +1 -1
- package/dist/api/encoder.d.ts +206 -0
- package/dist/api/encoder.js +315 -0
- package/dist/api/encoder.js.map +1 -1
- package/dist/api/filter-presets.d.ts +92 -0
- package/dist/api/filter-presets.js +92 -0
- package/dist/api/filter-presets.js.map +1 -1
- package/dist/api/filter.d.ts +225 -0
- package/dist/api/filter.js +363 -0
- package/dist/api/filter.js.map +1 -1
- package/dist/api/hardware.d.ts +17 -0
- package/dist/api/hardware.js +17 -0
- package/dist/api/hardware.js.map +1 -1
- package/dist/api/io-stream.d.ts +6 -0
- package/dist/api/io-stream.js +2 -0
- package/dist/api/io-stream.js.map +1 -1
- package/dist/api/media-input.d.ts +207 -1
- package/dist/api/media-input.js +353 -0
- package/dist/api/media-input.js.map +1 -1
- package/dist/api/media-output.d.ts +132 -1
- package/dist/api/media-output.js +339 -0
- package/dist/api/media-output.js.map +1 -1
- package/dist/api/pipeline.d.ts +65 -0
- package/dist/api/pipeline.js +61 -0
- package/dist/api/pipeline.js.map +1 -1
- package/dist/api/types.d.ts +7 -0
- package/dist/api/utils.js +2 -0
- package/dist/api/utils.js.map +1 -1
- package/dist/lib/audio-fifo.d.ts +103 -0
- package/dist/lib/audio-fifo.js +109 -0
- package/dist/lib/audio-fifo.js.map +1 -1
- package/dist/lib/binding.d.ts +1 -0
- package/dist/lib/binding.js.map +1 -1
- package/dist/lib/bitstream-filter-context.d.ts +79 -0
- package/dist/lib/bitstream-filter-context.js +83 -0
- package/dist/lib/bitstream-filter-context.js.map +1 -1
- package/dist/lib/bitstream-filter.d.ts +2 -0
- package/dist/lib/bitstream-filter.js +2 -0
- package/dist/lib/bitstream-filter.js.map +1 -1
- package/dist/lib/codec-context.d.ts +168 -0
- package/dist/lib/codec-context.js +178 -0
- package/dist/lib/codec-context.js.map +1 -1
- package/dist/lib/codec-parameters.d.ts +3 -0
- package/dist/lib/codec-parameters.js +3 -0
- package/dist/lib/codec-parameters.js.map +1 -1
- package/dist/lib/codec-parser.d.ts +6 -0
- package/dist/lib/codec-parser.js +6 -0
- package/dist/lib/codec-parser.js.map +1 -1
- package/dist/lib/codec.d.ts +12 -0
- package/dist/lib/codec.js +12 -0
- package/dist/lib/codec.js.map +1 -1
- package/dist/lib/dictionary.d.ts +16 -0
- package/dist/lib/dictionary.js +16 -0
- package/dist/lib/dictionary.js.map +1 -1
- package/dist/lib/error.d.ts +8 -0
- package/dist/lib/error.js +9 -0
- package/dist/lib/error.js.map +1 -1
- package/dist/lib/filter-context.d.ts +100 -0
- package/dist/lib/filter-context.js +104 -0
- package/dist/lib/filter-context.js.map +1 -1
- package/dist/lib/filter-graph.d.ts +80 -0
- package/dist/lib/filter-graph.js +84 -0
- package/dist/lib/filter-graph.js.map +1 -1
- package/dist/lib/filter-inout.d.ts +1 -0
- package/dist/lib/filter-inout.js +1 -0
- package/dist/lib/filter-inout.js.map +1 -1
- package/dist/lib/filter.d.ts +2 -0
- package/dist/lib/filter.js +2 -0
- package/dist/lib/filter.js.map +1 -1
- package/dist/lib/format-context.d.ts +338 -2
- package/dist/lib/format-context.js +355 -3
- package/dist/lib/format-context.js.map +1 -1
- package/dist/lib/frame.d.ts +41 -0
- package/dist/lib/frame.js +43 -0
- package/dist/lib/frame.js.map +1 -1
- package/dist/lib/hardware-device-context.d.ts +8 -0
- package/dist/lib/hardware-device-context.js +8 -0
- package/dist/lib/hardware-device-context.js.map +1 -1
- package/dist/lib/hardware-frames-context.d.ts +55 -0
- package/dist/lib/hardware-frames-context.js +57 -0
- package/dist/lib/hardware-frames-context.js.map +1 -1
- package/dist/lib/input-format.d.ts +43 -3
- package/dist/lib/input-format.js +48 -0
- package/dist/lib/input-format.js.map +1 -1
- package/dist/lib/io-context.d.ts +212 -0
- package/dist/lib/io-context.js +228 -0
- package/dist/lib/io-context.js.map +1 -1
- package/dist/lib/log.d.ts +2 -0
- package/dist/lib/log.js +2 -0
- package/dist/lib/log.js.map +1 -1
- package/dist/lib/native-types.d.ts +39 -1
- package/dist/lib/option.d.ts +90 -0
- package/dist/lib/option.js +97 -0
- package/dist/lib/option.js.map +1 -1
- package/dist/lib/output-format.d.ts +4 -0
- package/dist/lib/output-format.js +4 -0
- package/dist/lib/output-format.js.map +1 -1
- package/dist/lib/packet.d.ts +7 -0
- package/dist/lib/packet.js +7 -0
- package/dist/lib/packet.js.map +1 -1
- package/dist/lib/rational.d.ts +1 -0
- package/dist/lib/rational.js +1 -0
- package/dist/lib/rational.js.map +1 -1
- package/dist/lib/software-resample-context.d.ts +64 -0
- package/dist/lib/software-resample-context.js +66 -0
- package/dist/lib/software-resample-context.js.map +1 -1
- package/dist/lib/software-scale-context.d.ts +98 -0
- package/dist/lib/software-scale-context.js +102 -0
- package/dist/lib/software-scale-context.js.map +1 -1
- package/dist/lib/stream.d.ts +1 -0
- package/dist/lib/stream.js +1 -0
- package/dist/lib/stream.js.map +1 -1
- package/dist/lib/utilities.d.ts +60 -0
- package/dist/lib/utilities.js +60 -0
- package/dist/lib/utilities.js.map +1 -1
- package/package.json +13 -13
package/dist/api/media-input.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { closeSync, openSync, readSync } from 'fs';
|
|
1
2
|
import { open } from 'fs/promises';
|
|
2
3
|
import { resolve } from 'path';
|
|
3
4
|
import { AVFLAG_NONE, AVMEDIA_TYPE_AUDIO, AVMEDIA_TYPE_VIDEO } from '../constants/constants.js';
|
|
@@ -48,6 +49,7 @@ export class MediaInput {
|
|
|
48
49
|
ioContext;
|
|
49
50
|
/**
|
|
50
51
|
* @param formatContext - Opened format context
|
|
52
|
+
*
|
|
51
53
|
* @internal
|
|
52
54
|
*/
|
|
53
55
|
constructor(formatContext) {
|
|
@@ -62,6 +64,7 @@ export class MediaInput {
|
|
|
62
64
|
* Direct mapping to av_probe_input_format().
|
|
63
65
|
*
|
|
64
66
|
* @param input - File path or buffer to probe
|
|
67
|
+
*
|
|
65
68
|
* @returns Format information or null if unrecognized
|
|
66
69
|
*
|
|
67
70
|
* @example
|
|
@@ -133,6 +136,89 @@ export class MediaInput {
|
|
|
133
136
|
return null;
|
|
134
137
|
}
|
|
135
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Probe media format without fully opening the file synchronously.
|
|
141
|
+
* Synchronous version of probeFormat.
|
|
142
|
+
*
|
|
143
|
+
* Detects format by analyzing file headers and content.
|
|
144
|
+
* Useful for format validation before processing.
|
|
145
|
+
*
|
|
146
|
+
* Direct mapping to av_probe_input_format().
|
|
147
|
+
*
|
|
148
|
+
* @param input - File path or buffer to probe
|
|
149
|
+
*
|
|
150
|
+
* @returns Format information or null if unrecognized
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* const info = MediaInput.probeFormatSync('video.mp4');
|
|
155
|
+
* if (info) {
|
|
156
|
+
* console.log(`Format: ${info.format}`);
|
|
157
|
+
* console.log(`Confidence: ${info.confidence}%`);
|
|
158
|
+
* }
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* // Probe from buffer
|
|
164
|
+
* const buffer = fs.readFileSync('video.webm');
|
|
165
|
+
* const info = MediaInput.probeFormatSync(buffer);
|
|
166
|
+
* console.log(`MIME type: ${info?.mimeType}`);
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* @see {@link probeFormat} For async version
|
|
170
|
+
*/
|
|
171
|
+
static probeFormatSync(input) {
|
|
172
|
+
try {
|
|
173
|
+
if (Buffer.isBuffer(input)) {
|
|
174
|
+
// Probe from buffer
|
|
175
|
+
const format = InputFormat.probe(input);
|
|
176
|
+
if (!format) {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
format: format.name ?? 'unknown',
|
|
181
|
+
longName: format.longName ?? undefined,
|
|
182
|
+
extensions: format.extensions ?? undefined,
|
|
183
|
+
mimeType: format.mimeType ?? undefined,
|
|
184
|
+
confidence: 100, // Direct probe always has high confidence
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
// For files, read first part and probe
|
|
189
|
+
let fd;
|
|
190
|
+
try {
|
|
191
|
+
fd = openSync(input, 'r');
|
|
192
|
+
// Read first 64KB for probing
|
|
193
|
+
const buffer = Buffer.alloc(65536);
|
|
194
|
+
const bytesRead = readSync(fd, buffer, 0, 65536, 0);
|
|
195
|
+
const probeBuffer = buffer.subarray(0, bytesRead);
|
|
196
|
+
const format = InputFormat.probe(probeBuffer, input);
|
|
197
|
+
if (!format) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
format: format.name ?? 'unknown',
|
|
202
|
+
longName: format.longName ?? undefined,
|
|
203
|
+
extensions: format.extensions ?? undefined,
|
|
204
|
+
mimeType: format.mimeType ?? undefined,
|
|
205
|
+
confidence: 90, // File-based probe with filename hint
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
// If file reading fails, return null
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
finally {
|
|
213
|
+
if (fd !== undefined)
|
|
214
|
+
closeSync(fd);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
136
222
|
static async open(input, options = {}) {
|
|
137
223
|
// Check if input is raw data
|
|
138
224
|
if (typeof input === 'object' && 'type' in input && ('width' in input || 'sampleRate' in input)) {
|
|
@@ -231,6 +317,104 @@ export class MediaInput {
|
|
|
231
317
|
}
|
|
232
318
|
}
|
|
233
319
|
}
|
|
320
|
+
static openSync(input, options = {}) {
|
|
321
|
+
// Check if input is raw data
|
|
322
|
+
if (typeof input === 'object' && 'type' in input && ('width' in input || 'sampleRate' in input)) {
|
|
323
|
+
// Build options for raw data
|
|
324
|
+
const rawOptions = {
|
|
325
|
+
bufferSize: options.bufferSize,
|
|
326
|
+
format: options.format ?? (input.type === 'video' ? 'rawvideo' : 's16le'),
|
|
327
|
+
options: {
|
|
328
|
+
...options.options,
|
|
329
|
+
},
|
|
330
|
+
};
|
|
331
|
+
if (input.type === 'video') {
|
|
332
|
+
rawOptions.options = {
|
|
333
|
+
...rawOptions.options,
|
|
334
|
+
video_size: `${input.width}x${input.height}`,
|
|
335
|
+
pixel_format: avGetPixFmtName(input.pixelFormat) ?? 'yuv420p',
|
|
336
|
+
framerate: new Rational(input.frameRate.num, input.frameRate.den).toString(),
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
rawOptions.options = {
|
|
341
|
+
...rawOptions.options,
|
|
342
|
+
sample_rate: input.sampleRate,
|
|
343
|
+
channels: input.channels,
|
|
344
|
+
sample_fmt: avGetSampleFmtName(input.sampleFormat) ?? 's16le',
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
// Open with the raw data source
|
|
348
|
+
return MediaInput.openSync(input.input, rawOptions);
|
|
349
|
+
}
|
|
350
|
+
// Original implementation for non-raw data
|
|
351
|
+
const formatContext = new FormatContext();
|
|
352
|
+
let ioContext;
|
|
353
|
+
let optionsDict = null;
|
|
354
|
+
let inputFormat = null;
|
|
355
|
+
try {
|
|
356
|
+
// Create options dictionary if options are provided
|
|
357
|
+
if (options.options) {
|
|
358
|
+
optionsDict = Dictionary.fromObject(options.options);
|
|
359
|
+
}
|
|
360
|
+
// Find input format if specified
|
|
361
|
+
if (options.format) {
|
|
362
|
+
inputFormat = InputFormat.findInputFormat(options.format);
|
|
363
|
+
if (!inputFormat) {
|
|
364
|
+
throw new Error(`Input format '${options.format}' not found`);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (typeof input === 'string') {
|
|
368
|
+
// File path or URL - resolve relative paths to absolute
|
|
369
|
+
// Check if it's a URL (starts with protocol://) or a file path
|
|
370
|
+
const isUrl = /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(input);
|
|
371
|
+
const resolvedInput = isUrl ? input : resolve(input);
|
|
372
|
+
const ret = formatContext.openInputSync(resolvedInput, inputFormat, optionsDict);
|
|
373
|
+
FFmpegError.throwIfError(ret, 'Failed to open input');
|
|
374
|
+
}
|
|
375
|
+
else if (Buffer.isBuffer(input)) {
|
|
376
|
+
// Validate buffer is not empty
|
|
377
|
+
if (input.length === 0) {
|
|
378
|
+
throw new Error('Cannot open media from empty buffer');
|
|
379
|
+
}
|
|
380
|
+
// From buffer - allocate context first for custom I/O
|
|
381
|
+
formatContext.allocContext();
|
|
382
|
+
ioContext = IOStream.create(input, { bufferSize: options.bufferSize });
|
|
383
|
+
formatContext.pb = ioContext;
|
|
384
|
+
const ret = formatContext.openInputSync('', inputFormat, optionsDict);
|
|
385
|
+
FFmpegError.throwIfError(ret, 'Failed to open input from buffer');
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
throw new TypeError('Invalid input type. Expected file path, URL, or Buffer');
|
|
389
|
+
}
|
|
390
|
+
// Find stream information
|
|
391
|
+
const ret = formatContext.findStreamInfoSync(null);
|
|
392
|
+
FFmpegError.throwIfError(ret, 'Failed to find stream info');
|
|
393
|
+
const mediaInput = new MediaInput(formatContext);
|
|
394
|
+
mediaInput.ioContext = ioContext;
|
|
395
|
+
// After successful creation, streams should be available
|
|
396
|
+
mediaInput._streams = formatContext.streams ?? [];
|
|
397
|
+
return mediaInput;
|
|
398
|
+
}
|
|
399
|
+
catch (error) {
|
|
400
|
+
// Clean up only on error
|
|
401
|
+
if (ioContext) {
|
|
402
|
+
// Clear the pb reference first
|
|
403
|
+
formatContext.pb = null;
|
|
404
|
+
// Free the IOContext
|
|
405
|
+
ioContext.freeContext();
|
|
406
|
+
}
|
|
407
|
+
// Clean up FormatContext
|
|
408
|
+
formatContext.closeInputSync();
|
|
409
|
+
throw error;
|
|
410
|
+
}
|
|
411
|
+
finally {
|
|
412
|
+
// Clean up options dictionary
|
|
413
|
+
if (optionsDict) {
|
|
414
|
+
optionsDict.free();
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
234
418
|
/**
|
|
235
419
|
* Get all streams in the media.
|
|
236
420
|
*
|
|
@@ -322,6 +506,7 @@ export class MediaInput {
|
|
|
322
506
|
* Returns undefined if stream doesn't exist.
|
|
323
507
|
*
|
|
324
508
|
* @param index - Video stream index (default: 0)
|
|
509
|
+
*
|
|
325
510
|
* @returns Video stream or undefined
|
|
326
511
|
*
|
|
327
512
|
* @example
|
|
@@ -352,6 +537,7 @@ export class MediaInput {
|
|
|
352
537
|
* Returns undefined if stream doesn't exist.
|
|
353
538
|
*
|
|
354
539
|
* @param index - Audio stream index (default: 0)
|
|
540
|
+
*
|
|
355
541
|
* @returns Audio stream or undefined
|
|
356
542
|
*
|
|
357
543
|
* @example
|
|
@@ -384,6 +570,7 @@ export class MediaInput {
|
|
|
384
570
|
* Direct mapping to av_find_best_stream().
|
|
385
571
|
*
|
|
386
572
|
* @param type - Media type to find
|
|
573
|
+
*
|
|
387
574
|
* @returns Best stream or undefined if not found
|
|
388
575
|
*
|
|
389
576
|
* @example
|
|
@@ -413,7 +600,9 @@ export class MediaInput {
|
|
|
413
600
|
* Direct mapping to av_read_frame().
|
|
414
601
|
*
|
|
415
602
|
* @param index - Optional stream index to filter
|
|
603
|
+
*
|
|
416
604
|
* @yields {Packet} Demuxed packets (must be freed by caller)
|
|
605
|
+
*
|
|
417
606
|
* @throws {Error} If packet cloning fails
|
|
418
607
|
*
|
|
419
608
|
* @example
|
|
@@ -468,6 +657,74 @@ export class MediaInput {
|
|
|
468
657
|
packet.free();
|
|
469
658
|
}
|
|
470
659
|
}
|
|
660
|
+
/**
|
|
661
|
+
* Read packets from media as generator synchronously.
|
|
662
|
+
* Synchronous version of packets.
|
|
663
|
+
*
|
|
664
|
+
* Yields demuxed packets for processing.
|
|
665
|
+
* Automatically handles packet memory management.
|
|
666
|
+
* Optionally filters packets by stream index.
|
|
667
|
+
*
|
|
668
|
+
* Direct mapping to av_read_frame().
|
|
669
|
+
*
|
|
670
|
+
* @param index - Optional stream index to filter
|
|
671
|
+
*
|
|
672
|
+
* @yields {Packet} Demuxed packets (must be freed by caller)
|
|
673
|
+
*
|
|
674
|
+
* @throws {Error} If packet cloning fails
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
* ```typescript
|
|
678
|
+
* // Read all packets
|
|
679
|
+
* for (const packet of input.packetsSync()) {
|
|
680
|
+
* console.log(`Packet: stream=${packet.streamIndex}, pts=${packet.pts}`);
|
|
681
|
+
* packet.free();
|
|
682
|
+
* }
|
|
683
|
+
* ```
|
|
684
|
+
*
|
|
685
|
+
* @example
|
|
686
|
+
* ```typescript
|
|
687
|
+
* // Read only video packets
|
|
688
|
+
* const videoStream = input.video();
|
|
689
|
+
* for (const packet of input.packetsSync(videoStream.index)) {
|
|
690
|
+
* // Process video packet
|
|
691
|
+
* packet.free();
|
|
692
|
+
* }
|
|
693
|
+
* ```
|
|
694
|
+
*
|
|
695
|
+
* @see {@link packets} For async version
|
|
696
|
+
*/
|
|
697
|
+
*packetsSync(index) {
|
|
698
|
+
const packet = new Packet();
|
|
699
|
+
packet.alloc();
|
|
700
|
+
try {
|
|
701
|
+
while (true) {
|
|
702
|
+
const ret = this.formatContext.readFrameSync(packet);
|
|
703
|
+
if (ret < 0) {
|
|
704
|
+
// End of file or error
|
|
705
|
+
break;
|
|
706
|
+
}
|
|
707
|
+
if (index === undefined || packet.streamIndex === index) {
|
|
708
|
+
// Clone the packet for the user
|
|
709
|
+
// This creates a new Packet object that shares the same data buffer
|
|
710
|
+
// through reference counting. The data won't be freed until both
|
|
711
|
+
// the original and the clone are unreferenced.
|
|
712
|
+
const cloned = packet.clone();
|
|
713
|
+
if (!cloned) {
|
|
714
|
+
throw new Error('Failed to clone packet (out of memory)');
|
|
715
|
+
}
|
|
716
|
+
yield cloned;
|
|
717
|
+
}
|
|
718
|
+
// Unreference the original packet's data buffer
|
|
719
|
+
// This allows us to reuse the packet object for the next readFrame()
|
|
720
|
+
// The data itself is still alive because the clone has a reference
|
|
721
|
+
packet.unref();
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
finally {
|
|
725
|
+
packet.free();
|
|
726
|
+
}
|
|
727
|
+
}
|
|
471
728
|
/**
|
|
472
729
|
* Seek to timestamp in media.
|
|
473
730
|
*
|
|
@@ -477,8 +734,11 @@ export class MediaInput {
|
|
|
477
734
|
* Direct mapping to av_seek_frame().
|
|
478
735
|
*
|
|
479
736
|
* @param timestamp - Target position in seconds
|
|
737
|
+
*
|
|
480
738
|
* @param streamIndex - Stream index or -1 for global (default: -1)
|
|
739
|
+
*
|
|
481
740
|
* @param flags - Seek flags (default: AVFLAG_NONE)
|
|
741
|
+
*
|
|
482
742
|
* @returns 0 on success, negative on error
|
|
483
743
|
*
|
|
484
744
|
* @example
|
|
@@ -503,6 +763,45 @@ export class MediaInput {
|
|
|
503
763
|
const ts = BigInt(Math.floor(timestamp * 1000000));
|
|
504
764
|
return this.formatContext.seekFrame(streamIndex, ts, flags);
|
|
505
765
|
}
|
|
766
|
+
/**
|
|
767
|
+
* Seek to timestamp in media synchronously.
|
|
768
|
+
* Synchronous version of seek.
|
|
769
|
+
*
|
|
770
|
+
* Seeks to the specified position in seconds.
|
|
771
|
+
* Can seek in specific stream or globally.
|
|
772
|
+
*
|
|
773
|
+
* Direct mapping to av_seek_frame().
|
|
774
|
+
*
|
|
775
|
+
* @param timestamp - Target position in seconds
|
|
776
|
+
*
|
|
777
|
+
* @param streamIndex - Stream index or -1 for global (default: -1)
|
|
778
|
+
*
|
|
779
|
+
* @param flags - Seek flags (default: AVFLAG_NONE)
|
|
780
|
+
*
|
|
781
|
+
* @returns 0 on success, negative on error
|
|
782
|
+
*
|
|
783
|
+
* @example
|
|
784
|
+
* ```typescript
|
|
785
|
+
* // Seek to 30 seconds
|
|
786
|
+
* const ret = input.seekSync(30);
|
|
787
|
+
* FFmpegError.throwIfError(ret, 'seek failed');
|
|
788
|
+
* ```
|
|
789
|
+
*
|
|
790
|
+
* @example
|
|
791
|
+
* ```typescript
|
|
792
|
+
* import { AVSEEK_FLAG_BACKWARD } from 'node-av/constants';
|
|
793
|
+
*
|
|
794
|
+
* // Seek to keyframe before 60 seconds
|
|
795
|
+
* input.seekSync(60, -1, AVSEEK_FLAG_BACKWARD);
|
|
796
|
+
* ```
|
|
797
|
+
*
|
|
798
|
+
* @see {@link seek} For async version
|
|
799
|
+
*/
|
|
800
|
+
seekSync(timestamp, streamIndex = -1, flags = AVFLAG_NONE) {
|
|
801
|
+
// Convert seconds to AV_TIME_BASE
|
|
802
|
+
const ts = BigInt(Math.floor(timestamp * 1000000));
|
|
803
|
+
return this.formatContext.seekFrameSync(streamIndex, ts, flags);
|
|
804
|
+
}
|
|
506
805
|
/**
|
|
507
806
|
* Close media input and free resources.
|
|
508
807
|
*
|
|
@@ -537,6 +836,41 @@ export class MediaInput {
|
|
|
537
836
|
this.ioContext = undefined;
|
|
538
837
|
}
|
|
539
838
|
}
|
|
839
|
+
/**
|
|
840
|
+
* Close media input and free resources synchronously.
|
|
841
|
+
* Synchronous version of close.
|
|
842
|
+
*
|
|
843
|
+
* Releases format context and I/O context.
|
|
844
|
+
* Safe to call multiple times.
|
|
845
|
+
* Automatically called by Symbol.dispose.
|
|
846
|
+
*
|
|
847
|
+
* Direct mapping to avformat_close_input().
|
|
848
|
+
*
|
|
849
|
+
* @example
|
|
850
|
+
* ```typescript
|
|
851
|
+
* const input = MediaInput.openSync('video.mp4');
|
|
852
|
+
* try {
|
|
853
|
+
* // Use input
|
|
854
|
+
* } finally {
|
|
855
|
+
* input.closeSync();
|
|
856
|
+
* }
|
|
857
|
+
* ```
|
|
858
|
+
*
|
|
859
|
+
* @see {@link close} For async version
|
|
860
|
+
*/
|
|
861
|
+
closeSync() {
|
|
862
|
+
// IMPORTANT: Clear pb reference FIRST to prevent use-after-free
|
|
863
|
+
if (this.ioContext) {
|
|
864
|
+
this.formatContext.pb = null;
|
|
865
|
+
}
|
|
866
|
+
// Close FormatContext
|
|
867
|
+
this.formatContext.closeInputSync();
|
|
868
|
+
// NOW we can safely free the IOContext
|
|
869
|
+
if (this.ioContext) {
|
|
870
|
+
this.ioContext.freeContext();
|
|
871
|
+
this.ioContext = undefined;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
540
874
|
/**
|
|
541
875
|
* Get underlying format context.
|
|
542
876
|
*
|
|
@@ -568,5 +902,24 @@ export class MediaInput {
|
|
|
568
902
|
async [Symbol.asyncDispose]() {
|
|
569
903
|
await this.close();
|
|
570
904
|
}
|
|
905
|
+
/**
|
|
906
|
+
* Dispose of media input synchronously.
|
|
907
|
+
*
|
|
908
|
+
* Implements Disposable interface for automatic cleanup.
|
|
909
|
+
* Equivalent to calling closeSync().
|
|
910
|
+
*
|
|
911
|
+
* @example
|
|
912
|
+
* ```typescript
|
|
913
|
+
* {
|
|
914
|
+
* using input = MediaInput.openSync('video.mp4');
|
|
915
|
+
* // Process media...
|
|
916
|
+
* } // Automatically closed
|
|
917
|
+
* ```
|
|
918
|
+
*
|
|
919
|
+
* @see {@link closeSync} For manual cleanup
|
|
920
|
+
*/
|
|
921
|
+
[Symbol.dispose]() {
|
|
922
|
+
this.closeSync();
|
|
923
|
+
}
|
|
571
924
|
}
|
|
572
925
|
//# sourceMappingURL=media-input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media-input.js","sourceRoot":"","sources":["../../src/api/media-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,C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,CAAC;YAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC7B,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,SAAS;QACP,gEAAgE;QAChE,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,IAAI,CAAC,aAAa,CAAC,EAAE,GAAG,IAAI,CAAC;QAC/B,CAAC;QAED,sBAAsB;QACtB,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;QAEpC,uCAAuC;QACvC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;YAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC7B,CAAC;IACH,CAAC;IAED;;;;;;;;OAQG;IACH,gBAAgB;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -59,7 +59,7 @@ export interface StreamDescription {
|
|
|
59
59
|
* @see {@link Encoder} For encoding frames to packets
|
|
60
60
|
* @see {@link FormatContext} For low-level API
|
|
61
61
|
*/
|
|
62
|
-
export declare class MediaOutput implements AsyncDisposable {
|
|
62
|
+
export declare class MediaOutput implements AsyncDisposable, Disposable {
|
|
63
63
|
private formatContext;
|
|
64
64
|
private streams;
|
|
65
65
|
private ioContext?;
|
|
@@ -81,7 +81,9 @@ export declare class MediaOutput implements AsyncDisposable {
|
|
|
81
81
|
* Direct mapping to avformat_alloc_output_context2() and avio_open2().
|
|
82
82
|
*
|
|
83
83
|
* @param target - File path, URL, or I/O callbacks
|
|
84
|
+
*
|
|
84
85
|
* @param options - Output configuration options
|
|
86
|
+
*
|
|
85
87
|
* @returns Opened media output instance
|
|
86
88
|
*
|
|
87
89
|
* @throws {Error} If format required for custom I/O
|
|
@@ -126,6 +128,43 @@ export declare class MediaOutput implements AsyncDisposable {
|
|
|
126
128
|
* @see {@link IOOutputCallbacks} For custom I/O interface
|
|
127
129
|
*/
|
|
128
130
|
static open(target: string | IOOutputCallbacks, options?: MediaOutputOptions): Promise<MediaOutput>;
|
|
131
|
+
/**
|
|
132
|
+
* Open media output for writing synchronously.
|
|
133
|
+
* Synchronous version of open.
|
|
134
|
+
*
|
|
135
|
+
* Creates and configures output context for muxing.
|
|
136
|
+
* Automatically creates directories for file output.
|
|
137
|
+
* Supports files, URLs, and custom I/O callbacks.
|
|
138
|
+
*
|
|
139
|
+
* Direct mapping to avformat_alloc_output_context2() and avio_open2().
|
|
140
|
+
*
|
|
141
|
+
* @param target - File path, URL, or I/O callbacks
|
|
142
|
+
*
|
|
143
|
+
* @param options - Output configuration options
|
|
144
|
+
*
|
|
145
|
+
* @returns Opened media output instance
|
|
146
|
+
*
|
|
147
|
+
* @throws {Error} If format required for custom I/O
|
|
148
|
+
*
|
|
149
|
+
* @throws {FFmpegError} If allocation or opening fails
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* // Create file output
|
|
154
|
+
* using output = MediaOutput.openSync('output.mp4');
|
|
155
|
+
* ```
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* // Create output with specific format
|
|
160
|
+
* using output = MediaOutput.openSync('output.ts', {
|
|
161
|
+
* format: 'mpegts'
|
|
162
|
+
* });
|
|
163
|
+
* ```
|
|
164
|
+
*
|
|
165
|
+
* @see {@link open} For async version
|
|
166
|
+
*/
|
|
167
|
+
static openSync(target: string | IOOutputCallbacks, options?: MediaOutputOptions): MediaOutput;
|
|
129
168
|
/**
|
|
130
169
|
* Add a stream to the output.
|
|
131
170
|
*
|
|
@@ -140,8 +179,11 @@ export declare class MediaOutput implements AsyncDisposable {
|
|
|
140
179
|
* Direct mapping to avformat_new_stream().
|
|
141
180
|
*
|
|
142
181
|
* @param source - Encoder or stream to add
|
|
182
|
+
*
|
|
143
183
|
* @param options - Stream configuration options
|
|
184
|
+
*
|
|
144
185
|
* @param options.timeBase - Optional custom timebase for the stream
|
|
186
|
+
*
|
|
145
187
|
* @returns Stream index for packet writing
|
|
146
188
|
*
|
|
147
189
|
* @throws {Error} If called after packets have been written or output closed
|
|
@@ -183,7 +225,9 @@ export declare class MediaOutput implements AsyncDisposable {
|
|
|
183
225
|
* Direct mapping to avformat_write_header() (on first packet) and av_interleaved_write_frame().
|
|
184
226
|
*
|
|
185
227
|
* @param packet - Packet to write
|
|
228
|
+
*
|
|
186
229
|
* @param streamIndex - Target stream index
|
|
230
|
+
*
|
|
187
231
|
* @throws {Error} If stream invalid or encoder not initialized
|
|
188
232
|
*
|
|
189
233
|
* @throws {FFmpegError} If write fails
|
|
@@ -212,6 +256,54 @@ export declare class MediaOutput implements AsyncDisposable {
|
|
|
212
256
|
* @see {@link addStream} For adding streams
|
|
213
257
|
*/
|
|
214
258
|
writePacket(packet: Packet, streamIndex: number): Promise<void>;
|
|
259
|
+
/**
|
|
260
|
+
* Write a packet to the output synchronously.
|
|
261
|
+
* Synchronous version of writePacket.
|
|
262
|
+
*
|
|
263
|
+
* Writes muxed packet to the specified stream.
|
|
264
|
+
* Automatically handles:
|
|
265
|
+
* - Stream initialization on first packet (lazy initialization)
|
|
266
|
+
* - Codec parameter configuration from encoder or input stream
|
|
267
|
+
* - Header writing on first packet
|
|
268
|
+
* - Timestamp rescaling between source and output timebases
|
|
269
|
+
*
|
|
270
|
+
* For encoder sources, the encoder must have processed at least one frame
|
|
271
|
+
* before packets can be written (encoder must be initialized).
|
|
272
|
+
*
|
|
273
|
+
* Direct mapping to avformat_write_header() (on first packet) and av_interleaved_write_frame().
|
|
274
|
+
*
|
|
275
|
+
* @param packet - Packet to write
|
|
276
|
+
*
|
|
277
|
+
* @param streamIndex - Target stream index
|
|
278
|
+
*
|
|
279
|
+
* @throws {Error} If stream invalid or encoder not initialized
|
|
280
|
+
*
|
|
281
|
+
* @throws {FFmpegError} If write fails
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```typescript
|
|
285
|
+
* // Write encoded packet - header written automatically on first packet
|
|
286
|
+
* const packet = encoder.encodeSync(frame);
|
|
287
|
+
* if (packet) {
|
|
288
|
+
* output.writePacketSync(packet, videoIdx);
|
|
289
|
+
* packet.free();
|
|
290
|
+
* }
|
|
291
|
+
* ```
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* ```typescript
|
|
295
|
+
* // Stream copy with packet processing
|
|
296
|
+
* for (const packet of input.packetsSync()) {
|
|
297
|
+
* if (packet.streamIndex === inputVideoIdx) {
|
|
298
|
+
* output.writePacketSync(packet, outputVideoIdx);
|
|
299
|
+
* }
|
|
300
|
+
* packet.free();
|
|
301
|
+
* }
|
|
302
|
+
* ```
|
|
303
|
+
*
|
|
304
|
+
* @see {@link writePacket} For async version
|
|
305
|
+
*/
|
|
306
|
+
writePacketSync(packet: Packet, streamIndex: number): void;
|
|
215
307
|
/**
|
|
216
308
|
* Close media output and free resources.
|
|
217
309
|
*
|
|
@@ -233,6 +325,28 @@ export declare class MediaOutput implements AsyncDisposable {
|
|
|
233
325
|
* @see {@link Symbol.asyncDispose} For automatic cleanup
|
|
234
326
|
*/
|
|
235
327
|
close(): Promise<void>;
|
|
328
|
+
/**
|
|
329
|
+
* Close media output and free resources synchronously.
|
|
330
|
+
* Synchronous version of close.
|
|
331
|
+
*
|
|
332
|
+
* Automatically writes trailer if header was written.
|
|
333
|
+
* Closes the output file and releases all resources.
|
|
334
|
+
* Safe to call multiple times.
|
|
335
|
+
* Automatically called by Symbol.dispose.
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
* ```typescript
|
|
339
|
+
* const output = MediaOutput.openSync('output.mp4');
|
|
340
|
+
* try {
|
|
341
|
+
* // Use output - trailer written automatically on close
|
|
342
|
+
* } finally {
|
|
343
|
+
* output.closeSync();
|
|
344
|
+
* }
|
|
345
|
+
* ```
|
|
346
|
+
*
|
|
347
|
+
* @see {@link close} For async version
|
|
348
|
+
*/
|
|
349
|
+
closeSync(): void;
|
|
236
350
|
/**
|
|
237
351
|
* Get underlying format context.
|
|
238
352
|
*
|
|
@@ -260,4 +374,21 @@ export declare class MediaOutput implements AsyncDisposable {
|
|
|
260
374
|
* @see {@link close} For manual cleanup
|
|
261
375
|
*/
|
|
262
376
|
[Symbol.asyncDispose](): Promise<void>;
|
|
377
|
+
/**
|
|
378
|
+
* Dispose of media output synchronously.
|
|
379
|
+
*
|
|
380
|
+
* Implements Disposable interface for automatic cleanup.
|
|
381
|
+
* Equivalent to calling closeSync().
|
|
382
|
+
*
|
|
383
|
+
* @example
|
|
384
|
+
* ```typescript
|
|
385
|
+
* {
|
|
386
|
+
* using output = MediaOutput.openSync('output.mp4');
|
|
387
|
+
* // Use output...
|
|
388
|
+
* } // Automatically closed
|
|
389
|
+
* ```
|
|
390
|
+
*
|
|
391
|
+
* @see {@link closeSync} For manual cleanup
|
|
392
|
+
*/
|
|
393
|
+
[Symbol.dispose](): void;
|
|
263
394
|
}
|