homebridge-plugin-utils 1.33.0 → 1.35.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.
Files changed (46) hide show
  1. package/build/tsconfig.json +6 -4
  2. package/dist/backpressure.d.ts +79 -0
  3. package/dist/backpressure.js +137 -0
  4. package/dist/backpressure.js.map +1 -0
  5. package/dist/featureoptions.d.ts +3 -3
  6. package/dist/featureoptions.js +122 -97
  7. package/dist/featureoptions.js.map +1 -1
  8. package/dist/ffmpeg/codecs.js +26 -20
  9. package/dist/ffmpeg/codecs.js.map +1 -1
  10. package/dist/ffmpeg/exec.d.ts +1 -1
  11. package/dist/ffmpeg/exec.js.map +1 -1
  12. package/dist/ffmpeg/fmp4.d.ts +21 -2
  13. package/dist/ffmpeg/fmp4.js +55 -2
  14. package/dist/ffmpeg/fmp4.js.map +1 -1
  15. package/dist/ffmpeg/options.d.ts +6 -1
  16. package/dist/ffmpeg/options.js +13 -14
  17. package/dist/ffmpeg/options.js.map +1 -1
  18. package/dist/ffmpeg/process.d.ts +26 -14
  19. package/dist/ffmpeg/process.js +60 -36
  20. package/dist/ffmpeg/process.js.map +1 -1
  21. package/dist/ffmpeg/record.d.ts +121 -122
  22. package/dist/ffmpeg/record.js +363 -285
  23. package/dist/ffmpeg/record.js.map +1 -1
  24. package/dist/ffmpeg/rtp.d.ts +2 -2
  25. package/dist/ffmpeg/rtp.js +9 -2
  26. package/dist/ffmpeg/rtp.js.map +1 -1
  27. package/dist/ffmpeg/settings.d.ts +1 -0
  28. package/dist/ffmpeg/settings.js +3 -0
  29. package/dist/ffmpeg/settings.js.map +1 -1
  30. package/dist/ffmpeg/stream.d.ts +1 -1
  31. package/dist/ffmpeg/stream.js +6 -4
  32. package/dist/ffmpeg/stream.js.map +1 -1
  33. package/dist/index.d.ts +1 -0
  34. package/dist/index.js +1 -0
  35. package/dist/index.js.map +1 -1
  36. package/dist/mqttclient.js +6 -5
  37. package/dist/mqttclient.js.map +1 -1
  38. package/dist/service.d.ts +1 -1
  39. package/dist/service.js +10 -4
  40. package/dist/service.js.map +1 -1
  41. package/dist/ui/featureoptions.js +122 -97
  42. package/dist/ui/featureoptions.js.map +1 -1
  43. package/dist/util.d.ts +18 -19
  44. package/dist/util.js +43 -21
  45. package/dist/util.js.map +1 -1
  46. package/package.json +7 -8
@@ -24,9 +24,12 @@
24
24
  * @module
25
25
  */
26
26
  import { spawn } from "node:child_process";
27
+ import { EOL } from "node:os";
27
28
  import { EventEmitter } from "node:events";
28
- import os from "node:os";
29
+ import { FFMPEG_INPUT_TIMEOUT } from "./settings.js";
29
30
  import util from "node:util";
31
+ // Matches non-printable control characters for stripping from FFmpeg stderr output. Compiled once at module scope rather than per data event.
32
+ const NON_PRINTABLE_CHARS = /\p{C}+/gu;
30
33
  /**
31
34
  * Base class providing FFmpeg process management and capability introspection.
32
35
  *
@@ -58,18 +61,6 @@ import util from "node:util";
58
61
  * @category FFmpeg
59
62
  */
