VideoInfo Class

VideoInfo class object is used to store video information that is retrieved from video at time of encoding video or getting information directly from video.

All functions available in Media Handler Pro version 4.0 or later returns video information as VideoInfo object instead of normal string value which requires lots of code while parsing string value and decrease chances of errors.

Properties of VideoInfo Class

You can get various information from video using VideoInfo ojbect through their properties. Detail about VideoInfo class properties are decribe below.

Properties Type Detail Information
FileName
string FileName stores name of encoded video or video from which information is retrieved.
Vcodec
string Vcodec stores Video Codec information of encoded video.
Acodec
string Acodec stores Audio Codec information of encoded video.
SamplingRate
string SamplingRate Stores video samplingrate in hertz.
Channel
string Channel stores audio type, e.g mono or stereo.
Audio_Bitrate
string Audio_Bitrate stores audio bitrate information in kb/s
Video_Bitrate
string Video_Bitrate stores video bitrate information in kb/s
Width
int It stores width of video in pixels.
Height
int It stores height of video in pixels.
FrameRate
string FrameRate stores frame rate of video in fps.
Duration
string It returns duration of video in hh:mm:ss format.
Duration_Sec
double Duration_Sec returns duration of video in seconds. e.g 120 seconds.
Start
string It stores start postion of video.
ErrorCode
int It stores error code, if error occured while publishing video or parsing video information. Detail about possible error codes returned by Media Handler Pro component. Default value is 0 which means video processing, publishing, encoding successfully completed.
ErrorMessage
string It stores detail description of error.

Example of VideoInfo Object

Sample example for retrieving information from video using VideoInfo Object. Note VideoInfo object is available in Media Handler Pro version 4.0 or later.

// c#

MediaHandler _mhandler = new MediaHandler();

string RootPath = Server.MapPath(Request.ApplicationPath);

_mhandler.FFMPEGPath = HttpContext.Current.Server.MapPath("~\\ffmpeg\\ffmpeg.exe");
_mhandler.InputPath = RootPath + "\\contents\\original";
_mhandler.FileName = "sample.mpg";

// get information from video as VideoInfo Object.
VideoInfo info = _mhandler.Get_Info();
// check whether no error occured while reading video
if (info.ErrorCode > 0)
{
Response.Write("Video processing failed, Error code " + info.ErrorCode + " generated");
return;
}

// get information from VideoInfo Ojbect and print on screen.
StringBuilder str = new StringBuilder();
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("Video Duration= " + info.Duration + "<br />");

str.Append("Video Duration in Seconds= " + info.Duration_Sec + "<br />");
Response.Write(str.ToString());

 

Possible output of code show above

Video Codec= mpeg1video
Audio Codec= mp2
Video Bitrate= 104857 kb/s
Audio Bitrate= 112 kb/s
Audio Sampling Rate= 48000 Hz
Audio Channel= stereo
Width= 288
Height= 240
Video FrameRate=
Video Duration= 00:00:40.17
Video Duration in Seconds= 41

 

Note: If there is no information retrieved from video, it will be appear as "" empty means information is not available like in above case "FrameRate" value is "".

©2007 - 2008, MediaSoft Pro Inc  | Site Map