Search code examples
m3u8http-live-streaming

Is there a way to create a m3u8 playlist to loop a file in a stream?


The title says it all, really. I have an mp4 file sitting on S3, and when I play it (be it through the browser or any other player) it just stops at the end. Is there a way to make an m3u8 playlist that instructs the player to start from the beginning when the stream ends?


Solution

  • You can't do it by simply modifying the playlist. You can either implement this client-side for a specific player, eg. with a player supporting a JavaScript API on web, or loop and stream the same file over and over as a Live stream instead of VOD.

    For example, with ffmpeg you don't have the option to loop the file forever but you can create a playlist.txt containing:

    file 'input.mp4'
    file 'input.mp4'
    file 'input.mp4'
    [...]
    

    You then stream the playlist:

    ffmpeg -f concat -i playlist.txt playlist.m3u8