GlennS
GlennS

Reputation: 5621

When generating an M3U8 HLS playlist, should I include media segments which don't exist yet?

I am generating m3u8 media playlists for HLS https://www.rfc-editor.org/rfc/rfc8216

Should I include each media segment URL (for an MPEG-2 transport stream file) in the media playlist before data becomes available at that URLs? Or should I only include video segments which have finished recording and once I know the data is ready to download, and wait for the HLS client to re-request the playlist?

I feel like that standard isn't very clear on this point.

I note that for at least one HLS client (HLS.js), it requires at least one media segment to exist in the media playlist, otherwise it has a tizzy. It's possible this is just a bug, of course.

As a bit of background, the media segments in my playlist are Amazon S3 URLs. I instruct a different machine to start uploading the video segments to S3 when I receive a request for a playlist.

Upvotes: 1

Views: 774

Answers (2)

jmsn
jmsn

Reputation: 1080

Doing so would violate the HLS spec Section 6.2.1[1]:

Any Media Segment that is specified in a Playlist loaded by a client MUST be available for immediate download, or playback errors can occur. Once download starts, its transfer rate SHOULD NOT be constrained by the segment production process.

[1] https://www.rfc-editor.org/rfc/rfc8216#section-6.2.1

Upvotes: 2

szatmary
szatmary

Reputation: 31140

If the file doesn’t exist, the server will return a 404. Most players will just stop at this point.

Upvotes: 1

Related Questions