60
63
  export class FfmpegProcess extends EventEmitter {
61
- /**
62
- * Indicates if an error has occurred during FFmpeg process execution.
63
- */
64
- hasError;
65
- /**
66
- * Indicates whether the FFmpeg process has ended.
67
- */
68
- isEnded;
69
- /**
70
- * Indicates whether the FFmpeg process has started.
71
- */
72
- isStarted;
73
64
  /**
74
65
  * Optional callback to be called when the FFmpeg process is ready for streaming.
75
66
  */
@@ -94,28 +85,34 @@ export class FfmpegProcess extends EventEmitter {
94
85
  * The underlying Node.js ChildProcess instance for the FFmpeg process.
95
86
  */
96
87
  process;
88
+ _hasError;
89
+ _isStarted;
97
90
  /**
98
91
  * Accumulated log lines from standard error for error reporting and debugging.
99
92
  */
100
- stderrLog;
93
+ _stderrLog;
101
94
  ffmpegTimeout;
102
95
  isLogging;
103
96
  stderrBuffer;
97
+ /**
98
+ * Indicates whether the FFmpeg process has ended. Protected to allow subclass state transitions (e.g., signaling generators before shutdown).
99
+ */
100
+ _isEnded;
104
101
  // Create a new FFmpeg process instance.
105
102
  constructor(options, commandLineArgs, callback) {
106
103
  // Initialize our parent.
107
104
  super();
108
105
  this.callback = null;
109
106
  this.commandLineArgs = [];
110
- this.hasError = false;
107
+ this._hasError = false;
108
+ this._isEnded = false;
109
+ this._isStarted = false;
111
110
  this.isLogging = false;
112
- this.isEnded = false;
113
- this.isStarted = false;
114
111
  this.log = options.log;
115
112
  this.options = options;
116
113
  this.process = null;
117
114
  this.stderrBuffer = "";
118
- this.stderrLog = [];
115
+ this._stderrLog = [];
119
116
  // Toggle FFmpeg logging, if configured.
120
117
  this.isVerbose = this.options.codecSupport.verbose;
121
118
  // If we've specified a command line or a callback, let's save them.
@@ -139,8 +136,8 @@ export class FfmpegProcess extends EventEmitter {
139
136
  // See if we should display ffmpeg command output.
140
137
  this.isLogging = false;
141
138
  // Track if we've started or ended FFmpeg.
142
- this.isStarted = false;
143
- this.isEnded = false;
139
+ this._isStarted = false;
140
+ this._isEnded = false;
144
141
  // If we've got a loglevel specified, ensure we display it.
145
142
  if (this.commandLineArgs.includes("-loglevel")) {
146
143
  this.isLogging = true;
@@ -205,10 +202,10 @@ export class FfmpegProcess extends EventEmitter {
205
202
  // Inform us when we start receiving data back from FFmpeg. We do this here because it's the only
206
203
  // truly reliable place we can check on FFmpeg. stdin and stdout may not be used at all, depending
207
204
  // on the way FFmpeg is called, but stderr will always be there.
208
- if (!this.isStarted) {
209
- this.isStarted = true;
210
- this.isEnded = false;
211
- this.log.debug("Received the first frame.");
205
+ if (!this._isStarted) {
206
+ this._isStarted = true;
207
+ this._isEnded = false;
208
+ this.log.debug("FFmpeg process started.");
212
209
  // Always remember to execute the callback once we're setup to let homebridge know we're streaming.
213
210
  if (this.callback) {
214
211
  this.callback();
@@ -216,19 +213,19 @@ export class FfmpegProcess extends EventEmitter {
216
213
  }
217
214
  }
218
215
  // Append to the current line we've been buffering. We don't want to output not-printable characters to ensure the log output is readable.
219
- this.stderrBuffer += data.toString().replace(/\p{C}+/gu, os.EOL);
216
+ this.stderrBuffer += data.toString().replace(NON_PRINTABLE_CHARS, EOL);
220
217
  // Debugging and additional logging collection.
221
218
  for (;;) {
222
219
  // Find the next newline.
223
- const lineIndex = this.stderrBuffer.indexOf(os.EOL);
220
+ const lineIndex = this.stderrBuffer.indexOf(EOL);
224
221
  // If there's no newline, we're done until we get more data.
225
222
  if (lineIndex === -1) {
226
223
  return;
227
224
  }
228
225
  // Grab the next complete line, and increment our buffer.
229
226
  const line = this.stderrBuffer.slice(0, lineIndex);
230
- this.stderrBuffer = this.stderrBuffer.slice(lineIndex + os.EOL.length);
231
- this.stderrLog.push(line);
227
+ this.stderrBuffer = this.stderrBuffer.slice(lineIndex + EOL.length);
228
+ this._stderrLog.push(line);
232
229
  // Show it to the user if it's been requested.
233
230
  if (this.isLogging || this.isVerbose || this.options.debug) {
234
231
  this.log.info(line);
@@ -241,8 +238,8 @@ export class FfmpegProcess extends EventEmitter {
241
238
  if (this.ffmpegTimeout) {
242
239
  clearTimeout(this.ffmpegTimeout);
243
240
  }
244
- this.isStarted = false;
245
- this.isEnded = true;
241
+ this._isStarted = false;
242
+ this._isEnded = true;
246
243
  // Some utilities to streamline things.
247
244
  const logPrefix = "FFmpeg process ended ";
248
245
  // FFmpeg ended normally and our canary didn't need to enforce FFmpeg's extinction.
@@ -255,10 +252,10 @@ export class FfmpegProcess extends EventEmitter {
255
252
  }
256
253
  else {
257
254
  // Flag that we've run into an FFmpeg error.
258
- this.hasError = true;
255
+ this._hasError = true;
259
256
  // Flush out any remaining output in our error buffer.
260
257
  if (this.stderrBuffer.length) {
261
- this.stderrLog.push(this.stderrBuffer + "\n");
258
+ this._stderrLog.push(this.stderrBuffer + "\n");
262
259
  this.stderrBuffer = "";
263
260
  }
264
261
  // Inform the user.
@@ -268,11 +265,10 @@ export class FfmpegProcess extends EventEmitter {
268
265
  void errorHandler(util.format(this.options.name() + ": " + logPrefix + " unexpectedly with exit code %s and signal %s.", exitCode, signal));
269
266
  }
270
267
  }
271
- // Cleanup after ourselves.
268
+ // Cleanup after ourselves. We intentionally preserve _stderrLog so callers can inspect it for post-mortem diagnostics after the process exits.
272
269
  this.process?.stdin.off("error", errorListener);
273
270
  this.process?.stderr.off("data", dataListener);
274
271
  this.process = null;
275
- this.stderrLog = [];
276
272
  });
277
273
  }
278
274
  // Stop the FFmpeg process and complete any cleanup activities.
@@ -287,7 +283,7 @@ export class FfmpegProcess extends EventEmitter {
287
283
  // In case we need to kill it again, just to be sure it's really dead.
288
284
  this.ffmpegTimeout = setTimeout(() => {
289
285
  this.process?.kill("SIGKILL");
290
- }, 5000);
286
+ }, FFMPEG_INPUT_TIMEOUT);
291
287
  // Send the kill shot.
292
288
  this.process?.kill();
293
289
  }
@@ -313,7 +309,35 @@ export class FfmpegProcess extends EventEmitter {
313
309
  // Something else has occurred. Inform the user, and stop everything.
314
310
  this.log.error("FFmpeg process ended unexpectedly with %s%s%s.", (exitCode !== null) ? "an exit code of " + exitCode.toString() : "", ((exitCode !== null) && signal) ? " and " : "", signal ? "a signal received of " + signal : "");
315
311
  this.log.error("FFmpeg (%s) command that errored out was: %s %s", this.options.codecSupport.ffmpegVersion, this.options.codecSupport.ffmpegExec, this.commandLineArgs.join(" "));
316
- this.stderrLog.map(x => { this.log.error(x); });
312
+ for (const x of this._stderrLog) {
313
+ this.log.error(x);
314
+ }
315
+ }
316
+ /**
317
+ * Indicates if an error has occurred during FFmpeg process execution.
318
+ */
319
+ get hasError() {
320
+ return this._hasError;
321
+ }
322
+ /**
323
+ * Indicates whether the FFmpeg process has ended.
324
+ */
325
+ get isEnded() {
326
+ return this._isEnded;
327
+ }
328
+ /**
329
+ * Indicates whether the FFmpeg process has started.
330
+ */
331
+ get isStarted() {
332
+ return this._isStarted;
333
+ }
334
+ /**
335
+ * Returns the accumulated standard error log lines from the FFmpeg process.
336
+ *
337
+ * @returns An array of stderr log lines.
338
+ */
339
+ get stderrLog() {
340
+ return this._stderrLog;
317
341
  }
318
342
  /**
319
343
  * Returns the writable standard input stream for the FFmpeg process, if available.
@@ -1 +1 @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AAI,CAAC,OAAO,EAAE,KAAK,IAAI,IAAI,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACH,IAAW,MAAM;QAEf,OAAO,IAAI,CAAC,OAAO,EAAE,MAAM,IAAI,IAAI,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACH,IAAW,MAAM;QAEf,OAAO,IAAI,CAAC,OAAO,EAAE,MAAM,IAAI,IAAI,CAAC;IACtC,CAAC;CACF"}
@@ -10,7 +10,7 @@
10
10
  * - Automated setup and management of FFmpeg processes for HKSV event recording and livestreaming (with support for audio and video).
11
11
  * - Parsing and generation of fMP4 boxes/segments for HomeKit, including initialization and media segments.
12
12
  * - Async generator APIs for efficient, event-driven segment handling.
13
- * - Flexible error handling and timeouts for HomeKits strict realtime requirements.
13
+ * - Flexible error handling and timeouts for HomeKit's strict realtime requirements.
14
14
  * - Designed for Homebridge plugin authors or advanced users who need robust, platform-aware FFmpeg session control for HomeKit and related integrations.
15
15
  *
16
16
  * @module
@@ -20,21 +20,27 @@ import { type Nullable, type PartialWithId } from "../util.js";
20
20
  import type { FfmpegOptions } from "./options.js";
21
21
  import { FfmpegProcess } from "./process.js";
22
22
  /**
23
- * Base options for configuring an fMP4 recording or livestream session. These options aren't used directly but are inherited and used by it's descendents.
24
- *
25
- * @property audioStream - Audio stream input to use, if the input contains multiple audio streams. Defaults to `0` (the first audio stream).
26
- * @property codec - The codec for the input video stream. Valid values are `av1`, `h264`, and `hevc`. Defaults to `h264`.
27
- * @property enableAudio - Indicates whether to enable audio or not.
28
- * @property hardwareDecoding - Enable hardware-accelerated video decoding if available. Defaults to what was specified in `ffmpegOptions`.
29
- * @property hardwareTranscoding - Enable hardware-accelerated video transcoding if available. Defaults to what was specified in `ffmpegOptions`.
30
- * @property videoStream - Video stream input to use, if the input contains multiple video streams. Defaults to `0` (the first video stream).
23
+ * Base options shared by both fMP4 recording and livestream sessions.
24
+ *
25
+ * @property audioFilters - Audio filters for FFmpeg to process. These are passed as an array of filters.
26
+ * @property audioStream - Audio stream input to use, if the input contains multiple audio streams. Defaults to `0` (the first audio stream).
27
+ * @property codec - The codec for the input video stream. Valid values are `av1`, `h264`, and `hevc`. Defaults to `h264`.
28
+ * @property enableAudio - Indicates whether to enable audio or not.
29
+ * @property hardwareDecoding - Enable hardware-accelerated video decoding if available. Defaults to what was specified in `ffmpegOptions`.
30
+ * @property hardwareTranscoding - Enable hardware-accelerated video transcoding if available. Defaults to what was specified in `ffmpegOptions`.
31
+ * @property transcodeAudio - Transcode audio to AAC. This can be set to false if the audio stream is already in AAC. Defaults to `true`.
32
+ * @property videoFilters - Video filters for FFmpeg to process. These are passed as an array of filters.
33
+ * @property videoStream - Video stream input to use, if the input contains multiple video streams. Defaults to `0` (the first video stream).
31
34
  */
32
35
  export interface FMp4BaseOptions {
36
+ audioFilters: string[];
33
37
  audioStream: number;
34
38
  codec: string;
35
39
  enableAudio: boolean;
36
40
  hardwareDecoding: boolean;
37
41
  hardwareTranscoding: boolean;
42
+ transcodeAudio: boolean;
43
+ videoFilters: string[];
38
44
  videoStream: number;
39
45
  }
40
46
  /**
@@ -61,7 +67,7 @@ export interface FMp4BaseOptions {
61
67
  * url: "http://doorbird-ip/bha-api/audio.cgi"
62
68
  * };
63
69
  *
64
- * // Self-describing RTSP audio stream only URL is needed.
70
+ * // Self-describing RTSP audio stream - only URL is needed.
65
71
  * const rtspAudioInput: FMp4AudioInputConfig = {
66
72
  *
67
73
  * url: "rtsp://camera-ip/audio"
@@ -79,22 +85,16 @@ export interface FMp4AudioInputConfig {
79
85
  url: string;
80
86
  }
81
87
  /**
82
- * Options for configuring an fMP4 recording or livestream session.
88
+ * Options for configuring an fMP4 HKSV recording session.
83
89
  *
84
- * @property audioFilters - Audio filters for FFmpeg to process. These are passed as an array of filters.
85
90
  * @property fps - The video frames per second for the session.
86
91
  * @property probesize - Number of bytes to analyze for stream information.
87
92
  * @property timeshift - Timeshift offset for event-based recording (in milliseconds).
88
- * @property transcodeAudio - Transcode audio to AAC. This can be set to false if the audio stream is already in AAC. Defaults to `true`.
89
- * @property videoFilters - Video filters for FFmpeg to process. These are passed as an array of filters.
90
93
  */
91
94
  export interface FMp4RecordingOptions extends FMp4BaseOptions {
92
- audioFilters: string[];
93
95
  fps: number;
94
96
  probesize: number;
95
97
  timeshift: number;
96
- transcodeAudio: boolean;
97
- videoFilters: string[];
98
98
  }
99
99
  /**
100
100
  * Options for configuring an fMP4 livestream session.
@@ -112,94 +112,48 @@ export interface FMp4LivestreamOptions extends FMp4BaseOptions {
112
112
  url: string;
113
113
  }
114
114
  /**
115
- * FFmpeg process controller for HomeKit Secure Video (HKSV) and fMP4 livestreaming and recording.
116
- *
117
- * This class manages the lifecycle and parsing of an FFmpeg process to support HKSV and livestreaming in fMP4 format. It handles initialization segments, media segment
118
- * parsing, buffering, and HomeKit segment generation, and emits events for segment and initialization.
119
- *
120
- * @example
115
+ * Abstract base class for fMP4 FFmpeg processes. Owns the shared command line skeleton (preamble, video mapping, movflags, audio encoding, output format) and the fMP4
116
+ * box-parsing loop. Subclasses provide mode-specific pieces (input args, encoder selection, box handling) via protected hook methods, following the template method
117
+ * pattern.
121
118
  *
122
- * ```ts
123
- * // Create a new recording process for an HKSV event.
124
- * const process = new FfmpegRecordingProcess(ffmpegOptions, recordingConfig, 30, true, 5000000, 0);
125
- *
126
- * // Start the process.
127
- * process.start();
128
- *
129
- * // Iterate over generated segments.
130
- * for await(const segment of process.segmentGenerator()) {
131
- *
132
- * // Send segment to HomeKit, etc.
133
- * }
134
- *
135
- * // Stop when finished.
136
- * process.stop();
137
- * ```
138
- *
139
- * @see FfmpegOptions
119
+ * @see FfmpegRecordingProcess
120
+ * @see FfmpegLivestreamProcess
140
121
  * @see FfmpegProcess
141
122
  * @see {@link https://ffmpeg.org/ffmpeg.html | FFmpeg Documentation}
142
123
  */
143
- declare class FfmpegFMp4Process extends FfmpegProcess {
144
- private hasInitSegment;
145
- private _initSegment;
146
- private isLivestream;
124
+ declare abstract class FfmpegFMp4Process extends FfmpegProcess {
147
125
  private isLoggingErrors;
148
- isTimedOut: boolean;
149
- private recordingBuffer;
150
- segmentLength?: number;
126
+ protected readonly fMp4Options: Required<FMp4BaseOptions>;
127
+ protected readonly recordingConfig: CameraRecordingConfiguration;
151
128
  /**
152
- * Constructs a new fMP4 FFmpeg process for HKSV event recording or livestreaming.
129
+ * Constructs a new fMP4 FFmpeg process. Stores shared state and applies defaults to the base options. The command line is not assembled here...subclasses call
130
+ * `buildCommandLine()` after their own initialization to trigger the template method assembly.
153
131
  *
154
132
  * @param ffmpegOptions - FFmpeg configuration options.
155
133
  * @param recordingConfig - HomeKit recording configuration for the session.
156
- * @param isAudioActive - If `true`, enables audio stream processing.
157
- * @param fMp4Options - Configuration for the fMP4 session (fps, type, url, audio input, etc.).
134
+ * @param fMp4Options - Partial base options with defaults applied for any unset fields.
158
135
  * @param isVerbose - If `true`, enables more verbose logging for debugging purposes. Defaults to `false`.
159
- *
160
- * @example
161
- *
162
- * ```ts
163
- * const process = new FfmpegFMp4Process(ffmpegOptions, recordingConfig, true, { fps: 30 });
164
- * ```
165
136
  */
166
- constructor(ffmpegOptions: FfmpegOptions, recordingConfig: CameraRecordingConfiguration, fMp4Options?: Partial<FMp4LivestreamOptions & FMp4RecordingOptions>, isVerbose?: boolean);
137
+ constructor(ffmpegOptions: FfmpegOptions, recordingConfig: CameraRecordingConfiguration, fMp4Options?: Partial<FMp4BaseOptions>, isVerbose?: boolean);
138
+ private _isVerbose;
139
+ protected buildCommandLine(): void;
140
+ protected abstract inputArgs(): string[];
141
+ protected abstract separateAudioInputArgs(): string[];
142
+ protected abstract audioInputIndex(): number;
143
+ protected abstract videoEncoderArgs(): string[];
144
+ protected abstract postFilterArgs(): string[];
145
+ protected abstract metadataLabel(): string;
146
+ protected abstract handleParsedBox(header: Buffer, data: Buffer, dataLength: number, type: number): void;
167
147
  /**
168
- * Prepares and configures the FFmpeg process for reading and parsing output fMP4 data.
169
- *
170
- * This method is called internally by the process lifecycle and is not typically invoked directly by consumers.
148
+ * Prepares and configures the FFmpeg process for reading and parsing output fMP4 data. The box parsing loop is shared...each complete box is dispatched to the
149
+ * subclass via handleParsedBox().
171
150
  */
172
151
  protected configureProcess(): void;
173
152
  /**
174
- * Retrieves the fMP4 initialization segment generated by FFmpeg.
175
- *
176
- * Waits until the initialization segment is available, then returns it.
177
- *
178
- * @returns A promise resolving to the initialization segment as a Buffer.
179
- *
180
- * @example
181
- *
182
- * ```ts
183
- * const initSegment = await process.getInitSegment();
184
- * ```
185
- */
186
- protected getInitSegment(): Promise<Buffer>;
187
- /**
188
- * Stops the FFmpeg process and performs cleanup, including emitting termination events for segment generators.
189
- *
190
- * This is called as part of the process shutdown sequence.
153
+ * Stops the FFmpeg process and performs cleanup. Subclasses override this to emit mode-specific events before calling super, which handles the shared teardown and
154
+ * emits the "close" event.
191
155
  */
192
156
  protected stopProcess(): void;
193
- /**
194
- * Starts the FFmpeg process, adjusting segment length for livestreams if set.
195
- *
196
- * @example
197
- *
198
- * ```ts
199
- * process.start();
200
- * ```
201
- */
202
- start(): void;
203
157
  /**
204
158
  * Stops the FFmpeg process and logs errors if specified.
205
159
  *
@@ -218,40 +172,7 @@ declare class FfmpegFMp4Process extends FfmpegProcess {
218
172
  * @param exitCode - The exit code from the FFmpeg process.
219
173
  * @param signal - The signal (if any) used to terminate the process.
220
174
  */
221
- protected logFfmpegError(exitCode: number, signal: NodeJS.Signals): void;
222
- /**
223
- * Asynchronously generates complete segments from FFmpeg output, formatted for HomeKit Secure Video.
224
- *
225
- * This async generator yields fMP4 segments as Buffers, or ends on process termination or timeout.
226
- *
227
- * @yields A Buffer containing a complete MP4 segment suitable for HomeKit.
228
- *
229
- * @example
230
- *
231
- * ```ts
232
- * for await(const segment of process.segmentGenerator()) {
233
- *
234
- * // Process each segment for HomeKit.
235
- * }
236
- * ```
237
- */
238
- segmentGenerator(): AsyncGenerator<Buffer>;
239
- /**
240
- * Returns the initialization segment as a Buffer, or null if not yet available.
241
- *
242
- * @returns The initialization segment Buffer, or `null` if not yet generated.
243
- *
244
- * @example
245
- *
246
- * ```ts
247
- * const init = process.initSegment;
248
- * if(init) {
249
- *
250
- * // Use the initialization segment.
251
- * }
252
- * ```
253
- */
254
- get initSegment(): Nullable<Buffer>;
175
+ protected logFfmpegError(exitCode: Nullable<number>, signal: Nullable<NodeJS.Signals>): void;
255
176
  }
256
177
  /**
257
178
  * Manages a HomeKit Secure Video recording FFmpeg process.
@@ -268,6 +189,14 @@ declare class FfmpegFMp4Process extends FfmpegProcess {
268
189
  * @category FFmpeg
269
190
  */
270
191
  export declare class FfmpegRecordingProcess extends FfmpegFMp4Process {
192
+ /**
193
+ * Indicates whether the recording has timed out waiting for FFmpeg output.
194
+ */
195
+ isTimedOut: boolean;
196
+ private readonly fps;
197
+ private readonly probesize;
198
+ private recordingBuffer;
199
+ private readonly timeshift;
271
200
  /**
272
201
  * Constructs a new FFmpeg recording process for HKSV events.
273
202
  *
@@ -277,6 +206,34 @@ export declare class FfmpegRecordingProcess extends FfmpegFMp4Process {
277
206
  * @param isVerbose - If `true`, enables more verbose logging for debugging purposes. Defaults to `false`.
278
207
  */
279
208
  constructor(options: FfmpegOptions, recordingConfig: CameraRecordingConfiguration, fMp4Options?: Partial<FMp4RecordingOptions>, isVerbose?: boolean);
209
+ protected inputArgs(): string[];
210
+ protected separateAudioInputArgs(): string[];
211
+ protected audioInputIndex(): number;
212
+ protected videoEncoderArgs(): string[];
213
+ protected postFilterArgs(): string[];
214
+ protected metadataLabel(): string;
215
+ protected handleParsedBox(header: Buffer, data: Buffer, dataLength: number, type: number): void;
216
+ /**
217
+ * Stops the FFmpeg process and performs cleanup, ensuring the segment generator can exit.
218
+ */
219
+ protected stopProcess(): void;
220
+ /**
221
+ * Asynchronously generates complete segments from FFmpeg output, formatted for HomeKit Secure Video.
222
+ *
223
+ * This async generator yields fMP4 segments as Buffers, or ends on process termination or timeout.
224
+ *
225
+ * @yields A Buffer containing a complete MP4 segment suitable for HomeKit.
226
+ *
227
+ * @example
228
+ *
229
+ * ```ts
230
+ * for await(const segment of process.segmentGenerator()) {
231
+ *
232
+ * // Process each segment for HomeKit.
233
+ * }
234
+ * ```
235
+ */
236
+ segmentGenerator(): AsyncGenerator<Buffer>;
280
237
  }
281
238
  /**
282
239
  * Manages a HomeKit livestream FFmpeg process for generating fMP4 segments.
@@ -295,6 +252,15 @@ export declare class FfmpegRecordingProcess extends FfmpegFMp4Process {
295
252
  * @category FFmpeg
296
253
  */
297
254
  export declare class FfmpegLivestreamProcess extends FfmpegFMp4Process {
255
+ /**
256
+ * Optional override for the fMP4 fragment duration, in milliseconds. When set, the `-frag_duration` argument is updated before starting the FFmpeg process.
257
+ */
258
+ segmentLength?: number;
259
+ private _hasAudioInput;
260
+ private _initSegment;
261
+ private _initSegmentParts;
262
+ private hasInitSegment;
263
+ private readonly livestreamOptions;
298
264
  /**
299
265
  * Constructs a new FFmpeg livestream process.
300
266
  *
@@ -304,6 +270,23 @@ export declare class FfmpegLivestreamProcess extends FfmpegFMp4Process {
304
270
  * @param isVerbose - If `true`, enables more verbose logging for debugging purposes. Defaults to `false`.
305
271
  */
306
272
  constructor(options: FfmpegOptions, recordingConfig: CameraRecordingConfiguration, livestreamOptions: PartialWithId<FMp4LivestreamOptions, "url">, isVerbose?: boolean);
273
+ protected inputArgs(): string[];
274
+ protected separateAudioInputArgs(): string[];
275
+ protected audioInputIndex(): number;
276
+ protected videoEncoderArgs(): string[];
277
+ protected postFilterArgs(): string[];
278
+ protected metadataLabel(): string;
279
+ protected handleParsedBox(header: Buffer, data: Buffer, _dataLength: number, type: number): void;
280
+ /**
281
+ * Starts the FFmpeg process, adjusting the fragment duration if segmentLength has been set.
282
+ *
283
+ * @example
284
+ *
285
+ * ```ts
286
+ * process.start();
287
+ * ```
288
+ */
289
+ start(): void;
307
290
  /**
308
291
  * Gets the fMP4 initialization segment generated by FFmpeg for the livestream.
309
292
  *
@@ -316,5 +299,21 @@ export declare class FfmpegLivestreamProcess extends FfmpegFMp4Process {
316
299
  * ```
317
300
  */
318
301
  getInitSegment(): Promise<Buffer>;
302
+ /**
303
+ * Returns the initialization segment as a Buffer, or null if not yet available.
304
+ *
305
+ * @returns The initialization segment Buffer, or `null` if not yet generated.
306
+ *
307
+ * @example
308
+ *
309
+ * ```ts
310
+ * const init = process.initSegment;
311
+ * if(init) {
312
+ *
313
+ * // Use the initialization segment.
314
+ * }
315
+ * ```
316
+ */
317
+ get initSegment(): Nullable<Buffer>;
319
318
  }
320
319
  export {};