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.
You can specify the configuration in appsettings.json file:
{
//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:
//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...";
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 to VideoUltimateConfiguration.Current.
Alternatively you can specify the configuration in code, in Application_Start method 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 Sub
You can specify the configuration in a static (Shared in VB) method, e.g. in Main method 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 Sub
Open one of your class files (eg. Program.cs) and at the top of your file add the necessary namespaces:
using GleamTech.VideoUltimate;
Imports GleamTech.VideoUltimate
Now 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 Using
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:
//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