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 Java 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 Java image upload documentation.
This section provides an overview and examples of video upload functionality using Java.
The Java 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.
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.
This section provides examples of some of the video upload features mentioned in the previous section.
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.
cloudinary.uploader().upload("dog.mp4", ObjectUtils.asMap("resource_type", "video", "public_id", "my_folder/my_sub_folder/dog_closeup", "eager", Arrays.asList( new Transformation().width(300).height(300).crop("pad").audioCodec("none"), new Transformation().width(160).height(100).crop("crop").gravity("south").audioCodec("none")), "eager_async", true, "eager_notification_url", "https://mysite.example.com/notify_endpoint"));
The following example renders a direct file upload input field using the
imageUploadTag helper method. Although the default
resource_type for this method is
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.
cloudinary.uploader().imageUploadTag("video_id", com.cloudinary.utils.ObjectUtils.asMap("resource_type", "video", "eager", Arrays.asList( new EagerTransformation().format("83u8").rawTransformation("sp_full_hd")), "eager_async", true, "eager_notification_url", "https://mysite.example.com/notify_endpoint", ), com.cloudinary.utils.ObjectUtils.asMap("id", "my_upload_tag") );
The following example renders a an unsigned direct file upload input field using the
unsignedImageUploadTag 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_presetis defined as an unsigned preset for your account.
cloudinary.uploader().unsignedImageUploadTag("video_id", "my_upload_preset", com.cloudinary.utils.ObjectUtils.asMap("resource_type", "video", "public_id", "my_video", "tags", Arrays.asList("user_218", "screencast"), ), com.cloudinary.utils.ObjectUtils.emptyMap() );