Home > Net >  Do the various HLS files have to be stored in separate folders?
Do the various HLS files have to be stored in separate folders?

Time:01-31

Background:
The HLS RFC doesn't seem to mention anything about this. I'm creating a script that generates a 720p.m3u8 file for a series of 720p resolution .ts files. Then it uses FFMPEG to generate 480p .ts files using the 720p .ts files and generates a 480p.m3u8 file.
Then it generates a master playlist.m3u8 file which points to the 720p.m3u8 and 480p.m3u8 files.

Master:

#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=3145728,RESOLUTION=1280x720"
720p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1572864,RESOLUTION=854x480"
480p.m3u8

Question:

  1. Is it ok to have all the .ts files of all resolutions stored in the same folder along with their respective m3u8 files and the master m3u8 file? Or should the .ts and .m3u8 files of each resolution be stored in separate folders and the master m3u8 be in the parent folder? Like this:

    #EXTM3U
    #EXT-X-STREAM-INF:BANDWIDTH=3145728,RESOLUTION=1280x720"
    720p_folder/720p.m3u8
    #EXT-X-STREAM-INF:BANDWIDTH=1572864,RESOLUTION=854x480"
    480p_folder/480p.m3u8

  2. The multivariant playlist here shows m3u8 locations as full URL's http://example.com/low/index.m3u8. Is that how it should be, or can it be a relative folder path like I've shown above (480p_folder/480p.m3u8)?

This is for accessing via VideoJS from various client browsers across the world, and the .ts and .m3u8 files will be stored on an AWS S3 server.

CodePudding user response:

  1. Folders for the different renditions are commonly used but there is absolutely no requirement for it.

  2. All URLs in a Multivariant playlist (used to be called master playlist) and in the different variant playlists can be relative or absolute, without really any restrictions. Things to consider here are:

    1. With absolute URLs, it's easy to host just the playlist files elsewhere while all URLs will still work
    2. With relative URLs, it's easy to move or copy the content to other locations as long as m3u8 playlist and media files are kept together.

As a side note, you should consider using mp4 chunks instead of ts unless you have a technical reason not to. There are hardly any devices left that only support ts but not mp4, and for using some HLS features, the use of mp4 is required (at least for Apple devices), e.g.:

  • Using the more efficient HEVC codec 1
  • Using xHE-AAC, Apple Lossless, or FLAC audio 2
  • Using the IMSC1 subtitle format 3
  • Related