node-av 1.3.0 → 2.0.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 +37 -38
- package/dist/api/bitstream-filter.d.ts +2 -2
- package/dist/api/bitstream-filter.js +2 -2
- package/dist/api/decoder.d.ts +131 -120
- package/dist/api/decoder.js +191 -203
- package/dist/api/decoder.js.map +1 -1
- package/dist/api/encoder.d.ts +135 -77
- package/dist/api/encoder.js +235 -192
- package/dist/api/encoder.js.map +1 -1
- package/dist/api/filter-presets.d.ts +408 -1534
- package/dist/api/filter-presets.js +1005 -2058
- package/dist/api/filter-presets.js.map +1 -1
- package/dist/api/filter.d.ts +160 -165
- package/dist/api/filter.js +294 -374
- package/dist/api/filter.js.map +1 -1
- package/dist/api/hardware.d.ts +8 -31
- package/dist/api/hardware.js +19 -70
- package/dist/api/hardware.js.map +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/media-input.d.ts +1 -1
- package/dist/api/media-input.js +3 -8
- package/dist/api/media-input.js.map +1 -1
- package/dist/api/media-output.d.ts +35 -128
- package/dist/api/media-output.js +136 -208
- package/dist/api/media-output.js.map +1 -1
- package/dist/api/pipeline.d.ts +17 -17
- package/dist/api/pipeline.js +19 -42
- package/dist/api/pipeline.js.map +1 -1
- package/dist/api/types.d.ts +17 -57
- package/dist/lib/dictionary.d.ts +2 -2
- package/dist/lib/dictionary.js +2 -2
- package/dist/lib/dictionary.js.map +1 -1
- package/dist/lib/filter-context.d.ts +19 -2
- package/dist/lib/filter-context.js +15 -0
- package/dist/lib/filter-context.js.map +1 -1
- package/dist/lib/format-context.d.ts +18 -18
- package/dist/lib/format-context.js +20 -20
- package/dist/lib/format-context.js.map +1 -1
- package/dist/lib/frame.d.ts +43 -1
- package/dist/lib/frame.js +53 -0
- package/dist/lib/frame.js.map +1 -1
- package/package.json +17 -17
- package/release_notes.md +0 -29
package/dist/api/media-output.js
CHANGED
|
@@ -7,6 +7,8 @@ import { Encoder } from './encoder.js';
|
|
|
7
7
|
* High-level media output for writing and muxing media files.
|
|
8
8
|
*
|
|
9
9
|
* Provides simplified access to media muxing and file writing operations.
|
|
10
|
+
* Automatically manages header and trailer writing - header is written on first packet,
|
|
11
|
+
* trailer is written on close. Supports lazy initialization for both encoders and streams.
|
|
10
12
|
* Handles stream configuration, packet writing, and format management.
|
|
11
13
|
* Supports files, URLs, and custom I/O with automatic cleanup.
|
|
12
14
|
* Essential component for media encoding pipelines and transcoding.
|
|
@@ -22,14 +24,11 @@ import { Encoder } from './encoder.js';
|
|
|
22
24
|
* const videoIdx = output.addStream(videoEncoder);
|
|
23
25
|
* const audioIdx = output.addStream(audioEncoder);
|
|
24
26
|
*
|
|
25
|
-
* // Write header
|
|
26
|
-
* await output.writeHeader();
|
|
27
|
-
*
|
|
28
|
-
* // Write packets
|
|
27
|
+
* // Write packets - header written automatically on first packet
|
|
29
28
|
* await output.writePacket(packet, videoIdx);
|
|
30
29
|
*
|
|
31
|
-
* //
|
|
32
|
-
* await
|
|
30
|
+
* // Close - trailer written automatically
|
|
31
|
+
* // (automatic with await using)
|
|
33
32
|
* ```
|
|
34
33
|
*
|
|
35
34
|
* @example
|
|
@@ -40,8 +39,8 @@ import { Encoder } from './encoder.js';
|
|
|
40
39
|
*
|
|
41
40
|
* // Copy stream configuration
|
|
42
41
|
* const videoIdx = output.addStream(input.video());
|
|
43
|
-
* await output.writeHeader();
|
|
44
42
|
*
|
|
43
|
+
* // Process packets - header/trailer handled automatically
|
|
45
44
|
* for await (const packet of input.packets()) {
|
|
46
45
|
* await output.writePacket(packet, videoIdx);
|
|
47
46
|
* packet.free();
|
|
@@ -58,7 +57,8 @@ export class MediaOutput {
|
|
|
58
57
|
ioContext;
|
|
59
58
|
headerWritten = false;
|
|
60
59
|
trailerWritten = false;
|
|
61
|
-
|
|
60
|
+
isClosed = false;
|
|
61
|
+
headerWritePromise;
|
|
62
62
|
/**
|
|
63
63
|
* @internal
|
|
64
64
|
*/
|
|
@@ -197,21 +197,25 @@ export class MediaOutput {
|
|
|
197
197
|
* Add a stream to the output.
|
|
198
198
|
*
|
|
199
199
|
* Configures output stream from encoder or input stream.
|
|
200
|
-
* Must be called before
|
|
200
|
+
* Must be called before writing any packets.
|
|
201
201
|
* Returns stream index for packet writing.
|
|
202
202
|
*
|
|
203
|
-
*
|
|
203
|
+
* Streams are initialized lazily - codec parameters are configured
|
|
204
|
+
* automatically when the first packet is written. This allows encoders
|
|
205
|
+
* to be initialized from frame properties.
|
|
206
|
+
*
|
|
207
|
+
* Direct mapping to avformat_new_stream().
|
|
204
208
|
*
|
|
205
209
|
* @param source - Encoder or stream to add
|
|
206
210
|
* @param options - Stream configuration options
|
|
207
211
|
* @param options.timeBase - Optional custom timebase for the stream
|
|
208
212
|
* @returns Stream index for packet writing
|
|
209
213
|
*
|
|
210
|
-
* @throws {Error} If called after
|
|
214
|
+
* @throws {Error} If called after packets have been written or output closed
|
|
211
215
|
*
|
|
212
216
|
* @example
|
|
213
217
|
* ```typescript
|
|
214
|
-
* // Add stream from encoder
|
|
218
|
+
* // Add stream from encoder (lazy initialization)
|
|
215
219
|
* const videoIdx = output.addStream(videoEncoder);
|
|
216
220
|
* const audioIdx = output.addStream(audioEncoder);
|
|
217
221
|
* ```
|
|
@@ -228,68 +232,72 @@ export class MediaOutput {
|
|
|
228
232
|
* @see {@link Encoder} For transcoding source
|
|
229
233
|
*/
|
|
230
234
|
addStream(source, options) {
|
|
231
|
-
if (this.
|
|
235
|
+
if (this.isClosed) {
|
|
232
236
|
throw new Error('MediaOutput is closed');
|
|
233
237
|
}
|
|
234
238
|
if (this.headerWritten) {
|
|
235
|
-
throw new Error('Cannot add streams after
|
|
239
|
+
throw new Error('Cannot add streams after packets have been written');
|
|
236
240
|
}
|
|
237
241
|
const stream = this.formatContext.newStream(null);
|
|
238
242
|
if (!stream) {
|
|
239
243
|
throw new Error('Failed to create new stream');
|
|
240
244
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
if (
|
|
244
|
-
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
245
|
+
const isStreamCopy = !(source instanceof Encoder);
|
|
246
|
+
// For stream copy, initialize immediately since we have all the info
|
|
247
|
+
if (isStreamCopy) {
|
|
248
|
+
const inputStream = source;
|
|
249
|
+
const ret = inputStream.codecpar.copy(stream.codecpar);
|
|
250
|
+
FFmpegError.throwIfError(ret, 'Failed to copy codec parameters');
|
|
251
|
+
// Set the timebases
|
|
252
|
+
const sourceTimeBase = inputStream.timeBase;
|
|
253
|
+
stream.timeBase = options?.timeBase ? new Rational(options.timeBase.num, options.timeBase.den) : inputStream.timeBase;
|
|
254
|
+
this.streams.set(stream.index, {
|
|
255
|
+
initialized: true,
|
|
256
|
+
stream,
|
|
257
|
+
source,
|
|
258
|
+
timeBase: options?.timeBase,
|
|
259
|
+
sourceTimeBase,
|
|
260
|
+
isStreamCopy: true,
|
|
261
|
+
bufferedPackets: [],
|
|
262
|
+
});
|
|
255
263
|
}
|
|
256
264
|
else {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
265
|
+
this.streams.set(stream.index, {
|
|
266
|
+
initialized: false,
|
|
267
|
+
stream,
|
|
268
|
+
source,
|
|
269
|
+
timeBase: options?.timeBase,
|
|
270
|
+
sourceTimeBase: undefined, // Will be set on initialization
|
|
271
|
+
isStreamCopy: false,
|
|
272
|
+
bufferedPackets: [],
|
|
273
|
+
});
|
|
266
274
|
}
|
|
267
|
-
this.streams.set(stream.index, {
|
|
268
|
-
stream,
|
|
269
|
-
timeBase: stream.timeBase,
|
|
270
|
-
isStreamCopy,
|
|
271
|
-
sourceTimeBase,
|
|
272
|
-
});
|
|
273
275
|
return stream.index;
|
|
274
276
|
}
|
|
275
277
|
/**
|
|
276
278
|
* Write a packet to the output.
|
|
277
279
|
*
|
|
278
280
|
* Writes muxed packet to the specified stream.
|
|
279
|
-
* Automatically handles
|
|
280
|
-
*
|
|
281
|
+
* Automatically handles:
|
|
282
|
+
* - Stream initialization on first packet (lazy initialization)
|
|
283
|
+
* - Codec parameter configuration from encoder or input stream
|
|
284
|
+
* - Header writing on first packet
|
|
285
|
+
* - Timestamp rescaling between source and output timebases
|
|
286
|
+
*
|
|
287
|
+
* For encoder sources, the encoder must have processed at least one frame
|
|
288
|
+
* before packets can be written (encoder must be initialized).
|
|
281
289
|
*
|
|
282
|
-
* Direct mapping to av_interleaved_write_frame().
|
|
290
|
+
* Direct mapping to avformat_write_header() (on first packet) and av_interleaved_write_frame().
|
|
283
291
|
*
|
|
284
292
|
* @param packet - Packet to write
|
|
285
293
|
* @param streamIndex - Target stream index
|
|
286
|
-
* @throws {Error} If stream invalid or
|
|
294
|
+
* @throws {Error} If stream invalid or encoder not initialized
|
|
287
295
|
*
|
|
288
296
|
* @throws {FFmpegError} If write fails
|
|
289
297
|
*
|
|
290
298
|
* @example
|
|
291
299
|
* ```typescript
|
|
292
|
-
* // Write encoded packet
|
|
300
|
+
* // Write encoded packet - header written automatically on first packet
|
|
293
301
|
* const packet = await encoder.encode(frame);
|
|
294
302
|
* if (packet) {
|
|
295
303
|
* await output.writePacket(packet, videoIdx);
|
|
@@ -309,119 +317,93 @@ export class MediaOutput {
|
|
|
309
317
|
* ```
|
|
310
318
|
*
|
|
311
319
|
* @see {@link addStream} For adding streams
|
|
312
|
-
* @see {@link writeHeader} Must be called first
|
|
313
320
|
*/
|
|
314
321
|
async writePacket(packet, streamIndex) {
|
|
315
|
-
if (this.
|
|
322
|
+
if (this.isClosed) {
|
|
316
323
|
throw new Error('MediaOutput is closed');
|
|
317
324
|
}
|
|
318
|
-
if (!this.headerWritten) {
|
|
319
|
-
throw new Error('Header must be written before packets');
|
|
320
|
-
}
|
|
321
325
|
if (this.trailerWritten) {
|
|
322
|
-
throw new Error('Cannot write packets after
|
|
326
|
+
throw new Error('Cannot write packets after output is finalized');
|
|
323
327
|
}
|
|
324
|
-
|
|
325
|
-
if (!streamInfo) {
|
|
328
|
+
if (!this.streams.get(streamIndex)) {
|
|
326
329
|
throw new Error(`Invalid stream index: ${streamIndex}`);
|
|
327
330
|
}
|
|
328
|
-
//
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
const srcTb = streamInfo.sourceTimeBase;
|
|
337
|
-
const dstTb = outputStream.timeBase;
|
|
338
|
-
if (srcTb.num !== dstTb.num || srcTb.den !== dstTb.den) {
|
|
339
|
-
packet.rescaleTs(streamInfo.sourceTimeBase, outputStream.timeBase);
|
|
331
|
+
// Initialize any encoder streams that are ready
|
|
332
|
+
for (const streamInfo of this.streams.values()) {
|
|
333
|
+
if (!streamInfo.initialized && streamInfo.source instanceof Encoder) {
|
|
334
|
+
const encoder = streamInfo.source;
|
|
335
|
+
const codecContext = encoder.getCodecContext();
|
|
336
|
+
// Skip if encoder not ready yet
|
|
337
|
+
if (!encoder.isEncoderInitialized || !codecContext) {
|
|
338
|
+
continue;
|
|
340
339
|
}
|
|
340
|
+
// This encoder is ready, initialize it now
|
|
341
|
+
const ret = streamInfo.stream.codecpar.fromContext(codecContext);
|
|
342
|
+
FFmpegError.throwIfError(ret, 'Failed to copy codec parameters from encoder');
|
|
343
|
+
// Update the timebase from the encoder
|
|
344
|
+
streamInfo.sourceTimeBase = codecContext.timeBase;
|
|
345
|
+
// Output stream uses encoder's timebase (or custom if specified)
|
|
346
|
+
streamInfo.stream.timeBase = streamInfo.timeBase ? new Rational(streamInfo.timeBase.num, streamInfo.timeBase.den) : codecContext.timeBase;
|
|
347
|
+
// Mark as initialized
|
|
348
|
+
streamInfo.initialized = true;
|
|
341
349
|
}
|
|
342
350
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
*
|
|
354
|
-
* Direct mapping to avformat_write_header().
|
|
355
|
-
*
|
|
356
|
-
* @throws {Error} If already written or output closed
|
|
357
|
-
*
|
|
358
|
-
* @throws {FFmpegError} If write fails
|
|
359
|
-
*
|
|
360
|
-
* @example
|
|
361
|
-
* ```typescript
|
|
362
|
-
* // Standard workflow
|
|
363
|
-
* const output = await MediaOutput.open('output.mp4');
|
|
364
|
-
* output.addStream(encoder);
|
|
365
|
-
* await output.writeHeader();
|
|
366
|
-
* // Now ready to write packets
|
|
367
|
-
* ```
|
|
368
|
-
*
|
|
369
|
-
* @see {@link addStream} Must add streams first
|
|
370
|
-
* @see {@link writePacket} Can write packets after
|
|
371
|
-
* @see {@link writeTrailer} Must call at end
|
|
372
|
-
*/
|
|
373
|
-
async writeHeader() {
|
|
374
|
-
if (this.closed) {
|
|
375
|
-
throw new Error('MediaOutput is closed');
|
|
376
|
-
}
|
|
377
|
-
if (this.headerWritten) {
|
|
378
|
-
throw new Error('Header already written');
|
|
379
|
-
}
|
|
380
|
-
const ret = await this.formatContext.writeHeader();
|
|
381
|
-
FFmpegError.throwIfError(ret, 'Failed to write header');
|
|
382
|
-
this.headerWritten = true;
|
|
383
|
-
}
|
|
384
|
-
/**
|
|
385
|
-
* Write file trailer.
|
|
386
|
-
*
|
|
387
|
-
* Writes format trailer and finalizes the file.
|
|
388
|
-
* Must be called after all packets are written.
|
|
389
|
-
* Flushes any buffered data and updates file headers.
|
|
390
|
-
*
|
|
391
|
-
* Direct mapping to av_write_trailer().
|
|
392
|
-
*
|
|
393
|
-
* @throws {Error} If header not written or already written
|
|
394
|
-
*
|
|
395
|
-
* @throws {FFmpegError} If write fails
|
|
396
|
-
*
|
|
397
|
-
* @example
|
|
398
|
-
* ```typescript
|
|
399
|
-
* // Finalize output
|
|
400
|
-
* await output.writeTrailer();
|
|
401
|
-
* await output.close();
|
|
402
|
-
* ```
|
|
403
|
-
*
|
|
404
|
-
* @see {@link writeHeader} Must be called first
|
|
405
|
-
* @see {@link close} For cleanup after trailer
|
|
406
|
-
*/
|
|
407
|
-
async writeTrailer() {
|
|
408
|
-
if (this.closed) {
|
|
409
|
-
throw new Error('MediaOutput is closed');
|
|
351
|
+
const streamInfo = this.streams.get(streamIndex);
|
|
352
|
+
// Check if any streams are still uninitialized
|
|
353
|
+
const uninitialized = Array.from(this.streams.values()).some((s) => !s.initialized);
|
|
354
|
+
if (uninitialized) {
|
|
355
|
+
const clonedPacket = packet.clone();
|
|
356
|
+
packet.free();
|
|
357
|
+
if (clonedPacket) {
|
|
358
|
+
streamInfo.bufferedPackets.push(clonedPacket);
|
|
359
|
+
}
|
|
360
|
+
return;
|
|
410
361
|
}
|
|
362
|
+
// Automatically write header if not written yet
|
|
363
|
+
// Use a promise to ensure only one thread writes the header
|
|
411
364
|
if (!this.headerWritten) {
|
|
412
|
-
|
|
365
|
+
this.headerWritePromise ??= (async () => {
|
|
366
|
+
const ret = await this.formatContext.writeHeader();
|
|
367
|
+
FFmpegError.throwIfError(ret, 'Failed to write header');
|
|
368
|
+
this.headerWritten = true;
|
|
369
|
+
})();
|
|
370
|
+
// All threads wait for the header to be written
|
|
371
|
+
await this.headerWritePromise;
|
|
413
372
|
}
|
|
414
|
-
|
|
415
|
-
|
|
373
|
+
// Set stream index
|
|
374
|
+
packet.streamIndex = streamIndex;
|
|
375
|
+
const write = async (pkt) => {
|
|
376
|
+
// Rescale packet timestamps if source and output timebases differ
|
|
377
|
+
// Note: The stream's timebase may have been changed by writeHeader (e.g., MP4 uses 1/time_scale)
|
|
378
|
+
if (streamInfo.sourceTimeBase) {
|
|
379
|
+
const outputStream = this.formatContext.streams?.[streamIndex];
|
|
380
|
+
if (outputStream) {
|
|
381
|
+
// Only rescale if timebases actually differ
|
|
382
|
+
const srcTb = streamInfo.sourceTimeBase;
|
|
383
|
+
const dstTb = outputStream.timeBase;
|
|
384
|
+
if (srcTb.num !== dstTb.num || srcTb.den !== dstTb.den) {
|
|
385
|
+
pkt.rescaleTs(streamInfo.sourceTimeBase, outputStream.timeBase);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
// Write the packet
|
|
390
|
+
const ret = await this.formatContext.interleavedWriteFrame(pkt);
|
|
391
|
+
FFmpegError.throwIfError(ret, 'Failed to write packet');
|
|
392
|
+
};
|
|
393
|
+
// Write any buffered packets first
|
|
394
|
+
for (const bufferedPacket of streamInfo.bufferedPackets) {
|
|
395
|
+
await write(bufferedPacket);
|
|
396
|
+
bufferedPacket.free();
|
|
416
397
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
398
|
+
streamInfo.bufferedPackets = [];
|
|
399
|
+
// Write the current packet
|
|
400
|
+
await write(packet);
|
|
420
401
|
}
|
|
421
402
|
/**
|
|
422
403
|
* Close media output and free resources.
|
|
423
404
|
*
|
|
424
|
-
*
|
|
405
|
+
* Automatically writes trailer if header was written.
|
|
406
|
+
* Closes the output file and releases all resources.
|
|
425
407
|
* Safe to call multiple times.
|
|
426
408
|
* Automatically called by Symbol.asyncDispose.
|
|
427
409
|
*
|
|
@@ -429,7 +411,7 @@ export class MediaOutput {
|
|
|
429
411
|
* ```typescript
|
|
430
412
|
* const output = await MediaOutput.open('output.mp4');
|
|
431
413
|
* try {
|
|
432
|
-
* // Use output
|
|
414
|
+
* // Use output - trailer written automatically on close
|
|
433
415
|
* } finally {
|
|
434
416
|
* await output.close();
|
|
435
417
|
* }
|
|
@@ -438,14 +420,23 @@ export class MediaOutput {
|
|
|
438
420
|
* @see {@link Symbol.asyncDispose} For automatic cleanup
|
|
439
421
|
*/
|
|
440
422
|
async close() {
|
|
441
|
-
if (this.
|
|
423
|
+
if (this.isClosed) {
|
|
442
424
|
return;
|
|
443
425
|
}
|
|
444
|
-
this.
|
|
426
|
+
this.isClosed = true;
|
|
427
|
+
// Free any buffered packets
|
|
428
|
+
for (const streamInfo of this.streams.values()) {
|
|
429
|
+
// Free any buffered packets
|
|
430
|
+
for (const pkt of streamInfo.bufferedPackets) {
|
|
431
|
+
pkt.free();
|
|
432
|
+
}
|
|
433
|
+
streamInfo.bufferedPackets = [];
|
|
434
|
+
}
|
|
445
435
|
// Try to write trailer if header was written but trailer wasn't
|
|
446
436
|
try {
|
|
447
437
|
if (this.headerWritten && !this.trailerWritten) {
|
|
448
438
|
await this.formatContext.writeTrailer();
|
|
439
|
+
this.trailerWritten = true;
|
|
449
440
|
}
|
|
450
441
|
}
|
|
451
442
|
catch {
|
|
@@ -486,69 +477,6 @@ export class MediaOutput {
|
|
|
486
477
|
}
|
|
487
478
|
}
|
|
488
479
|
}
|
|
489
|
-
/**
|
|
490
|
-
* Get stream information.
|
|
491
|
-
*
|
|
492
|
-
* Returns internal stream info for the specified index.
|
|
493
|
-
*
|
|
494
|
-
* @param streamIndex - Stream index
|
|
495
|
-
* @returns Stream info or undefined
|
|
496
|
-
*
|
|
497
|
-
* @example
|
|
498
|
-
* ```typescript
|
|
499
|
-
* const info = output.getStreamInfo(0);
|
|
500
|
-
* console.log(`Stream 0 timebase: ${info?.timeBase.num}/${info?.timeBase.den}`);
|
|
501
|
-
* ```
|
|
502
|
-
*/
|
|
503
|
-
getStreamInfo(streamIndex) {
|
|
504
|
-
return this.streams.get(streamIndex);
|
|
505
|
-
}
|
|
506
|
-
/**
|
|
507
|
-
* Get all stream indices.
|
|
508
|
-
*
|
|
509
|
-
* Returns array of all added stream indices.
|
|
510
|
-
*
|
|
511
|
-
* @returns Array of stream indices
|
|
512
|
-
*
|
|
513
|
-
* @example
|
|
514
|
-
* ```typescript
|
|
515
|
-
* const indices = output.getStreamIndices();
|
|
516
|
-
* console.log(`Output has ${indices.length} streams`);
|
|
517
|
-
* ```
|
|
518
|
-
*/
|
|
519
|
-
getStreamIndices() {
|
|
520
|
-
return Array.from(this.streams.keys());
|
|
521
|
-
}
|
|
522
|
-
/**
|
|
523
|
-
* Check if header has been written.
|
|
524
|
-
*
|
|
525
|
-
* @returns true if header written
|
|
526
|
-
*
|
|
527
|
-
* @example
|
|
528
|
-
* ```typescript
|
|
529
|
-
* if (!output.isHeaderWritten()) {
|
|
530
|
-
* await output.writeHeader();
|
|
531
|
-
* }
|
|
532
|
-
* ```
|
|
533
|
-
*/
|
|
534
|
-
isHeaderWritten() {
|
|
535
|
-
return this.headerWritten;
|
|
536
|
-
}
|
|
537
|
-
/**
|
|
538
|
-
* Check if trailer has been written.
|
|
539
|
-
*
|
|
540
|
-
* @returns true if trailer written
|
|
541
|
-
*
|
|
542
|
-
* @example
|
|
543
|
-
* ```typescript
|
|
544
|
-
* if (!output.isTrailerWritten()) {
|
|
545
|
-
* await output.writeTrailer();
|
|
546
|
-
* }
|
|
547
|
-
* ```
|
|
548
|
-
*/
|
|
549
|
-
isTrailerWritten() {
|
|
550
|
-
return this.trailerWritten;
|
|
551
|
-
}
|
|
552
480
|
/**
|
|
553
481
|
* Get underlying format context.
|
|
554
482
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media-output.js","sourceRoot":"","sources":["../../src/api/media-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAExC,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAChG,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"media-output.js","sourceRoot":"","sources":["../../src/api/media-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,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I,CAAC;gBACH,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;YAChC,CAAC;YAAC,MAAM,CAAC;gBACP,gBAAgB;YAClB,CAAC;QACH,CAAC;QAED,sBAAsB;QACtB,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,IAAI,CAAC;gBACH,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC;YACnC,CAAC;YAAC,MAAM,CAAC;gBACP,gBAAgB;YAClB,CAAC;QACH,CAAC;QAED,wCAAwC;QACxC,IAAI,IAAI,CAAC,SAAS,IAAI,UAAU,EAAE,CAAC;YACjC,IAAI,CAAC;gBACH,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;YAC/B,CAAC;YAAC,MAAM,CAAC;gBACP,gBAAgB;YAClB,CAAC;QACH,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;CACF"}
|
package/dist/api/pipeline.d.ts
CHANGED
|
@@ -93,7 +93,7 @@ export declare function pipeline(source: MediaInput, decoder: Decoder, filter: F
|
|
|
93
93
|
* @example
|
|
94
94
|
* ```typescript
|
|
95
95
|
* const decoder = await Decoder.create(input.video());
|
|
96
|
-
* const encoder = await Encoder.create(FF_ENCODER_LIBX264,
|
|
96
|
+
* const encoder = await Encoder.create(FF_ENCODER_LIBX264, { ... });
|
|
97
97
|
* const bsf = await BitStreamFilterAPI.create('h264_mp4toannexb');
|
|
98
98
|
* const control = pipeline(input, decoder, encoder, bsf, output);
|
|
99
99
|
* await control.completion;
|
|
@@ -114,8 +114,8 @@ export declare function pipeline(source: MediaInput, decoder: Decoder, encoder:
|
|
|
114
114
|
* @example
|
|
115
115
|
* ```typescript
|
|
116
116
|
* const decoder = await Decoder.create(input.video());
|
|
117
|
-
* const filter = await FilterAPI.create('scale=640:480');
|
|
118
|
-
* const encoder = await Encoder.create(FF_ENCODER_LIBX264,
|
|
117
|
+
* const filter = await FilterAPI.create('scale=640:480', { ... });
|
|
118
|
+
* const encoder = await Encoder.create(FF_ENCODER_LIBX264, { ... });
|
|
119
119
|
* const bsf = await BitStreamFilterAPI.create('h264_mp4toannexb');
|
|
120
120
|
* const control = pipeline(input, decoder, filter, encoder, bsf, output);
|
|
121
121
|
* await control.completion;
|
|
@@ -136,9 +136,9 @@ export declare function pipeline(source: MediaInput, decoder: Decoder, filter: F
|
|
|
136
136
|
* @example
|
|
137
137
|
* ```typescript
|
|
138
138
|
* const decoder = await Decoder.create(input.video());
|
|
139
|
-
* const scaleFilter = await FilterAPI.create('scale=640:480');
|
|
140
|
-
* const cropFilter = await FilterAPI.create('crop=640:360');
|
|
141
|
-
* const encoder = await Encoder.create(FF_ENCODER_LIBX264,
|
|
139
|
+
* const scaleFilter = await FilterAPI.create('scale=640:480', { ... });
|
|
140
|
+
* const cropFilter = await FilterAPI.create('crop=640:360', { ... });
|
|
141
|
+
* const encoder = await Encoder.create(FF_ENCODER_LIBX264, { ... });
|
|
142
142
|
* const control = pipeline(input, decoder, scaleFilter, cropFilter, encoder, output);
|
|
143
143
|
* await control.completion;
|
|
144
144
|
* ```
|
|
@@ -189,8 +189,8 @@ export declare function pipeline(source: MediaInput, bsf: BitStreamFilterAPI | B
|
|
|
189
189
|
* ```typescript
|
|
190
190
|
* // Process frames from custom source
|
|
191
191
|
* const frameSource = generateFrames(); // Your async frame generator
|
|
192
|
-
* const filter = await FilterAPI.create('scale=1920:1080');
|
|
193
|
-
* const encoder = await Encoder.create(FF_ENCODER_LIBX264,
|
|
192
|
+
* const filter = await FilterAPI.create('scale=1920:1080', { ... });
|
|
193
|
+
* const encoder = await Encoder.create(FF_ENCODER_LIBX264, { ... });
|
|
194
194
|
* const control = pipeline(frameSource, filter, encoder, output);
|
|
195
195
|
* await control.completion;
|
|
196
196
|
* ```
|
|
@@ -208,7 +208,7 @@ export declare function pipeline(source: AsyncIterable<Frame>, filter: FilterAPI
|
|
|
208
208
|
* ```typescript
|
|
209
209
|
* // Encode raw frames directly
|
|
210
210
|
* const frameSource = generateFrames(); // Your async frame generator
|
|
211
|
-
* const encoder = await Encoder.create(FF_ENCODER_LIBX264,
|
|
211
|
+
* const encoder = await Encoder.create(FF_ENCODER_LIBX264, { ... });
|
|
212
212
|
* const control = pipeline(frameSource, encoder, output);
|
|
213
213
|
* await control.completion;
|
|
214
214
|
* ```
|
|
@@ -245,7 +245,7 @@ export declare function pipeline(source: MediaInput, decoder: Decoder): AsyncGen
|
|
|
245
245
|
* ```typescript
|
|
246
246
|
* // Get filtered frames for custom processing
|
|
247
247
|
* const decoder = await Decoder.create(input.video());
|
|
248
|
-
* const filter = await FilterAPI.create('scale=640:480');
|
|
248
|
+
* const filter = await FilterAPI.create('scale=640:480', { ... });
|
|
249
249
|
* const frames = pipeline(input, decoder, filter);
|
|
250
250
|
* for await (const frame of frames) {
|
|
251
251
|
* // Process filtered frame
|
|
@@ -267,8 +267,8 @@ export declare function pipeline(source: MediaInput, decoder: Decoder, filter: F
|
|
|
267
267
|
* ```typescript
|
|
268
268
|
* // Get encoded packets for custom output handling
|
|
269
269
|
* const decoder = await Decoder.create(input.video());
|
|
270
|
-
* const filter = await FilterAPI.create('scale=640:480');
|
|
271
|
-
* const encoder = await Encoder.create(FF_ENCODER_LIBX264,
|
|
270
|
+
* const filter = await FilterAPI.create('scale=640:480', { ... });
|
|
271
|
+
* const encoder = await Encoder.create(FF_ENCODER_LIBX264, { ... });
|
|
272
272
|
* const packets = pipeline(input, decoder, filter, encoder);
|
|
273
273
|
* for await (const packet of packets) {
|
|
274
274
|
* // Handle encoded packet
|
|
@@ -289,7 +289,7 @@ export declare function pipeline(source: MediaInput, decoder: Decoder, filter: F
|
|
|
289
289
|
* ```typescript
|
|
290
290
|
* // Transcode to packets for custom output
|
|
291
291
|
* const decoder = await Decoder.create(input.video());
|
|
292
|
-
* const encoder = await Encoder.create(FF_ENCODER_LIBX264,
|
|
292
|
+
* const encoder = await Encoder.create(FF_ENCODER_LIBX264, { ... });
|
|
293
293
|
* const packets = pipeline(input, decoder, encoder);
|
|
294
294
|
* for await (const packet of packets) {
|
|
295
295
|
* // Handle transcoded packet
|
|
@@ -309,7 +309,7 @@ export declare function pipeline(source: MediaInput, decoder: Decoder, encoder:
|
|
|
309
309
|
* ```typescript
|
|
310
310
|
* // Filter frames from custom source
|
|
311
311
|
* const frameSource = generateFrames();
|
|
312
|
-
* const filter = await FilterAPI.create('scale=640:480');
|
|
312
|
+
* const filter = await FilterAPI.create('scale=640:480', { ... });
|
|
313
313
|
* const filteredFrames = pipeline(frameSource, filter);
|
|
314
314
|
* for await (const frame of filteredFrames) {
|
|
315
315
|
* // Process filtered frame
|
|
@@ -329,7 +329,7 @@ export declare function pipeline(source: AsyncIterable<Frame>, filter: FilterAPI
|
|
|
329
329
|
* ```typescript
|
|
330
330
|
* // Encode frames to packets
|
|
331
331
|
* const frameSource = generateFrames();
|
|
332
|
-
* const encoder = await Encoder.create(FF_ENCODER_LIBX264,
|
|
332
|
+
* const encoder = await Encoder.create(FF_ENCODER_LIBX264, { ... });
|
|
333
333
|
* const packets = pipeline(frameSource, encoder);
|
|
334
334
|
* for await (const packet of packets) {
|
|
335
335
|
* // Handle encoded packet
|
|
@@ -350,8 +350,8 @@ export declare function pipeline(source: AsyncIterable<Frame>, encoder: Encoder)
|
|
|
350
350
|
* ```typescript
|
|
351
351
|
* // Process frames with filter and encode to packets
|
|
352
352
|
* const frameSource = generateFrames();
|
|
353
|
-
* const filter = await FilterAPI.create('scale=640:480');
|
|
354
|
-
* const encoder = await Encoder.create(FF_ENCODER_LIBX264,
|
|
353
|
+
* const filter = await FilterAPI.create('scale=640:480', { ... });
|
|
354
|
+
* const encoder = await Encoder.create(FF_ENCODER_LIBX264, { ... });
|
|
355
355
|
* const packets = pipeline(frameSource, filter, encoder);
|
|
356
356
|
* for await (const packet of packets) {
|
|
357
357
|
* // Handle encoded packet
|