Skip to main content

Sample Codes

This section will provide various examples and usage guide which will help you implementing vuploader user control properly in your application.

Example 1:

Sample code for publishing single video without grabbing thumbs using vuploader encoding script.

encoder.GrabThumbs = false; // disable grabbing thumbs from video

Example 2:

Sample code can be use to publish audio file only using vuploader encoding script.

itags.Add("14"); // publish mp3 audio (more detail at encoder settings section
encoder.GrabThumbs = false; // disable grabbing thumbs from video

Example 3:

This code will help you publishing 360p mp4 video and grab thumbs

itags.Add("5"); // publish 360p mp4 video (more detail at encoder settings section
encoder.TotalThumbs = 15;// grab fifteen thumbs from start to end of video
encoder.GrabThumbs = true; // disable grabbing thumbs from video

Example 4:

This code will help you publishing 360p mp4 video, mp3 audio file and grab thumbs in one step using vuploader encoding script.

itags.Add("5"); // publish 360p mp4 video (more detail at encoder settings section
itags.Add("14"); // publish mp3 audio file (more detail at encoder settings section
encoder.TotalThumbs = 15;// grab fifteen thumbs from start to end of video
encoder.GrabThumbs = true; // disable grabbing thumbs from video

Example 5:

This example will generate multiple videos (multi level and multi format) and grab thumbs in one step using vuploader encoding script.

ArrayList itags= new ArrayList();
itags.Add("0"); // publish 240p flv video (more detail at encoder settings section
itags.Add("1"); // publish 360p flv video (more detail at encoder settings section
itags.Add("2"); // publish 480p flv video (more detail at encoder settings section
itags.Add("5"); // publish 360p mp4 video (more detail at encoder settings section
itags.Add("6"); // publish 480 mp4 video (more detail at encoder settings section
itags.Add("7"); // publish 720p mp4 video (more detail at encoder settings section
itags.Add("10"); // publish 360p webm video (more detail at encoder settings section
itags.Add("11"); // publish 480p webm video (more detail at encoder settings section
itags.Add("14"); // publish mp3 audio file (more detail at encoder settings section
encoder.ThumbsDirectory = RootPath + "\\contents\\thumbs"; // directory path of published video thumbs
encoder.TotalThumbs = 15;// grab fifteen thumbs from start to end of video
encoder.GrabThumbs = true; // disable grabbing thumbs from video

Example 6:

This code will help you publishing multi format, multi level video encoding, grab thumbs and cloud storage in one step using asp.net vuploader encoding script.

encoder.EnableCloudStorage = true; // disable cloud storage
ArrayList itags= new ArrayList();
itags.Add("0"); // publish 240p flv video (more detail at encoder settings section
itags.Add("1"); // publish 360p flv video (more detail at encoder settings section
itags.Add("2"); // publish 480p flv video (more detail at encoder settings section
itags.Add("5"); // publish 360p mp4 video (more detail at encoder settings section
itags.Add("6"); // publish 480 mp4 video (more detail at encoder settings section
itags.Add("7"); // publish 720p mp4 video (more detail at encoder settings section
itags.Add("10"); // publish 360p webm video (more detail at encoder settings section
itags.Add("11"); // publish 480p webm video (more detail at encoder settings section
itags.Add("14"); // publish mp3 audio file (more detail at encoder settings section
encoder.ThumbsDirectory = RootPath + "\\contents\\thumbs"; // directory path of published video thumbs
encoder.TotalThumbs = 15;// grab fifteen thumbs from start to end of video
encoder.GrabThumbs = true; // disable grabbing thumbs from video

Complete Example

Complete code for setting vuploader encoding script in your asp.net application.

MHPEncoder encoder = new MHPEncoder();
string RootPath = Server.MapPath(Request.ApplicationPath);  
encoder.FfmpegPath = RootPath + "\\ffmpeg\\ffmpeg.exe"; // path of ffmpeg  
encoder.FlvToolPath = RootPath + "\\flvtool\\flvtool2.exe"; // path of flvtool, use in case of setting meta information to flv videos  encoder.Mp4BoxPath =  RootPath + "\\mp4box\\MP4Box.exe"; // path of mp4box, to be used for setting meta information to mp4 video  
encoder.SourcePath = RootPath + "\\contents\\default"; // path of source video directory  
encoder.SourceFileName = filename; // source video filename  
encoder.PublishedPath = RootPath + "\\contents\\videos"; // directory path of published videos  
encoder.EnableCloudStorage = false; // disable cloud storage  
ArrayList itags= new ArrayList();  
itags.Add("5"); // publish 360p mp4 video (more detail at encoder settings section  
encoder.ThumbsDirectory = RootPath + "\\contents\\thumbs"; // directory path of published video thumbs  
encoder.GrabThumbs = false; // disable grabbing thumbs from video  
encoder.DeleteSource = true; // delete original video after completion  
Video_Information vinfo = encoder.Process(); // start processing  
if (vinfo.ErrorCode > 0)  
{ 
  // Encoding Failed 
  // Encoding Failure Detail in vinfo.ErrorDescription  
}
// Retrive Information  
string PublishedVideoName = vinfo.FLVVideoName;  
string OriginalVideoName = vinfo.OriginalVideoName;  
string ThumbFileName = vinfo.ThumbFileName; //return middle thumb filename  
string Duration = vinfo.Duration; // length of video  
string Duration_Sec = vinfo.Duration_Sec; //length of video in seconds  
string isEnabled = vinfo.isEnabled; // to make sure video published and thumbs grabbed successfully.