How do HLS-live-stream incoming batches of individual frames, "appending" to an m3u8 playlist in real-time, with ffmpeg?

In order to provide real-time HLS live streaming, where individual frame sequences are continuously added to a m3u8 playlist, I’m investigating the use of FFmpeg. I’m especially interested in fully grasping the sequential procedures, industry standards, and necessary FFmpeg commands or configurations required to carry out this dynamic real-time HLS streaming.
I would be very grateful for any advice or suggestions from the community to assist me in doing this task successfully.


Creating a real-time HLS (HTTP Live Streaming) live stream by continuously appending individual frames to an m3u8 playlist using FFmpeg can be a complex process. Here’s a detailed guide on how to achieve this:

1. Install FFmpeg

To download FFmpeg on your system follow the below guides:

2. Get ready for your video source

Be prepared with a video source that offers separate frames. This can be either a video source or a series of picture files (such as PNG or JPEG).

3. Create the Initial m3u8 Playlist

Create a first m3u8 playlist that contains a link to your first video segment.

For example:


Save this as playlist.m3u8.

4. Start the FFmpeg real-time segmentation process

Run FFmpeg to split the video stream into manageable chunks and update the playlist continually. Change input.mp4 to the name of your video source.

ffmpeg -i input.mp4 -c:v h264 -hls_time 10 -hls_list_size 5 -hls_wrap 10 -start_number 0 playlist.m3u8
  • -c:v h264: Set the video codec to H.264. Adjust as needed.
  • -hls_time 10: Define the segment duration (in seconds).
  • -hls_list_size 5: Limit the number of segments in the playlist (adjust as needed).
  • -hls_wrap 10: Specify the maximum number of segment files to retain before overwriting (should be larger than -hls_list_size).
  • -start_number 0: Set the initial segment number.

5. Keep Adding New Frames

As additional frames become available, manually modify the playlist playlist.m3u8 file with new entries for the segments, then use FFmpeg to convert them into video segments (e.g., segment_1.ts, segment_2.ts).

6. Stream the HLS protocol

Deliver the HLS stream to viewers via a web server or streaming software. Make that the segment segment.m3u8 and playlist playlist.m3u8 files can be accessed through HTTP.

The m3u8 playlist will be updated often when new segments are added, simulating a real-time HLS live stream.

1 Like