.NET video upload
As with images, Cloudinary’s video management solution enables you to upload videos to the cloud and perform manipulations. Cloudinary’s RESTful API and the .NET client library (SDK) allow you to upload videos from server-side code, directly from the browser, or from a mobile app. You can transcode your videos to all relevant formats, apply a wide range of video transformations, and stream your optimized videos via CDN to web browsers and mobile devices.
The upload process for videos is generally the same as that for images, and you can apply essentially all image upload functionality to video as well. For details, see the .NET image upload documentation.
This section provides an overview and examples of video upload functionality using .NET.
For complete details on all video upload functionality, see Upload videos.
For the complete list of available upload parameters, see the Upload method of the Upload API Reference.
.NET video upload functionality
The .NET SDK package wraps the Cloudinary upload API to help you upload your videos to the cloud via server upload or as a direct upload from the browser or your mobile app. Direct upload of video from the browser works the same way as direct image upload. It requires the JQuery upload plugin and some configuration setup. For details, see Direct uploading from the browser.
You can also use the upload widget for uploads of user-generated video content.
Although most video transformations can be performed on-the-fly and the resulting video can stream even while the derived video is being generated, it can sometimes be a good idea to perform your transformations eagerly as part of the upload. This is especially true for longer videos, so that the final video is ready for fast delivery when the first user requests it.
For user-generated video content, consider utilizing incoming transformations and upload presets.
To avoid the risks of network issues, you can take advantage of the upload_large method, which uploads large videos to the cloud in chunks.
.NET video upload examples
This section provides examples of some of the video upload features mentioned in the previous section.
Example 1: Server-side upload
The following example uploads dog.mp4 to Cloudinary and stores it in a bi-level folder structure with the public ID dog_closeup
. It also performs two eager transformations that resize the video to a square and a small rectangle.
var uploadParams = new VideoUploadParams() { File = new FileDescription(@"dog.mp4"), ResourceType = "video" PublicId = "my_folder/my_sub_folder/dog_closeup", EagerTransforms = new List<Transformation>() { new Transformation().Width(300).Height(300).Crop("pad").AudioCodec("none"), new Transformation().Width(160).Height(100).Crop("crop").Gravity("south").AudioCodec("none")), } EagerAsync = true, EagerNotificationUrl = "https://mysite.example.com/my_notification_endpoint" }; var uploadResult = cloudinary.Upload(uploadParams);
Example 2: Client-side upload from the browser (signed upload)
The following example renders a direct file upload input field using the BuildUploadForm
helper method. Although the default resource_type
for this method is auto
, the video
type is explicitly defined, and asynchronous eager transformations are used to generate adaptive bitrate streaming content. The html
parameter is used to include standard HTML parameters (in this case, an id
attribute) in the generated tag.
string input = m_cloudinary.Api.BuildUploadForm("video_id", "video", new Dictionary<string, object>() { { "eager", "sp_full_hd/83u8"}, { "eager_async", true }, { "eager_notification_url", "https://mysite.example.com/notify_endpoint" } }, new Dictionary<string, string>() { { "id", "my_upload_tag" } } );
Example 3: Client-side upload from the browser (unsigned upload)
The following example renders an unsigned direct file upload input field using the BuildUnsignedUploadForm
helper method. The default resource_type
for this method is auto
, so it can be used for images, video, and raw files. The method defines a public_ID and tags for the uploaded file.
my_upload_preset
is defined as an unsigned preset for your account.string input = m_cloudinary.Api.BuildUnsignedUploadForm("video_id", "my_upload_preset", new Dictionary<string, object>() { { "public_id", "my_video" }, { "tags", "user_218,screencast" } }, null );