This commit is contained in:
Developer
2026-03-10 19:04:18 +08:00
parent 18eebfb0d2
commit cf20b016ff
18 changed files with 1106 additions and 123 deletions

26
utils/buildMpd.ts Normal file
View File

@@ -0,0 +1,26 @@
export function buildMpd(
videoUrl: string,
videoCodecs: string,
videoBandwidth: number,
audioUrl: string,
audioCodecs: string,
audioBandwidth: number,
): string {
return `<?xml version="1.0"?>
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" type="static" mediaPresentationDuration="PT9999S">
<Period>
<AdaptationSet contentType="video" mimeType="video/mp4" segmentAlignment="true">
<Representation id="v1" codecs="${videoCodecs}" bandwidth="${videoBandwidth}">
<BaseURL>${videoUrl}</BaseURL>
<SegmentBase><Initialization range="0-999"/></SegmentBase>
</Representation>
</AdaptationSet>
<AdaptationSet contentType="audio" mimeType="audio/mp4">
<Representation id="a1" codecs="${audioCodecs}" bandwidth="${audioBandwidth}">
<BaseURL>${audioUrl}</BaseURL>
<SegmentBase><Initialization range="0-999"/></SegmentBase>
</Representation>
</AdaptationSet>
</Period>
</MPD>`;
}