Skip to content

Commit

Permalink
feat: output segment title from EXTINF (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
Genteure authored Jul 7, 2023
1 parent 516ab67 commit 4adaa2c
Show file tree
Hide file tree
Showing 16 changed files with 108 additions and 51 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Manifest {
discontinuityStarts: [number],
segments: [
{
title: string,
byterange: {
length: number,
offset: number
Expand Down
5 changes: 5 additions & 0 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ export default class Parser extends Stream {
message: 'defaulting discontinuity sequence to zero'
});
}

if (entry.title) {
currentUri.title = entry.title;
}

if (entry.duration > 0) {
currentUri.duration = entry.duration;
}
Expand Down
12 changes: 8 additions & 4 deletions test/fixtures/integration/disc-sequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,27 @@ module.exports = {
{
duration: 10,
timeline: 3,
uri: '001.ts'
uri: '001.ts',
title: '0'
},
{
duration: 19,
timeline: 3,
uri: '002.ts'
uri: '002.ts',
title: '0'
},
{
discontinuity: true,
duration: 10,
timeline: 4,
uri: '003.ts'
uri: '003.ts',
title: '0'
},
{
duration: 11,
timeline: 4,
uri: '004.ts'
uri: '004.ts',
title: '0'
}
],
targetDuration: 19,
Expand Down
27 changes: 18 additions & 9 deletions test/fixtures/integration/discontinuity.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,59 @@ module.exports = {
{
duration: 10,
timeline: 0,
uri: '001.ts'
uri: '001.ts',
title: '0'
},
{
duration: 19,
timeline: 0,
uri: '002.ts'
uri: '002.ts',
title: '0'
},
{
discontinuity: true,
duration: 10,
timeline: 1,
uri: '003.ts'
uri: '003.ts',
title: '0'
},
{
duration: 11,
timeline: 1,
uri: '004.ts'
uri: '004.ts',
title: '0'
},
{
discontinuity: true,
duration: 10,
timeline: 2,
uri: '005.ts'
uri: '005.ts',
title: '0'
},
{
duration: 10,
timeline: 2,
uri: '006.ts'
uri: '006.ts',
title: '0'
},
{
duration: 10,
timeline: 2,
uri: '007.ts'
uri: '007.ts',
title: '0'
},
{
discontinuity: true,
duration: 10,
timeline: 3,
uri: '008.ts'
uri: '008.ts',
title: '0'
},
{
duration: 16,
timeline: 3,
uri: '009.ts'
uri: '009.ts',
title: '0'
}
],
targetDuration: 19,
Expand Down
12 changes: 8 additions & 4 deletions test/fixtures/integration/emptyMediaSequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,26 @@ module.exports = {
{
duration: 6.64,
timeline: 0,
uri: '/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts'
uri: '/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts',
title: '{}'
},
{
duration: 6.08,
timeline: 0,
uri: '/test/ts-files/tvy7/56be1cef869a1c0cc8e38864ad1add17d187f051-hi720.ts'
uri: '/test/ts-files/tvy7/56be1cef869a1c0cc8e38864ad1add17d187f051-hi720.ts',
title: '{}'
},
{
duration: 6.6,
timeline: 0,
uri: '/test/ts-files/tvy7/549c8c77f55f049741a06596e5c1e01dacaa46d0-hi720.ts'
uri: '/test/ts-files/tvy7/549c8c77f55f049741a06596e5c1e01dacaa46d0-hi720.ts',
title: '{}'
},
{
duration: 5,
timeline: 0,
uri: '/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts'
uri: '/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts',
title: '{}'
}
],
targetDuration: 8,
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/integration/extXPlaylistTypeInvalidPlaylist.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ module.exports = {
{
duration: 6.64,
timeline: 0,
uri: '/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts'
uri: '/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts',
title: '{}'
}
],
targetDuration: 8,
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/integration/extinf.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ module.exports = {
},
duration: 10,
timeline: 0,
uri: 'hls_450k_video.ts'
uri: 'hls_450k_video.ts',
title: ';asljasdfii11)))00,'
},
{
byterange: {
Expand Down
12 changes: 8 additions & 4 deletions test/fixtures/integration/invalidMediaSequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,26 @@ module.exports = {
{
duration: 6.64,
timeline: 0,
uri: '/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts'
uri: '/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts',
title: '{}'
},
{
duration: 6.08,
timeline: 0,
uri: '/test/ts-files/tvy7/56be1cef869a1c0cc8e38864ad1add17d187f051-hi720.ts'
uri: '/test/ts-files/tvy7/56be1cef869a1c0cc8e38864ad1add17d187f051-hi720.ts',
title: '{}'
},
{
duration: 6.6,
timeline: 0,
uri: '/test/ts-files/tvy7/549c8c77f55f049741a06596e5c1e01dacaa46d0-hi720.ts'
uri: '/test/ts-files/tvy7/549c8c77f55f049741a06596e5c1e01dacaa46d0-hi720.ts',
title: '{}'
},
{
duration: 5,
timeline: 0,
uri: '/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts'
uri: '/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts',
title: '{}'
}
],
targetDuration: 8,
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/integration/liveMissingSegmentDuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module.exports = {
{
duration: 6.64,
timeline: 0,
uri: '/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts'
uri: '/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts',
title: '{}'
},
{
duration: 8,
Expand Down
27 changes: 18 additions & 9 deletions test/fixtures/integration/liveStart30sBefore.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,56 @@ module.exports = {
{
duration: 10,
timeline: 0,
uri: '001.ts'
uri: '001.ts',
title: '0'
},
{
duration: 19,
timeline: 0,
uri: '002.ts'
uri: '002.ts',
title: '0'
},
{
duration: 10,
timeline: 0,
uri: '003.ts'
uri: '003.ts',
title: '0'
},
{
duration: 11,
timeline: 0,
uri: '004.ts'
uri: '004.ts',
title: '0'
},
{
duration: 10,
timeline: 0,
uri: '005.ts'
uri: '005.ts',
title: '0'
},
{
duration: 10,
timeline: 0,
uri: '006.ts'
uri: '006.ts',
title: '0'
},
{
duration: 10,
timeline: 0,
uri: '007.ts'
uri: '007.ts',
title: '0'
},
{
duration: 10,
timeline: 0,
uri: '008.ts'
uri: '008.ts',
title: '0'
},
{
duration: 16,
timeline: 0,
uri: '009.ts'
uri: '009.ts',
title: '0'
}
],
targetDuration: 10,
Expand Down
12 changes: 8 additions & 4 deletions test/fixtures/integration/mediaSequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,26 @@ module.exports = {
{
duration: 6.64,
timeline: 0,
uri: '/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts'
uri: '/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts',
title: '{}'
},
{
duration: 6.08,
timeline: 0,
uri: '/test/ts-files/tvy7/56be1cef869a1c0cc8e38864ad1add17d187f051-hi720.ts'
uri: '/test/ts-files/tvy7/56be1cef869a1c0cc8e38864ad1add17d187f051-hi720.ts',
title: '{}'
},
{
duration: 6.6,
timeline: 0,
uri: '/test/ts-files/tvy7/549c8c77f55f049741a06596e5c1e01dacaa46d0-hi720.ts'
uri: '/test/ts-files/tvy7/549c8c77f55f049741a06596e5c1e01dacaa46d0-hi720.ts',
title: '{}'
},
{
duration: 5,
timeline: 0,
uri: '/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts'
uri: '/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts',
title: '{}'
}
],
targetDuration: 8,
Expand Down
12 changes: 8 additions & 4 deletions test/fixtures/integration/missingMediaSequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,26 @@ module.exports = {
{
duration: 6.64,
timeline: 0,
uri: '/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts'
uri: '/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts',
title: '{}'
},
{
duration: 6.08,
timeline: 0,
uri: '/test/ts-files/tvy7/56be1cef869a1c0cc8e38864ad1add17d187f051-hi720.ts'
uri: '/test/ts-files/tvy7/56be1cef869a1c0cc8e38864ad1add17d187f051-hi720.ts',
title: '{}'
},
{
duration: 6.6,
timeline: 0,
uri: '/test/ts-files/tvy7/549c8c77f55f049741a06596e5c1e01dacaa46d0-hi720.ts'
uri: '/test/ts-files/tvy7/549c8c77f55f049741a06596e5c1e01dacaa46d0-hi720.ts',
title: '{}'
},
{
duration: 5,
timeline: 0,
uri: '/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts'
uri: '/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts',
title: '{}'
}
],
targetDuration: 8,
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/integration/missingSegmentDuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module.exports = {
{
duration: 6.64,
timeline: 0,
uri: '/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts'
uri: '/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts',
title: '{}'
},
{
duration: 8,
Expand Down
12 changes: 8 additions & 4 deletions test/fixtures/integration/negativeMediaSequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,26 @@ module.exports = {
{
duration: 6.64,
timeline: 0,
uri: '/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts'
uri: '/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts',
title: '{}'
},
{
duration: 6.08,
timeline: 0,
uri: '/test/ts-files/tvy7/56be1cef869a1c0cc8e38864ad1add17d187f051-hi720.ts'
uri: '/test/ts-files/tvy7/56be1cef869a1c0cc8e38864ad1add17d187f051-hi720.ts',
title: '{}'
},
{
duration: 6.6,
timeline: 0,
uri: '/test/ts-files/tvy7/549c8c77f55f049741a06596e5c1e01dacaa46d0-hi720.ts'
uri: '/test/ts-files/tvy7/549c8c77f55f049741a06596e5c1e01dacaa46d0-hi720.ts',
title: '{}'
},
{
duration: 5,
timeline: 0,
uri: '/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts'
uri: '/test/ts-files/tvy7/6cfa378684ffeb1c455a64dae6c103290a1f53d4-hi720.ts',
title: '{}'
}
],
targetDuration: 8,
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/integration/playlistMediaSequenceHigher.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module.exports = {
{
duration: 6.64,
timeline: 0,
uri: '/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts'
uri: '/test/ts-files/tvy7/8a5e2822668b5370f4eb1438b2564fb7ab12ffe1-hi720.ts',
title: '{}'
}
],
targetDuration: 8,
Expand Down
Loading

0 comments on commit 4adaa2c

Please sign in to comment.