Every few seconds I'm receiving a chunk of a long audio file from a server. I want to segment those chunks and create a m3u8 playlist to play the audio in the browser.
I can create the m3u8 file and append segments every few seconds to it until I received the last chunk and the file can be played in the browser. The problem is that ffmpeg adds the #EXT-X-DISCONTINUITY tag to the m3u8 file which adds short silence periods to the audio and the playback in the browser doesn't sound fluent.
Is there are way to tell ffmpeg that all my independent files actually belong together (same source and encoding) and stop adding the #EXT-X-DISCONTINUITY tags? Or is there a way to avoid the short silence periods added by this tag? Or are there any other ways I can try to create a fluent audio stream from independent files?
My final m3u8 file:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:EVENT
#EXTINF:1.792000,
http://localhost:9000/aacf6dc4-9f3e-4f76-86b6-3e0f01a65d88000000.ts
#EXT-X-DISCONTINUITY
#EXTINF:1.792000,
http://localhost:9000/aacf6dc4-9f3e-4f76-86b6-3e0f01a65d88000001.ts
...
#EXT-X-DISCONTINUITY
#EXTINF:1.792000,
http://localhost:9000/aacf6dc4-9f3e-4f76-86b6-3e0f01a65d88000006.ts
#EXT-X-ENDLIST
My ffmpeg commands:
# create the playlist
ffmpeg -y -i <chunk.flac> -hls_playlist_type event -hls_base_url http://localhost:9000/ -hls_segment_filename <segment> -hls_time 2 -hls_flags omit_endlist playlist.m3u8
# append to playlist
ffmpeg -y -i <chunk.flac> -hls_playlist_type event -hls_base_url http://localhost:9000/ -hls_segment_filename <segment> -hls_time 2 -hls_flags omit_endlist+append_list playlist.m3u8
# finish the playlist
ffmpeg -y -i <chunk.flac> -hls_playlist_type event -hls_base_url http://localhost:9000/ -hls_segment_filename <segment> -hls_time 2 -hls_flags append_list playlist.m3u8