Ios – Live playlist, must #EXT-X-TARGETDURATION and #EXTINF be equal

avplayerhttp-live-streamingios

I have this m3u8 file. #EXT-X-TARGETDURATION is 8. the #EXTINF of first segment is 6. When the avplayer switched to this m3u8, it gave the following error.

Error Domain=CoreMediaErrorDomain Code=-12312 \"Media Entry time value
does not match previous playlist for MEDIA-SEQUENCE 477000: 8.000000
vs 6.000000\" UserInfo={NSDescription=Media Entry time value does not
match previous playlist for MEDIA-SEQUENCE 477000: 8.000000 vs
6.000000}"

 #EXTM3U
 #EXT-X-MEDIA-SEQUENCE:477000
#EXT-X-ALLOW-CACHE:NO
    #EXT-X-VERSION:2
    #EXT-X-FAXS-CM:URI="xxxxxxxx"
    #EXT-X-KEY:METHOD=xxxxxxx
    #EXT-X-TARGETDURATION:8
    #EXTINF:6,
    477000.ts
    #EXTINF:8,
    477001.ts
    #EXTINF:8,
    477002.ts
    #EXTINF:8,
    477003.ts
    #EXTINF:8,
    477004.ts
    #EXTINF:8,
    477005.ts
    #EXTINF:8,
    477006.ts

The question is
in a live playlist, must #EXT-X-TARGETDURATION and #EXTINF of each segment be equal?! I can't find any document from Apple to define this rule. In this document, https://developer.apple.com/library/ios/technotes/tn2288/_index.html
the Lie Playlist sample, they are all same.

Best Answer

Short answer: No.

Wether Live or VOD, EXT-X-TARGETDURATION specifies a maximum duration for the segments in the playlist. The actual duration specified by EXTINF may be less. In the HLS draft [1] it says:

The EXT-X-TARGETDURATION tag specifies the maximum Media Segment duration. The EXTINF duration of each Media Segment in the Playlist file, when rounded to the nearest integer, MUST be less than or equal to the target duration; longer segments can trigger playback stalls or other errors.

The way I read the error

Media Entry time value does not match previous playlist for MEDIA-SEQUENCE 477000: 8.000000 vs 6.000000

is that the EXTINF for the particular segment with sequence number 477000, 477000.ts that is, was 8.000000 in the previous playlist and is 6.000000 in the playlist just switched to. AFAIK there is no regulation that demands for those durations to be equal. Maybe the player cannot handle this for some reason.

You can test your HLS stream for conformance using Apple's MediaStreamValidator [2] command-line tool. It will show any issues that the stream might have.

[1] https://datatracker.ietf.org/doc/html/draft-pantos-http-live-streaming-19#section-4.3.3.1

[2] https://developer.apple.com/library/ios/technotes/tn2235/_index.html

Related Topic