Skip to content

Commit

Permalink
fix(#56): $Time$ segments not replaced
Browse files Browse the repository at this point in the history
  • Loading branch information
bwallberg committed Feb 16, 2024
1 parent 8f2d8b9 commit 56f0681
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/manifests/handlers/dash/segment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default async function dashSegmentHandler(
const urlSearchParams = new URLSearchParams(event.queryStringParameters);
const pathStem = path.basename(event.path).replace('.mp4', '');
// Get the number part after "segment_"
const [, reqSegmentIndexStr, representationIdStr, bitrateStr] =
const [, reqSegmentIndexStr, representationIdStr, bitrateStr, timeStr] =
pathStem.split('_');
// Build correct Source Segment url
// segment templates may contain a width parameter "$Number%0[width]d$", and then we need to zero-pad them to that length
Expand All @@ -54,6 +54,9 @@ export default async function dashSegmentHandler(
representationIdStr
);
}
if (timeStr) {
segmentUrl = segmentUrl.replace('$Time$', timeStr);
}
if (bitrateStr) {
urlSearchParams.set('bitrate', bitrateStr);
}
Expand Down
2 changes: 1 addition & 1 deletion src/manifests/utils/dashManifestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default function (): DASHManifestTools {
segmentTemplate.$.media = proxyPathBuilder(
mediaUrl.match(/^http/) ? mediaUrl : baseUrl + mediaUrl,
urlQuery,
'proxy-segment/segment_$Number$_$RepresentationID$_$Bandwidth$'
'proxy-segment/segment_$Number$_$RepresentationID$_$Bandwidth$_$Time$'
);
// Initialization attr.
const initUrl = segmentTemplate.$.initialization;
Expand Down
3 changes: 2 additions & 1 deletion src/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ type ProxyBasenames =
| 'proxy-media.m3u8'
| '../../segments/proxy-segment'
| 'proxy-segment/segment_$Number$.mp4'
| 'proxy-segment/segment_$Number$_$RepresentationID$_$Bandwidth$';
| 'proxy-segment/segment_$Number$_$RepresentationID$_$Bandwidth$'
| 'proxy-segment/segment_$Number$_$RepresentationID$_$Bandwidth$_$Time$';

/**
* Adjust paths based on directory navigation
Expand Down
4 changes: 2 additions & 2 deletions src/testvectors/dash/dash1_compressed/proxy-manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<SegmentTemplate
timescale="48000"
initialization="https://mock.mock.com/stream/relative_base/audiotrack/init/$RepresentationID$.m4s"
media="proxy-segment/segment_$Number$_$RepresentationID$_$Bandwidth$?url=https%3A%2F%2Fmock.mock.com%2Fstream%2Frelative_base%2Faudiotrack%2F%24RepresentationID%24%2F%24Time%24.m4s&amp;statusCode=%5B%7Bi%3A0%2Ccode%3A404%7D%2C%7Bi%3A2%2Ccode%3A401%7D%5D&amp;timeout=%5B%7Bi%3A3%7D%5D&amp;delay=%5B%7Bi%3A2%2Cms%3A2000%7D%5D">
media="proxy-segment/segment_$Number$_$RepresentationID$_$Bandwidth$_$Time$?url=https%3A%2F%2Fmock.mock.com%2Fstream%2Frelative_base%2Faudiotrack%2F%24RepresentationID%24%2F%24Time%24.m4s&amp;statusCode=%5B%7Bi%3A0%2Ccode%3A404%7D%2C%7Bi%3A2%2Ccode%3A401%7D%5D&amp;timeout=%5B%7Bi%3A3%7D%5D&amp;delay=%5B%7Bi%3A2%2Cms%3A2000%7D%5D">
<SegmentTimeline>
<S t="80746389121167" d="184320" r="78" />
</SegmentTimeline>
Expand Down Expand Up @@ -62,7 +62,7 @@
<SegmentTemplate
timescale="600"
initialization="https://mock.mock.com/stream/relative_base/videotrack/init/$RepresentationID$.m4s"
media="proxy-segment/segment_$Number$_$RepresentationID$_$Bandwidth$?url=https%3A%2F%2Fmock.mock.com%2Fstream%2Frelative_base%2Fvideotrack%2F%24RepresentationID%24%2F%24Time%24.m4s&amp;statusCode=%5B%7Bi%3A0%2Ccode%3A404%7D%2C%7Bi%3A2%2Ccode%3A401%7D%5D&amp;timeout=%5B%7Bi%3A3%7D%5D&amp;delay=%5B%7Bi%3A2%2Cms%3A2000%7D%5D">
media="proxy-segment/segment_$Number$_$RepresentationID$_$Bandwidth$_$Time$?url=https%3A%2F%2Fmock.mock.com%2Fstream%2Frelative_base%2Fvideotrack%2F%24RepresentationID%24%2F%24Time%24.m4s&amp;statusCode=%5B%7Bi%3A0%2Ccode%3A404%7D%2C%7Bi%3A2%2Ccode%3A401%7D%5D&amp;timeout=%5B%7Bi%3A3%7D%5D&amp;delay=%5B%7Bi%3A2%2Cms%3A2000%7D%5D">
<SegmentTimeline>
<S t="1009329864060" d="2304" r="78" />
</SegmentTimeline>
Expand Down
4 changes: 2 additions & 2 deletions src/testvectors/dash/dash_period_baseurl/proxy-manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<MPD xmlns="urn:mpeg:DASH:schema:MPD:2011" minBufferTime="PT1.500S" type="static" mediaPresentationDuration="PT0H0M10.000S" maxSegmentDuration="PT0H0M1.000S" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 DASH-MPD.xsd">
<Period id="0" start="PT0H0M0.000S">
<AdaptationSet mimeType="video/mp4" codecs="avc1.4D401E" frameRate="30000/1001" lang="und">
<SegmentTemplate timescale="1000" media="proxy-segment/segment_$Number$_$RepresentationID$_$Bandwidth$?url=http%3A%2F%2Fvm2.dashif.org%2Flivesim-dev%2Fperiods_60%2Fvideo_%24Number%24.mp4" initialization="http://vm2.dashif.org/livesim-dev/periods_60/video_init.mp4" startNumber="1" presentationTimeOffset="0">
<SegmentTemplate timescale="1000" media="proxy-segment/segment_$Number$_$RepresentationID$_$Bandwidth$_$Time$?url=http%3A%2F%2Fvm2.dashif.org%2Flivesim-dev%2Fperiods_60%2Fvideo_%24Number%24.mp4" initialization="http://vm2.dashif.org/livesim-dev/periods_60/video_init.mp4" startNumber="1" presentationTimeOffset="0">
<SegmentTimeline>
<S t="0" d="10000"/>
<S t="10000" d="10000"/>
Expand All @@ -17,7 +17,7 @@
</SegmentTemplate>
</AdaptationSet>
<AdaptationSet mimeType="audio/mp4" lang="und">
<SegmentTemplate timescale="1000" media="proxy-segment/segment_$Number$_$RepresentationID$_$Bandwidth$?url=http%3A%2F%2Fvm2.dashif.org%2Flivesim-dev%2Fperiods_60%2Faudio_%24Number%24.mp4" initialization="http://vm2.dashif.org/livesim-dev/periods_60/audio_init.mp4" startNumber="1" presentationTimeOffset="0">
<SegmentTemplate timescale="1000" media="proxy-segment/segment_$Number$_$RepresentationID$_$Bandwidth$_$Time$?url=http%3A%2F%2Fvm2.dashif.org%2Flivesim-dev%2Fperiods_60%2Faudio_%24Number%24.mp4" initialization="http://vm2.dashif.org/livesim-dev/periods_60/audio_init.mp4" startNumber="1" presentationTimeOffset="0">
<SegmentTimeline>
<S t="0" d="10000"/>
<S t="10000" d="10000"/>
Expand Down

0 comments on commit 56f0681

Please sign in to comment.