Get Information

Media Handler Pro component can be used to fetch information from videos and audio files using your asp.net, vb.net and c# applications.

Media Handler Pro return video information in the form of VideoInfo object.

Script mentioned in this post is out dated. click here for latest code about posting watermark on video using asp.net, c# and vb.net.

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();

vi: C# code for error validation after processing completes

// start validation whether media processed properly or failed.
// info object store all information retreived from media after processing completes.
if (infoErrorCode > 0 && info.ErrorCode != 121)
{
    Response.Write("Video processing failed, Error code " + info.ErrorCode + " generated");
    return;
}
// if ErrorCode returned by function is greater than zero, means there is error occured. for detail about error codes click here

vi: 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 retreived from media after processing completes.
// After errorcode validation you can retrieve source and output video information from info object as shown below.
StringBuilder 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 />");
// for more detail about videoinfo object visit video output parameter section.