
Fetch information from video using ASP.NET
ASP.NET Video Converter component can be used to fetch information from videos and audio files using your asp.net, vb.net, and c# applications.
C# Sample Code
This code will help you fetching useful information from video or audio file in your .net applications.
// set media filename
_mhandler.FileName = "sample.mp4";
VideoInfo info =_mhandler.Get_Info();
// start validation whether media processed properly or failed. // info object-store all information retrieved from media after processing completes.
if (infoErrorCode > 0 && info.ErrorCode != 121) {
Response.Write("Video processing failed, Error code " + info.ErrorCode + " generated"); return;
}
C# code for retrieving information from source and output media (video, audio, image) using .NET Media Handler Pro 5.0
// info object-store all information retrieved from media after processing completes.
// After error code validation you can retrieve source and output video information from info object as shown below.
var str = new StringBuilder();
str.Append("File Name= " + info.FileName + "<br />");
str.Append("Video Duration= " + info.Duration + "<br />");
str.Append("Video Duration in Seconds= " + info.Duration_Sec + "<br />");
// Retrieve information from source media
str.Append("Video Codec= " + info.Input_Vcodec + "<br />");
str.Append("Audio Codec= " + info.Input_Acodec + "<br />");
str.Append("Video Bitrate= " + info.Input_Video_Bitrate + "<br />");
str.Append("Audio Bitrate= " + info.Input_Audio_Bitrate + "<br />");
str.Append("Audio Sampling Rate= " + info.Input_SamplingRate + "<br />");
str.Append("Audio Channel= " + info.Input_Channel + "<br />");
str.Append("Width= " + info.Input_Width + "<br />");
str.Append("Height= " + info.Input_Height + "<br />");
str.Append("Video FrameRate= " + info.Input_FrameRate + "<br />");
// Retrieve information from output video
str.Append("Video Codec= " + info.Vcodec + "<br />");
str.Append("Audio Codec= " + info.Acodec + "<br />");
str.Append("Video Bitrate= " + info.Video_Bitrate + "<br />");
str.Append("Audio Bitrate= " + info.Audio_Bitrate + "<br />");
str.Append("Audio Sampling Rate= " + info.SamplingRate + "<br />");
str.Append("Audio Channel= " + info.Channel + "<br />");
str.Append("Width= " + info.Width + "<br />");
str.Append("Height= " + info.Height + "<br />");
str.Append("Video FrameRate= " + info.FrameRate + "<br />");
str.Append(".................................<br />");
str.Append("FFMPEG Output:" + info.FFMPEGOutput + "");
str.Append("Error Code= " + info.ErrorCode + "<br />");