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)
Clone this repo and create a media
directory in root
Add some sample media files in there (preferably several minutes duration). Get samples here
npm run start
Go to localhost:4000
to view a list of files and open a stream session.
Get client player/device/limitations on open stream request.
Selecting best encoding options based on file and client capabilities.
See about direct play if possible.
Master playlist needs correct variation strings.
Would appreciate any help at all.