Using VideoUltimate in a project
To use VideoUltimate in a project, do the following in Visual Studio:
Make sure you have added references to VideoUltimate assemblies as described here.
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.jsonfile:{ //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 toVideoUltimateConfiguration.Current.Alternatively you can specify the configuration in code, in
Configuremethod of your Startup.cs://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.<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 toVideoUltimateConfiguration.Current.Alternatively you can specify the configuration in code, in
Application_Startmethod of your Global.asax.cs: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..."; }Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) '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..." End SubFor other project types
You can specify the configuration in a static (Shared in VB) method, e.g. in
Mainmethod for a Console project: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..."; }Shared Sub Main(args As String()) '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..." End SubOpen one of your class files (eg. Program.cs) and at the top of your file add the necessary namespaces:
using GleamTech.VideoUltimate;Imports GleamTech.VideoUltimateNow in some method insert these lines:
//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'")) { }'Read video from "c:\SomeFolder\InputFile.mp4" Using videoFrameReader As New VideoFrameReader("c:\SomeFolder\InputFile.mp4") End Using '--------------------------------------- 'Read with a virtual path string: 'See below for other path string examples. Using videoFrameReader As New VideoFrameReader("~/SomeFolder/InputFile.mp4") End Using 'Read with a URL string: 'See below for other path string examples. Using videoFrameReader As New VideoFrameReader("http://example.com/SomeFolder/InputFile.mp4") End Using 'Read with a Data URL string: 'See below for other path string examples. Using videoFrameReader As New VideoFrameReader("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7") End Using 'Read with a file provider instance: 'See below for other file provider examples (UNC Path, AmazonS3, AzureBlob, Database etc.). Dim fileProvider As New FileSystemFileProvider() With { .File = "InputFile.mp4", .Location = New PhysicalLocation() With { .Path = "c:\SomeFolder" } } Using videoFrameReader As New VideoFrameReader(fileProvider) End Using 'Read with a provider string: 'See below for other provider string examples (UNC Path, AmazonS3, AzureBlob, Database etc.). Using videoFrameReader As New VideoFrameReader("Type=FileSystem; File=InputFile.mp4; Location='Type=Physical; Path=c:\SomeFolder'") End UsingThis 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 asC:\Frame1.jpg.Sometimes you may only need to quickly generate a meaningful thumbnail for a video, you can use
VideoThumbnailerclass for this://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'")) { }'Read video from "c:\SomeFolder\InputFile.mp4" Using videoThumbnailer = New VideoThumbnailer("c:\SomeFolder\InputFile.mp4") End Using '--------------------------------------- 'Read with a virtual path string: 'See below for other path string examples. Using videoThumbnailer = New VideoThumbnailer("~/SomeFolder/InputFile.mp4") End Using 'Read with a URL string: 'See below for other path string examples. Using videoThumbnailer = New VideoThumbnailer("http://example.com/SomeFolder/InputFile.mp4") End Using 'Read with a Data URL string: 'See below for other path string examples. Using videoThumbnailer = New VideoThumbnailer("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7") End Using 'Read with a file provider instance: 'See below for other file provider examples (UNC Path, AmazonS3, AzureBlob, Database etc.). Dim fileProvider As New FileSystemFileProvider() With { .File = "InputFile.mp4", .Location = New PhysicalLocation() With { .Path = "c:\SomeFolder" } } Using videoThumbnailer = New VideoThumbnailer(fileProvider) End Using 'Read with a provider string: 'See below for other provider string examples (UNC Path, AmazonS3, AzureBlob, Database etc.). Using videoThumbnailer = New VideoThumbnailer("Type=FileSystem; File=InputFile.mp4; Location='Type=Physical; Path=c:\SomeFolder'") End Using