Node server to transcode video files and stream on the fly via HLS.
Note: requires ffmpeg
Streaming videos of any format on demand with seeking.
Using FFmpeg and HTTP Live Streaming (HLS) protocol.
Generate the full .m3u8
playlist immediately so the client behaves as if the entire video is ready to play. In order to make the playlist ahead of time we need to set a static segment length. When the client seeks to a portion of the video that has not been transcoded yet, we cancel the current job and start a new one.
- Receive request to start stream session (i.e.
localhost:4000/stream/name-of-movie.mkv
) - Get metadata from video file using FFprobe
- Use file metadata & client limitations to determine how the video will be transcoded (or if)
- Generate
.m3u8
playlists - Start the FFmpeg job of remuxing video to HLS
- Listen for
.m3u8
and.ts
requests from client player (HLS.js)