Video compression
Encode like you mean it.
Let’s play.
Videos are everywhere. EVERYWHERE! But videos can and will be huge when 4k becomes an internet standard. Currently, 1920x1080 is king and we usually have no problem hosting or playing this resolution.
Because we can doesn’t mean we should.
Right now, the (good) trend of web performance is on the rise. Everyone wants a blazing fast loading website, which might not be possible if we send requests to 100mb (or even more) videos.
With a good connection, users will not see the difference. But if we go down that path, nor will they with a 300mb one. So the goal is to make every asset as small as possible. It’s already the case with images. But it’s simpler and faster than video encoding.
Small size, best quality.
Let’s say we exported a 1920x1080 video from Premiere Pro with these basic settings:
It’s gorgeous, it’s Full HD, it’s 1:30 minute of excellent editing but it’s 50mb… What a shame.
We can already bring down the size from Premiere or Media Encoder by selecting CBR instead of VBR and using a low bitrate (like 2 or 3).
Let’s now use Handbrake! It’s free, open source and multi platform. You can also read this great article from Ueno on video encoding.
Please please PLEASE. Never export videos from within After Effects.
Handbrake
Summary screen
While it’s not as nice as Premiere Pro, it has way more exporting capabilities. Follow these steps to use good standard settings:
- Open your source video
- Select a preset corresponding to your future usage like Fast 1080p30
- Check Web Optimized
- Keep MPEG-4 as the format
Video screen
- Keep H.264 (x264) or use H.264 nvidia nvenc if you can (crazy fast encoding by nvidia)
- Choose Constant Quality and try a value between 20 and 30 (higher = smaller size but lower quality)
- Choose Peak Framerate. If you don’t know the framerate, keep the default setting
- Choose the type of video you are encoding (film, animation…)
Audio screen
If you don’t have audio, be sure to set the audio channel to none. If you have an audio channel, these settings are great and will not influence the size much:
- Codec AAC
- Samplerate 44.1
- Bitrate 192 to 256 (your choice)
Export!
I used a RF of 25 for this example and no audio.
- My Premiere Pro video was 50,6mb
- My Handbrake video is 5,5mb
What a save!
I ended up dividing the original size by 10. Which is cool. I tried with a RF of 30. The video was still pretty good and only 3,3mb.
Exporting for the web
Now that we know how to properly compress videos, let’s go further. Say we have a website with a lot of videos on the same page. We still want to load the content as fast as possible. So our videos need to be as small as possible. We won’t do better than previously seen using mp4/H.264. However, we can use webm/VP9. Webm is an html video format and VP9 is its latest codec.
Using Handbrake and webm/VP9, we can achieve really great compression without losing too much quality (or none at all depending on the settings). I was able to divide by 4 the size of a video using these presets:
The only down side is that it takes some time to encode. It will depend on the video length and your computing power.
I tried various settings but I read here that VP9 is supposed to be used with two-pass encoding. You then have to find the right bitrate (here 1000) for your situation.