Using VideoUltimate in a project

To use VideoUltimate in a project, do the following in Visual Studio:

  1. Make sure you have added references to VideoUltimate assemblies as described here.

  2. Optionally set VideoUltimate's global configuration (if overriding a default value is required). For example, you may want to set the license key.

    For an ASP.NET Core project

    You can specify the configuration in appsettings.json file:

    Json
    {
      //Set this property only if you have a valid license key, otherwise do not
      //set it so VideoUltimate runs in trial mode.
      "VideoUltimate:LicenseKey": "QQJDJLJP34..."
    }

    As you would notice, VideoUltimate: prefix maps to VideoUltimateConfiguration.Current.

    Alternatively you can specify the configuration in code, in Configure method of your Startup.cs:

    C#
    //Set this property only if you have a valid license key, otherwise do not
    //set it so DocumentUltimate runs in trial mode.
    VideoUltimateConfiguration.Current.LicenseKey = "QQJDJLJP34...";

    For an ASP.NET Classic (MVC or WebForms) project

    You can specify the configuration in <appSettings> tag of your Web.config.

    XML
    <appSettings>
      <!--
        Set this property only if you have a valid license key, otherwise do not
        set it so VideoUltimate runs in trial mode.
      -->
      <add key="VideoUltimate:LicenseKey" value="QQJDJLJP34..." />
    </appSettings>

    As you would notice, VideoUltimate: prefix maps to VideoUltimateConfiguration.Current.

    Alternatively you can specify the configuration in code, in Application_Start method of your Global.asax.cs:

    C#
    protected void Application_Start(object sender, EventArgs e)
    {
        //Set this property only if you have a valid license key, otherwise do not
        //set it so VideoUltimate runs in trial mode.
        VideoUltimateConfiguration.Current.LicenseKey = "QQJDJLJP34...";
    }

    For other project types

    You can specify the configuration in a static (Shared in VB) method, e.g. in Main method for a Console project:

    C#
    static void Main(string[] args)
    {
        //Set this property only if you have a valid license key, otherwise do not
        //set it so VideoUltimate runs in trial mode.
        VideoUltimateConfiguration.Current.LicenseKey = "QQJDJLJP34...";
    }

  3. Open one of your class files (eg. Program.cs) and at the top of your file add the necessary namespaces:

    C#
    using GleamTech.VideoUltimate;

    Now in some method insert these lines:

    C#
    //Read video from "c:\SomeFolder\InputFile.mp4"
    using (var videoFrameReader = new VideoFrameReader(@"c:\SomeFolder\InputFile.mp4"))
    {
    }
    
    //---------------------------------------
    
    //Read with a virtual path string:
    //See below for other path string examples.
    using (var videoFrameReader = new VideoFrameReader("~/SomeFolder/InputFile.mp4"))
    {
    }
    
    //Read with a URL string:
    //See below for other path string examples.
    using (var videoFrameReader = new VideoFrameReader("http://example.com/SomeFolder/InputFile.mp4"))
    {
    }
    
    //Read with a Data URL string:
    //See below for other path string examples.
    using (var videoFrameReader = new VideoFrameReader("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"))
    {
    }
    
    //Read with a file provider instance:
    //See below for other file provider examples (UNC Path, AmazonS3, AzureBlob, Database etc.).
    var fileProvider = new FileSystemFileProvider
    {
        File = "InputFile.mp4",
        Location = new PhysicalLocation
        {
            Path = @"c:\SomeFolder"
        }
    };
    using (var videoFrameReader = new VideoFrameReader(fileProvider))
    {
    }
    
    //Read with a provider string:
    //See below for other provider string examples (UNC Path, AmazonS3, AzureBlob, Database etc.).
    using (var videoFrameReader = new VideoFrameReader(@"Type=FileSystem; File=InputFile.mp4; Location='Type=Physical; Path=c:\SomeFolder'"))
    {
    }

    This will open the source video C:\Video.mp4, read the first frame, and if the frame is read and decoded successfully, it will get a Bitmap instance of the frame and save it as C:\Frame1.jpg.

    Sometimes you may only need to quickly generate a meaningful thumbnail for a video, you can use VideoThumbnailer class for this:

    C#
    //Read video from "c:\SomeFolder\InputFile.mp4"
    using (var videoThumbnailer = new VideoThumbnailer(@"c:\SomeFolder\InputFile.mp4"))
    {
    }
    
    //---------------------------------------
    
    //Read with a virtual path string:
    //See below for other path string examples.
    using (var videoThumbnailer = new VideoThumbnailer("~/SomeFolder/InputFile.mp4"))
    {
    }
    
    //Read with a URL string:
    //See below for other path string examples.
    using (var videoThumbnailer = new VideoThumbnailer("http://example.com/SomeFolder/InputFile.mp4"))
    {
    }
    
    //Read with a Data URL string:
    //See below for other path string examples.
    using (var videoThumbnailer = new VideoThumbnailer("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"))
    {
    }
    
    //Read with a file provider instance:
    //See below for other file provider examples (UNC Path, AmazonS3, AzureBlob, Database etc.).
    var fileProvider = new FileSystemFileProvider
    {
        File = "InputFile.mp4",
        Location = new PhysicalLocation
        {
            Path = @"c:\SomeFolder"
        }
    };
    using (var videoThumbnailer = new VideoThumbnailer(fileProvider))
    {
    }
    
    //Read with a provider string:
    //See below for other provider string examples (UNC Path, AmazonS3, AzureBlob, Database etc.).
    using (var videoThumbnailer = new VideoThumbnailer(@"Type=FileSystem; File=InputFile.mp4; Location='Type=Physical; Path=c:\SomeFolder'"))
    {
    }