16b9cb9d by David LaPalomento

Default segment duration to target duration if unspecified

When parsing a media playlist, if a URI is encountered without a corresponding #EXTINF with valid duration, default its value to the last encountered #EXT-X-TARGETDURATION tag.
1 parent fba877e5
......@@ -422,6 +422,15 @@
currentUri.uri = entry.uri;
uris.push(currentUri);
// if no explicit duration was declared, use the target duration
if (this.manifest.targetDuration &&
!('duration' in currentUri)) {
this.trigger('warn', {
message: 'defaulting segment duration to the target duration'
});
currentUri.duration = this.manifest.targetDuration;
}
// prepare for the next URI
currentUri = {};
},
......
......@@ -16,6 +16,7 @@
"length": 587500,
"offset": 522828
},
"duration": 10,
"uri": "hls_450k_video.ts"
},
{
......@@ -135,6 +136,7 @@
"length": 44556,
"offset": 8353216
},
"duration": 10,
"uri": "hls_450k_video.ts"
}
],
......
......@@ -8,9 +8,11 @@
"uri": "/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts"
},
{
"duration": 8,
"uri": "/test/ts-files/tvy7/56be1cef869a1c0cc8e38864ad1add17d187f051-hi720.ts"
},
{
"duration": 8,
"uri": "/test/ts-files/tvy7/549c8c77f55f049741a06596e5c1e01dacaa46d0-hi720.ts"
}
],
......
......@@ -8,6 +8,7 @@
"uri": "hls_450k_video.ts"
},
{
"duration": 10,
"uri": "hls_450k_video.ts"
},
{
......
......@@ -8,12 +8,15 @@
"uri": "/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts"
},
{
"duration": 8,
"uri": "/test/ts-files/tvy7/56be1cef869a1c0cc8e38864ad1add17d187f051-hi720.ts"
},
{
"duration": 8,
"uri": "/test/ts-files/tvy7/549c8c77f55f049741a06596e5c1e01dacaa46d0-hi720.ts"
},
{
"duration": 8,
"uri": "/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts"
}
],
......
{
"allowCache": true,
"mediaSequence": 0,
"playlistType": "VOD",
"targetDuration": 10,
"segments": [{
"uri": "001.ts"
}, {
"uri": "002.ts",
"duration": 9
}, {
"uri": "003.ts",
"duration": 7
}, {
"uri": "004.ts",
"duration": 10
}]
}
#EXTM3U
001.ts
#EXT-X-TARGETDURATION:9
002.ts
#EXTINF:7
003.ts
#EXT-X-TARGETDURATION:10
004.ts
\ No newline at end of file