@seydx/rtsp / FfmpegSink
Class: FfmpegSink
Defined in: sinks/ffmpeg.ts:100
Sink that remuxes the relayed stream into another container.
Pipes the relay's packets into a node-av muxer entirely in-process, with no child process involved. Streams are copied rather than re-encoded, so the operation stays cheap and lossless. Point it at a file, a streaming URL, or a writable stream to record or republish the upstream media.
Examples
import { Relay, FfmpegSink } from '@seydx/rtsp';
const sink = new FfmpegSink({ output: 'out.mp4' });
relay.pipe(sink);import { FfmpegSink } from '@seydx/rtsp';
const sink = new FfmpegSink({
output: 'rtmp://localhost/live/stream',
format: 'flv',
options: { flvflags: 'no_duration_filesize' },
});See
Implements
Constructors
Constructor
new FfmpegSink(
options):FfmpegSink
Defined in: sinks/ffmpeg.ts:114
Create a new ffmpeg sink.
Parameters
options
Output destination and muxer configuration
Returns
FfmpegSink
Example
const sink = new FfmpegSink({ output: 'out.mp4', format: 'mp4' });Methods
close()
close():
Promise<void>
Defined in: sinks/ffmpeg.ts:184
Finalize and release the muxer.
Flushes any buffered output, writes the container trailer, and frees the stream mapping. Safe to call when the sink was never initialized. Errors raised while closing are reported through the configured logger rather than thrown, so teardown of other sinks is not interrupted.
Returns
Promise<void>
Resolves once the muxer has been closed
Example
await sink.close();Implementation of
init()
init(
info):Promise<void>
Defined in: sinks/ffmpeg.ts:134
Initialize the muxer and map the source tracks onto it.
Opens the output destination, then registers each AV-backed track as a muxer stream so packets can later be routed to the correct output index. Tracks without a native handle are skipped, since they cannot be copied.
Parameters
info
Resolved description of the upstream tracks
Returns
Promise<void>
Resolves once the muxer is open and all streams are mapped
Throws
If the output cannot be opened by node-av
Example
await sink.init(streamInfo);Implementation of
write()
write(
packet):Promise<void>
Defined in: sinks/ffmpeg.ts:163
Write a single packet to the muxer.
Routes the packet to its mapped output stream by index. Packets for unmapped tracks, or packets without an underlying AV payload, are dropped silently.
Parameters
packet
The media packet to remux
Returns
Promise<void>
Resolves once the packet has been handed to the muxer
Example
await sink.write(packet);