Some of my videos are very big in size, like 1GB+. Can I use ImageKit to reduce the video file size? Are there any limitations and how much compression can I expect?
You can use the following features in ImageKit Video API to reduce video file size. There are certain limits applicab;e
1. Automatic format conversion (WebM and MP4)
ImageKit Video API automatically converts videos to WebM format on supported devices and falls back to MP4 format on other devices. This can be done with the video optimization dashboard setting or you can use f-auto
to automatically serve the best format supported by the browser.
WebM format is smaller than MP4 at similar quality which will help you reduce video size and is supported on almost all devices.
For example: The original video below is 26MB in MP4, but gets delivered in ~5MB in WebM after compression.
https://ik.imagekit.io/ikmedia/sample-video.mp4
2. Video compression in real-time
ImageKit applies automatic compression to reduce video file size while preserving visual quality as much as possible. You just need to set the default video quality level in your video optimization setting dashboard or apply it with q
quality parameter in the URL.
ImageKit keeps the default quality setting at 50 which is good for most cases. At max you should take it up to 70 for a better visual quality while still maintaining a good compression. Higher than that, it will lead to much bigger video sizes whereas changes in visual quality may not be visible to naked eye. Even if the video is not converted to WebM, compression helps reduce size of even MP4 format.
3. Resize videos for mobile devices
If most of your users are coming to mobile, you can resize 1080p HD videos to lower resolutions like 720p or 480p depending on the device or context. 480p for example is nothing but resizing the video to height 480px. This can be done using the h
height transformation parameter in the URL.
For example:
https://ik.imagekit.io/ikmedia/sample-video.mp4?tr=h-480
While doing this automatic format conversion and compression are also done resulting in a very small size of video.
You can also consider using shorter video trims as trailers, or lazy loading videos that are not in the visible viewport for the user, or loading a video thumbnail instead of video autoplay. These methods can reduce the total size of video that loads on a user’s device till they actually interact with the video.