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.
Media Handler Pro 5.0 or later support retrieving input and output media information after completion of publishing video.
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 | Returns filename of encoded video or media. |
Vcodec |
string | Returns video codec information of encoded video or direct video. |
Acodec |
string | Returns audio codec information from encoded video. |
SamplingRate |
string | Returns audio sampling rate of published or direct video. |
Channel |
string | Returns encoded video audio channel information, e.g mono or stereo. |
Audio_Bitrate |
string | Returns audio bitrate of encoded video in kb/s. |
Video_Bitrate |
string | Returns video bitrate of encoded video in kb/s. |
Width |
int | Returns width of published video. |
Height |
int | Returns height of published video. |
FrameRate |
string | Returns frame rate of published 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. |
FFMPEGOutput |
string | Returns complete output of FFMPEG. |
Input_Vcodec new |
string | Returns video codec information of input (source video) in case of video publishing . |
Input_Acodec new |
string | Returns audio codec information of input (source video) in case of video publishing . |
Input_Video_Bitrate new |
string | Returns video bitrate information of input (source video) in case of video publishing . |
Input_Audio_Bitrate new |
string | Returns audio bitrate information of input (source video) in case of video publishing . |
Input_SamplingRate new |
string | Returns audio sampling rate information of input (source video) in case of video publishing . |
Input_Channel new |
string | Returns audio channel information of input (source video) in case of video publishing . |
Input_Width new |
string | Returns source video width in case of video encoding. |
Input_Height new |
string | Returns source video height in case of video encoding. |
Input_FrameRate new |
string | Returns video frame rate information of input (source video) in case of video publishing . |
Sample example for retrieving information from video using VideoInfo Object in Media Handler Pro 5.0 after video publishing completed.
// c#
// get information from video as VideoInfo Object.
VideoInfo info = _mhandler.Encode_FLV();
// 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("File Name= " + info.FileName + "<br />");
str.Append("Video Duration= " + info.Duration + "<br />");
str.Append("Video Duration in Seconds= " + info.Duration_Sec + "<br />");
// Input values
str.Append("<strong>Input Values</strong><br />");
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 />");
// Output values
str.Append("<strong>Output Values</strong><br />");
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 />");
Response.Write(str.ToString());
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());
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 "".