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

First you need to download FFmpeg on your system use the following the below guides:

  1. 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).

  2. 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.

  1. 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.
  1. 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).

  1. 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.

Do let me know if you need more help regarding this.


Great! Just want to know what challenges might arise if there is a delay in generating and appending new frames to the HLS playlist in real-time using ffmpeg?

As far as I know, lag or gaps in the live stream may occur if there is a delay in creating and adding new frames. You can notice that the audio and video are not synchronized or there are interruptions. The frame creation method must be made as efficient as possible to work in real-time and add new frames to the HLS playlist quickly in order to remedy this.

Ok, then, how can newcomers troubleshoot playback issues caused by mismatched frame rates between the input frames and the specified frame rate in the ffmpeg command for HLS live streaming?

1 Like

Well Nora, new users should carefully check and synchronize the frame rate given in the -framerate option of the ffmpeg command with the actual frame rate of the incoming frames if there are playback issues caused by a mismatch in frame rates.

Furthermore, reviewing the logs for any errors or warnings pertaining to frame rate discrepancies can offer important information about how to fix the playback problems. For a precise and seamless HLS live feed, frame rates must be kept constant.