As technologies advance apace, the volume of online videos continues to increase fast. Instagram, WhatsApp, Facebook, YouTube, TikTok are just a few platforms among many that massively share and distribute videos around the clock.
When compared to other media files, such as those for audios and images, video files are larger, consuming a lion’s share of data bandwidth. Compressing video files enables faster downloads, uploads, and streaming online.
For people in remote areas and developing regions, where download and upload speeds usually range between 720 kb and 1.5 Mb per second, compressing video files is not optional—it’s mandatory! To do that and deliver videos of a smaller file size to users with Cloudinary, you as developers can choose either of these two ways:
- Compression as part of the upload request
- On-the-fly compression during delivery
q_autoparameter, Cloudinary intelligently encodes video using the most optimized settings, for the best trade-off between file size and quality. Read more.
This technique involves applying compression transformation to the videos during upload before storage. Cloudinary makes the process a walk in the park with just one line of code in Ruby, Python, or PHP:
Cloudinary::Uploader.upload("cool_video.mp4", :resource_type => :video, :quality => 60)
cloudinary.uploader.upload("cool_video.mp4", resource_type = "video", "quality" = "60")
\Cloudinary\Uploader::upload("my_video.mp4", [ "resource_type" => "video", "quality" => "60"]);
In the code above, you specify the
quality parameter to manipulate the video’s quality and size before Cloudinary stores the video in the cloud.
qualityparameter, just type
auto. Cloudinary then automatically adjusts the compression quality for your video by applying the optimal balance between the video’s file size and quality.
With this Cloudinary technique, you upload videos straight to the cloud and then apply the
quality compression parameter when delivering them to users. You can also serve videos in the formats that pertain to the various web browsers and mobile devices.
You configure quality on a 0-100 scale. The higher the video quality, the larger the video size; the lower the video quality, the smaller the video size. To compress video size on the fly, adjust their
quality parameter in a codeline. See the examples below.
On-the-fly video compression through the URL
q_50 in the above URL,
q stands for quality;
50 is the number of your choice on a 0-100 scale.
Front-end developers, you can drop those components in your app out of the box, like this:
dog represents the name of the uploaded video, which is usually the public ID (
publicId) on the Cloudinary storage.
Compress video size automatically with Cloudinary making media much more accessible. Furthermore, Cloudinary’s drop-in tools and services are effective, simple, and intuitive, saving you ample time to focus on your project.
For details, check out the following Cloudinary documentation:
- A complete reference on video manipulation and transformation with Cloudinary.
- SDKs and libraries: server side, client side, and mobile
- Video Transcoding and Manipulation
- Top 10 Mistakes in Handling Website Videos and How to Solve Them
- ExoPlayer Android Tutorial: Easy Video Delivery and Editing
- Ultimate HTML5 Video Player Showdown: 10 Players Compared
- How to Generate Waveform Images From Audio Files
- Auto Generate Subtitles Based on Video Transcript
- Auto-Generate Video Previews with Great Results Every Time
- Adaptive HLS Streaming Using the HTML5 Video Tag
- Video Optimization With the HTML5 <\video> Player
- Converting Android Videos to Animated GIF Images With Cloudinary: A Tutorial