Playlist vs segment duration mismatch (negative values)

When I run mediastreamvalidator on my HLS stream, I get the following MUST fix issue:


--------------------------------------------------------------------------------
MUST fix issues
--------------------------------------------------------------------------------


Error: Playlist vs segment duration mismatch
--> Detail:  Segment duration -56.0000, Playlist duration: 8.0000
--> Source:  https://d1vyzmpse3ih8.cloudfront.net/out/v1/4c74cc7ba91843acac917f39e455ae50/index_3.m3u8 - index_3_356731.ts?m=1520138727


--> Detail:  Segment duration -60.0000, Playlist duration: 8.0000
--> Source:  https://d1vyzmpse3ih8.cloudfront.net/out/v1/4c74cc7ba91843acac917f39e455ae50/index_5.m3u8 - index_5_356693.ts?m=1520138727


--> Detail:  Segment duration -56.0000, Playlist duration: 8.0000
--> Source:  https://d1vyzmpse3ih8.cloudfront.net/out/v1/4c74cc7ba91843acac917f39e455ae50/index_2.m3u8 - index_2_356694.ts?m=1520138727


I don't understand what this means, so I don't know how to go about fixing it. Per the mediastreamvalidator my segments are reporting a negative duration! If I download the .ts file manually, it plays fine on my Mac.

Replies

Your segments may have discontinuities between them. If so you will need to enter the tag

#EXT-X-DISCONTINUITY
between them. The HLS spec specifies that you need to mark discontinuities in the following scenarios:
  • file format
  • number, type, and identifiers of tracks
  • timestamp sequence

See Section 4.3.2.3: https://tools.ietf.org/html/rfc8216

What it reports for segment duration is the difference between the start time stamp of this segment and the start time stamp of the next segment.

So a negative means that the time stamp jumps back.

I have duration issue too, but with invalid positive duration.

Could you please give more explanation, which time stamps are used? Is it only video frames PTSs or audio frames counts too? Should a frame be keyframe or not?

mediastreamvalidator is looking at PTS (or PCR?) in the actual segment file and matchign it to playlist metadata. There is not standard for this but the EXTINF section kind of impiies it should be reasonably accurate.
If it's under some percentage value (Apple please share this!!!) Mediastreamvalidator reports these as "SHOULD Fix". Clearly negative is not, and will cause many players to fail.