I've tried to upload a song (.mp4) file format to media services. it has uploaded successfully but, when i tried to create encoding job then i'm getting the below mentioned error. For few files i'm getting the below error and for few files it is not. unable to identify what is the error & how to resolve this problem?
Error Msg:
Encoding task
ErrorProcessingTask : An error has occurred. Stage: ApplyEncodeCommand. Code: System.IO.InvalidDataException.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --->
System.IO.InvalidDataException: Bad input: the source video has an avg_frame_rate of NaN fps and r_frame_rate of 90000 fps.
Code: using encoding of "H264 Multiple Bitrate 720p"
static public IAsset CreateEncodingJob(IAsset asset, string preset,string fileName)
{
IJob job = _context.Jobs.Create(preset + " encoding job");
var mediaProcessors =
_context.MediaProcessors.Where(p => p.Name.Contains("Media Encoder Standard")).ToList();
var latestMediaProcessor =
mediaProcessors.OrderBy(mp => new Version(mp.Version)).LastOrDefault();
ITask task = job.Tasks.AddNew(preset + " encoding task",
latestMediaProcessor,
preset,
Microsoft.WindowsAzure.MediaServices.Client.TaskOptions.ProtectedConfiguration);
task.InputAssets.Add(asset);
task.OutputAssets.AddNew(fileName + " " + preset,
AssetCreationOptions.None);
job.StateChanged += new
EventHandler<JobStateChangedEventArgs>(StateChanged);
job.Submit();
LogJobDetails(job.Id);
Task progressJobTask = job.GetExecutionProgressTask(CancellationToken.None);
progressJobTask.Wait();
if (job.State == JobState.Error)
{
throw new Exception("\nExiting method due to job error.");
}
return job.OutputMediaAssets[0];
}
Can any one help me on this?
Found the solution: Click here
Re posting the comment:
Your encode tasks are failing because the nominal frame rate reported by the input video is either too high or too low. You will have to override the output frame rate setting in the encoding preset. Suppose you know that the input videos have been recorded at 30 frames/second, then:
Take the JSON for "H264 Multiple Bitrate 720p" from https://msdn.microsoft.com/en-us/library/azure/mt269953.aspx
Edit/replace each "FrameRate": "0/1" entry with "FrameRate": "30/1". Note that there are multiple entries to be replaced.
Save the resultant JSON
When submitting an encode Task, in CreateEncodingTask, replace the string "preset" with the entire JSON (by using System.IO.File.ReadAllText("song.Json"))
Regards, Dilip.