Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save itorian/4ac5fa723b3d5267258450a2c1a00294 to your computer and use it in GitHub Desktop.
Save itorian/4ac5fa723b3d5267258450a2c1a00294 to your computer and use it in GitHub Desktop.
In case you are facing error in scheduled transcoding task and you would like to know details of the error, you can use below code snippet. More details here http://www.itorian.com/2016/04/azure-media-services-transcoding.html
static public IAsset EncodeToAdaptiveBitrateMP4s(IAsset asset, AssetCreationOptions options)
{
// Default preset settings
//IJob job = _context.Jobs.CreateWithSingleTask(MediaProcessorNames.AzureMediaEncoder,
// MediaEncoderTaskPresetStrings.H264AdaptiveBitrateMP4Set720p,
// asset,
// "Test-Video-" + 100 + "-" + Guid.NewGuid().ToString() + "-Adaptive-Bitrate-MP4",
// AssetCreationOptions.None);
// Custom preset settings
string configuration = File.ReadAllText(Path.Combine(_presetFiles, @"H264MultipleBitrateCustom720p.xml"));
IJob job = _context.Jobs.CreateWithSingleTask(MediaProcessorNames.AzureMediaEncoder,
configuration,
asset,
"Test-Video-" + 100 + "-" + Guid.NewGuid().ToString() + "-Adaptive-Bitrate-MP4",
AssetCreationOptions.None);
Console.WriteLine("Submitting transcoding job...");
job.Submit();
job = job.StartExecutionProgressTask(
j =>
{
Console.WriteLine("Job state: {0}", j.State);
// Error handling
if(j.State == JobState.Error)
{
foreach (var task in job.Tasks)
{
if (task.ErrorDetails != null)
{
foreach (var errordetail in task.ErrorDetails)
{
Console.WriteLine("Error Message:" + errordetail.Message);
Console.WriteLine("Error Code:" + errordetail.Code);
}
}
}
}
Console.WriteLine("Job progress: {0:0.##}%", j.GetOverallProgress());
},
CancellationToken.None).Result;
Console.WriteLine("Transcoding job end.");
IAsset outputAsset = job.OutputMediaAssets[0];
return outputAsset;
}
@itorian
Copy link
Author

itorian commented Apr 19, 2016

Here is the error I was getting on Azure portal:

error in transcoding task

Here is the error details in output after using above code snippet:

output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment