import type { Readable, Writable } from "node:stream"; import type { ChildProcess } from "node:child_process"; /** * Resolves the FFmpeg executable path. Checks Channels DVR (macOS, Windows, Linux), then the bundled ffmpeg-for-homebridge, then system PATH. The resolved path is * cached for subsequent calls. * @returns Promise resolving to the FFmpeg path if found, or undefined if not available. */ export declare function resolveFFmpegPath(): Promise; /** * Result from spawning an FFmpeg process. */ export interface FFmpegProcess { kill: () => void; process: ChildProcess; stdin: Writable; stdout: Readable; } /** * Spawns an FFmpeg process configured to transcode WebM (H264+Opus) to fMP4 (H264+AAC). The process reads from stdin and writes to stdout, allowing it to be * integrated into a Node.js stream pipeline. Video is passed through unchanged; audio is transcoded from Opus to AAC for HLS compatibility. * * FFmpeg arguments: * - `-hide_banner -loglevel warning`: Reduce noise, only show warnings/errors * - `-probesize 16384`: Limit input probing to 16KB (Chrome's WebM header fits well under this) to minimize startup delay * - `-i pipe:0`: Read input from stdin * - `-c:v copy`: Copy video stream without re-encoding (H264 passthrough) * - `-c:a aac -b:a `: Transcode audio to AAC at specified bitrate * - `-f mp4`: Output MP4 container format * - `-movflags frag_keyframe+empty_moov+default_base_moof`: Streaming-friendly fMP4 flags * - `-flush_packets 1`: Flush output immediately after each packet to minimize latency * - `pipe:1`: Write output to stdout * @param audioBitrate - Audio bitrate in bits per second (e.g., 256000 for 256 kbps). * @param onError - Callback invoked when FFmpeg exits unexpectedly or encounters an error. * @param streamId - Stream identifier for logging. * @param comment - Optional comment metadata (channel name or domain) to embed in the output. * @returns FFmpeg process wrapper with stdin, stdout, and kill function. */ export declare function spawnFFmpeg(audioBitrate: number, onError: (error: Error) => void, streamId?: string, comment?: string): FFmpegProcess; /** * Spawns an FFmpeg process configured to remux fMP4 input to MPEG-TS output with codec copy. The process reads a continuous fMP4 stream (init segment followed by * media segments) from stdin and writes MPEG-TS to stdout. No transcoding occurs — both video (H264) and audio (AAC) are copied unchanged — so CPU usage is minimal. * * FFmpeg arguments: * - `-hide_banner -loglevel warning`: Reduce noise, only show warnings/errors * - `-probesize 16384`: Limit input probing to 16KB (fMP4 init segment is ~1.3KB) to minimize startup delay * - `-f mp4 -i pipe:0`: Read fragmented MP4 from stdin * - `-c copy`: Copy both video and audio codecs without transcoding * - `-f mpegts`: Output MPEG-TS container format * - `-mpegts_pmt_start_pid 0x0020`: Use ATSC-conventional PMT PID range instead of FFmpeg's default (0x1000). Minimum allowed value is 0x0020 (32). * - `-mpegts_start_pid 0x0031`: Use ATSC-conventional elementary stream PIDs instead of FFmpeg's defaults (0x100+) * - `-mpegts_service_type digital_tv`: Label the service as digital TV in the PMT service descriptor * - `-pat_period 0.1`: Repeat PAT/PMT tables every 100ms, matching ATSC broadcast frequency * - `-pcr_period 40`: Insert PCR timestamps every 40ms, matching ATSC broadcast convention * - `-flush_packets 1`: Flush output immediately after each packet to minimize latency * - `pipe:1`: Write output to stdout * @param onError - Callback invoked when FFmpeg exits unexpectedly or encounters an error. * @param streamId - Optional stream identifier for logging. * @returns FFmpeg process wrapper with stdin, stdout, and kill function. */ export declare function spawnMpegTsRemuxer(onError: (error: Error) => void, streamId?: string): FFmpegProcess; /** * Checks if FFmpeg is available on the system. This resolves the FFmpeg path and caches it for use by spawnFFmpeg(). * @returns Promise resolving to true if FFmpeg is available, false otherwise. */ export declare function isFFmpegAvailable(): Promise;