I’m trying to change the media and initialization for the following manifest line:
<SegmentTemplate media="video_1080p/segment_$Number$.m4s" startNumber="0" timescale="60000" duration="240000" initialization="video_1080p/init.mp4"/>
so it looks like
<SegmentTemplate media="video_1080p/segment_$Number$.m4s?sv=2022-11-02&ss=bfqt" startNumber="0" timescale="60000" duration="240000" initialization="video_1080p/init.mp4sv=2022-11-02&ss=bfqt"/>
Here’s my Javascript code to create dash manaifest code.
async function createDashManifestFmp4(
encodingId,
outputId,
dashManifestPath,
muxings, // Array of { muxingId, segmentPath, segmentNaming, initSegmentName }
manifestName
) {
// 1) Create the DASH manifest
const dashManifest = new DashManifest({
name: 'fMP4 DASH Manifest',
manifestName: `${manifestName}.mpd`,
profile: DashProfile.LIVE, // or VOD, depending on use case
outputs: [
{
outputId: outputId,
outputPath: dashManifestPath,
acl: [{ permission: 'PUBLIC_READ' }]
}
]
});
const createdManifest = await bitmovinApi.encoding.manifests.dash.create(dashManifest);
console.log('DASH manifest created:', createdManifest);
// 2) Create a Period
const period = await bitmovinApi.encoding.manifests.dash.periods.create(
createdManifest.id,
new Period()
);
console.log('Period created:', period);
// 3) Create a Video Adaptation Set
const videoAdaptationSet = await bitmovinApi.encoding.manifests.dash.periods.adaptationsets.video.create(
createdManifest.id,
period.id,
new VideoAdaptationSet({})
);
console.log('Video adaptation set created:', videoAdaptationSet);
// 4) Add an fMP4 Representation for each muxing
for (const { muxingId, segmentPath, segmentNaming, initSegmentName } of muxings) {
// Note: Use DashFmp4Representation (NOT DashCmafRepresentation)
const dashFmp4Rep = new DashFmp4Representation({
type: DashRepresentationType.TEMPLATE, // 'TEMPLATE' ensures segment templating
encodingId: encodingId,
muxingId: muxingId,
segmentPath: segmentPath,
segmentNaming: segmentNaming,
initSegmentName: initSegmentName
});
const representation = await bitmovinApi.encoding.manifests.dash.periods.adaptationsets.representations.fmp4.create(
createdManifest.id,
period.id,
videoAdaptationSet.id,
dashFmp4Rep
);
console.log('Added fMP4 representation:', representation);
}
// 5) Start the manifest generation
await bitmovinApi.encoding.manifests.dash.start(createdManifest.id);
// 6) Poll until finished
let manifestStatus;
do {
manifestStatus = await bitmovinApi.encoding.manifests.dash.status(createdManifest.id);
console.log(`DASH manifest status: ${manifestStatus.status}`);
if (manifestStatus.status === 'ERROR') {
throw new Error('DASH manifest generation failed');
}
await new Promise((resolve) => setTimeout(resolve, 3000));
} while (manifestStatus.status !== 'FINISHED');
console.log('DASH manifest generated successfully!');
return createdManifest.id;
}
Then I call it like this:
const dashManifestId = await createDashManifestFmp4(
encoding.id,
output.id,
'/',
[
{
muxingId: muxing1080p.id,
segmentPath: 'video_1080p',
segmentNaming: `segment_$Number$.m4s?${SAS_TOKEN}`,
initSegmentName: `init.mp4?${SAS_TOKEN}`
},
{
muxingId: muxing720p.id,
segmentPath: 'video_720p',
segmentNaming: `segment_%number%.m4s?${SAS_TOKEN}`,
initSegmentName: `init.mp4?${SAS_TOKEN}`
},
{
muxingId: muxing480p.id,
segmentPath: 'video_480p',
segmentNaming: `segment_$Number$.m4s?${SAS_TOKEN}`,
initSegmentName: `init.mp4?${SAS_TOKEN}`
}
],
manifestName
);
This clearly doesn’t work.
Any suggestions?