Default Dash Manifest creation is FAILED with CDNOutPut inbuilt with error UNDEFINED.
Code I am using for the same:
public async Task CreatePerTileWithCDN()
{
DirectFileUploadInput input = new DirectFileUploadInput();
input.Name = this.contentid;
input.Description = this.contentid;
var encoding = await CreateEncoding(contentid, "Per-Title encoding with HLS and DASH manifest");
DirectFileUploadInput input1 = await this.bitmovinApi.Encoding.Inputs.DirectFileUpload.CreateAsync(input);
string filePath = Directory.GetCurrentDirectory() + "/Media/XXX.mp4";
bool isfileUploaded = UploadObject(filePath, input1.UploadUrl);
CdnOutput cdnOutput = await this.bitmovinApi.Encoding.Outputs.Cdn.GetAsync("XXXXX");
CdnOutput output = await this.bitmovinApi.Encoding.Outputs.Cdn.GetAsync(cdnOutput.Id);
var inputFilePath = Path.GetFileName(filePath);
var OutPutPath = "/";
var h264VideoConfig = await CreateH264VideoConfiguration();
var h264VideoStream = await CreateStream(encoding, input1, inputFilePath, h264VideoConfig, StreamMode.PER_TITLE_TEMPLATE);
var aacConfig = await CreateAacAudioConfiguration();
var aacAudioStream = await CreateStream(encoding, input1, inputFilePath, aacConfig, StreamMode.STANDARD);
var videoMuxing = await CreateFmp4Muxing(encoding, output, OutPutPath + "video/{height}/{bitrate}_{uuid}", h264VideoStream);
var audioMuxing = await CreateFmp4Muxing(encoding, output, OutPutPath + "audio", aacAudioStream);
if (this.DRM_KEY != null && this.DRM_KEY != "")
{
await CreateDrmConfig(encoding, videoMuxing, output, OutPutPath + "video/{height}/{bitrate}_{uuid}");
await CreateDrmConfig(encoding, audioMuxing, output, OutPutPath + "audio");
}
var dashManifest = await CreateDefaultDashManifest(encoding, output, OutPutPath);
var hlsManifest = await CreateDefaultHlsManifest(encoding, output, OutPutPath);
var startEncodingRequest = new StartEncodingRequest()
{
PerTitle = new PerTitle()
{
H264Configuration = new H264PerTitleConfiguration()
{
AutoRepresentations = new AutoRepresentation()
}
},
ManifestGenerator = ManifestGenerator.V2,
VodDashManifests = new List<ManifestResource>() { BuildManifestResource(dashManifest) },
VodHlsManifests = new List<ManifestResource>() { BuildManifestResource(hlsManifest) }
};
await ExecuteEncoding(encoding, startEncodingRequest);
}
private Task CreateH264VideoConfiguration()
{
var config = new H264VideoConfiguration()
{
Name = “Base H.264 video config”,
PresetConfiguration = PresetConfiguration.VOD_STANDARD
};
return this.bitmovinApi.Encoding.Configurations.Video.H264.CreateAsync(config);
}
private Task CreateAacAudioConfiguration()
{
var config = new AacAudioConfiguration()
{
Name = “AAC 128 kbit/s”,
Bitrate = 128_000L
};
return this.bitmovinApi.Encoding.Configurations.Audio.Aac.CreateAsync(config);
}
private Task<Bitmovin.Api.Sdk.Models.Stream> CreateStream(Bitmovin.Api.Sdk.Models.Encoding encoding, DirectFileUploadInput input, string inputPath,
CodecConfiguration configuration, StreamMode streamMode)
{
var streamInput = new StreamInput()
{
InputId = input.Id,
InputPath = this.Filename,
SelectionMode = StreamSelectionMode.AUTO
};
var stream = new Bitmovin.Api.Sdk.Models.Stream()
{
InputStreams = new List<StreamInput>() { streamInput },
CodecConfigId = configuration.Id,
Mode = streamMode
};
return this.bitmovinApi.Encoding.Encodings.Streams.CreateAsync(encoding.Id, stream);
}
private Task CreateFmp4Muxing(Bitmovin.Api.Sdk.Models.Encoding encoding, CdnOutput output, string outputPath, Bitmovin.Api.Sdk.Models.Stream stream)
{
var muxingStream = new MuxingStream()
{
StreamId = stream.Id
};
var muxing = new Fmp4Muxing()
{
SegmentLength = 4,
Outputs = new List<EncodingOutput>() { BuildEncodingOutput(output, outputPath) },
Streams = new List<MuxingStream>() { muxingStream }
};
return this.bitmovinApi.Encoding.Encodings.Muxings.Fmp4.CreateAsync(encoding.Id, muxing);
}
private async Task CreateDefaultDashManifest(Bitmovin.Api.Sdk.Models.Encoding encoding, Output output, string outputPath)
{
var dashManifestDefault = new DashManifestDefault()
{
Name = this.contentid + “_dash”,
EncodingId = encoding.Id,
ManifestName = this.contentid + “.mpd”,
Version = DashManifestDefaultVersion.V1,
Outputs = new List() { BuildEncodingOutput(output, outputPath) }
};
return await this.bitmovinApi.Encoding.Manifests.Dash.Default.CreateAsync(dashManifestDefault);
}
private async Task CreateDefaultHlsManifest(Bitmovin.Api.Sdk.Models.Encoding encoding, Output output, string outputPath)
{
var hlsManifestDefault = new HlsManifestDefault()
{
Name = this.contentid + “_hls”,
EncodingId = encoding.Id,
ManifestName = this.contentid + “.m3u8”,
Version = HlsManifestDefaultVersion.V1,
Outputs = new List() { BuildEncodingOutput(output, outputPath) }
};
return await this.bitmovinApi.Encoding.Manifests.Hls.Default.CreateAsync(hlsManifestDefault);
}
private EncodingOutput BuildEncodingOutput(Output output, string outputPath)
{
var aclEntry = new AclEntry()
{
Permission = AclPermission.PUBLIC_READ
};
var encodingOutput = new EncodingOutput()
{
OutputPath = outputPath,
OutputId = output.Id,
Acl = new List<AclEntry>() { aclEntry }
};
return encodingOutput;
}
private void LogTaskErrors(ServiceTaskStatus task)
{
task.Messages.Where(msg => msg.Type == MessageType.ERROR).ToList().ForEach(message =>
{
Console.WriteLine(message.Text);
});
}
private async Task ExecuteEncoding(Bitmovin.Api.Sdk.Models.Encoding encoding, StartEncodingRequest startEncodingRequest)
{
await this.bitmovinApi.Encoding.Encodings.StartAsync(encoding.Id, startEncodingRequest);
ServiceTaskStatus serviceTaskStatus;
do
{
await Task.Delay(5000);
serviceTaskStatus = await this.bitmovinApi.Encoding.Encodings.StatusAsync(encoding.Id);
Console.WriteLine($"Encoding status is {serviceTaskStatus.Status} (progress: {serviceTaskStatus.Progress} %)");
} while (serviceTaskStatus.Status != Status.FINISHED && serviceTaskStatus.Status != Status.ERROR);
if (serviceTaskStatus.Status == Status.ERROR)
{
LogTaskErrors(serviceTaskStatus);
throw new SystemException("Encoding failed");
}
Console.WriteLine("Encoding finished successfully");
}