The input file to stream. Expected to be a media file with at least one
audio stream, or, if options.concat
is true, an
ffconcat
playlist file to
play back multiple files in succession. If this is a relative path, it will
be resolved relative to the current working directory
Optional
workingDirectory: stringOptional directory to run ffmpeg
in and output the resulting HLS files.
Defaults to the current working directory of the parent process
Optional
options: HLSStreamOptionsOptional HLS stream options. HLS_STREAM_DEFAULTS will be used to fill in any missing options with default values.
A cold rxjs Observable which emits
HLSStreamProgress events as parsed from ffmpeg
's output. Because
the observable is cold, it will not start the underlying ffmpeg
process
until it is subscribed to. Its unsubscribe process checks if the underlying
process is still running, and if so, it sends a SIGKILL
signal to the
process to terminate it. It will complete when the underlying process exits
with a 0
code, and errors with an HLSStreamError if the process
fails to start, exits with a non-zero code, or fails to parse a progress
update from the process output
The official FFMPEG docs
to learn more about HLS streaming with ffmpeg
.
Creates an observable that generates HLS playlist and segment files from a given input file in real-time using
ffmpeg
. The generated files will be placed in the specified output directory, and the observable will emit HLSStreamProgress objects that report on the progress of the streaming process.The returned observable will not create the underlying
ffmpeg
process until subscribed, and each subscription will create a newffmpeg
process with the same configuration as specified by the given input file, output directory, and options (HLSStreamOptions). This is useful for "replay" and "playlist" functionality, where a series of these observables can be constructed and arranged before running them, but care must be exercised not to subscribe to the same observable multiple times at once, asffmpeg
will gladly try to overwrite the same output files at the same time. In many cases, use of the HLSStreamOptions.concat option is better suited for playlist functionality, and HLSStreamOptions.loopCount for replay / looping.Note:
ffmpeg
HLS streaming will always leave behind the last playlist and segment files it created when the process exits. If the same playlist file names and locations are used on a subsequent run,ffmpeg
will append to the existing playlist files, and preserve the tail of the old segments until they are removed from the playlist, after which they will be deleted. However, any existing segments files that are not referenced by the existing playlist when the newffmpeg
process starts will be ignored, and require manual deletion if they are no longer needed. There is always at least one dangling segment file left behind by eachffmpeg
process.