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 @@ ...@@ -422,6 +422,15 @@
422 currentUri.uri = entry.uri; 422 currentUri.uri = entry.uri;
423 uris.push(currentUri); 423 uris.push(currentUri);
424 424
425 // if no explicit duration was declared, use the target duration
426 if (this.manifest.targetDuration &&
427 !('duration' in currentUri)) {
428 this.trigger('warn', {
429 message: 'defaulting segment duration to the target duration'
430 });
431 currentUri.duration = this.manifest.targetDuration;
432 }
433
425 // prepare for the next URI 434 // prepare for the next URI
426 currentUri = {}; 435 currentUri = {};
427 }, 436 },
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
16 "length": 587500, 16 "length": 587500,
17 "offset": 522828 17 "offset": 522828
18 }, 18 },
19 "duration": 10,
19 "uri": "hls_450k_video.ts" 20 "uri": "hls_450k_video.ts"
20 }, 21 },
21 { 22 {
...@@ -135,8 +136,9 @@ ...@@ -135,8 +136,9 @@
135 "length": 44556, 136 "length": 44556,
136 "offset": 8353216 137 "offset": 8353216
137 }, 138 },
139 "duration": 10,
138 "uri": "hls_450k_video.ts" 140 "uri": "hls_450k_video.ts"
139 } 141 }
140 ], 142 ],
141 "targetDuration": 10 143 "targetDuration": 10
142 }
...\ No newline at end of file ...\ No newline at end of file
144 }
......
...@@ -8,11 +8,13 @@ ...@@ -8,11 +8,13 @@
8 "uri": "/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts" 8 "uri": "/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts"
9 }, 9 },
10 { 10 {
11 "duration": 8,
11 "uri": "/test/ts-files/tvy7/56be1cef869a1c0cc8e38864ad1add17d187f051-hi720.ts" 12 "uri": "/test/ts-files/tvy7/56be1cef869a1c0cc8e38864ad1add17d187f051-hi720.ts"
12 }, 13 },
13 { 14 {
15 "duration": 8,
14 "uri": "/test/ts-files/tvy7/549c8c77f55f049741a06596e5c1e01dacaa46d0-hi720.ts" 16 "uri": "/test/ts-files/tvy7/549c8c77f55f049741a06596e5c1e01dacaa46d0-hi720.ts"
15 } 17 }
16 ], 18 ],
17 "targetDuration": 8 19 "targetDuration": 8
18 }
...\ No newline at end of file ...\ No newline at end of file
20 }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
8 "uri": "hls_450k_video.ts" 8 "uri": "hls_450k_video.ts"
9 }, 9 },
10 { 10 {
11 "duration": 10,
11 "uri": "hls_450k_video.ts" 12 "uri": "hls_450k_video.ts"
12 }, 13 },
13 { 14 {
...@@ -16,4 +17,4 @@ ...@@ -16,4 +17,4 @@
16 } 17 }
17 ], 18 ],
18 "targetDuration": 10 19 "targetDuration": 10
19 }
...\ No newline at end of file ...\ No newline at end of file
20 }
......
...@@ -8,14 +8,17 @@ ...@@ -8,14 +8,17 @@
8 "uri": "/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts" 8 "uri": "/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts"
9 }, 9 },
10 { 10 {
11 "duration": 8,
11 "uri": "/test/ts-files/tvy7/56be1cef869a1c0cc8e38864ad1add17d187f051-hi720.ts" 12 "uri": "/test/ts-files/tvy7/56be1cef869a1c0cc8e38864ad1add17d187f051-hi720.ts"
12 }, 13 },
13 { 14 {
15 "duration": 8,
14 "uri": "/test/ts-files/tvy7/549c8c77f55f049741a06596e5c1e01dacaa46d0-hi720.ts" 16 "uri": "/test/ts-files/tvy7/549c8c77f55f049741a06596e5c1e01dacaa46d0-hi720.ts"
15 }, 17 },
16 { 18 {
19 "duration": 8,
17 "uri": "/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts" 20 "uri": "/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts"
18 } 21 }
19 ], 22 ],
20 "targetDuration": 8 23 "targetDuration": 8
21 }
...\ No newline at end of file ...\ No newline at end of file
24 }
......
1 {
2 "allowCache": true,
3 "mediaSequence": 0,
4 "playlistType": "VOD",
5 "targetDuration": 10,
6 "segments": [{
7 "uri": "001.ts"
8 }, {
9 "uri": "002.ts",
10 "duration": 9
11 }, {
12 "uri": "003.ts",
13 "duration": 7
14 }, {
15 "uri": "004.ts",
16 "duration": 10
17 }]
18 }
1 #EXTM3U
2 001.ts
3 #EXT-X-TARGETDURATION:9
4 002.ts
5 #EXTINF:7
6 003.ts
7 #EXT-X-TARGETDURATION:10
8 004.ts
...\ No newline at end of file ...\ No newline at end of file