Compress video on Mac, the better way
Published in
2 min readNov 3, 2019
You want to reduce the size of a video without loss in quality. If you google ffmpeg compress video
, the top answers are
1. StackExchange: Calculate the bitrate by dividing 1 GB by the video length in second, then use
ffmpeg -i input.mp4 -b .... output.mp4
2. ffmpeg wiki: Choose a CRF value, then a preset, and a tune,then
ffmpeg -i input.avi -c:v libx264 -preset ... -crf ... -c:a copy output.mkv
…
What? Do you have to do math and make hard choices just to compress a video? You don’t. In fact, these commands are slow, and probably won’t give you the output you wanted.
Here’s a simpler, faster way:
ffmpeg -i [FILE].mp4
Put in the filename. In the result, first look forSteam #0 Video
then, in your video stream, look for a data that have the unitkb/s
. This is the bitrate of your video stream. It’s completely fine if you don’t know what bitrate means. Just copy down this number.ffmpeg -i [FILE].mp4 -c:v h264_videotoolbox -b:v [BIT RATE]k -c:a aac output.mp4
Put in your filename and bit rate obtained from step 1.- That’s it! Enjoy fast & good quality compression
Explanation:
-i
gives you the information of the video-c:v
-c:a
-b:v
c: codec, b: bitrate, v: video, a: audioh264_videotoolbox
a codec that utilizes macOS hardware acceleration, which make encoding superfast and you won’t be burning your CPU.- But, h264_videotoolbox doesn’t work well with CRF values. Even if you do
-crf 0
you would still get unacceptably bad quality. That’s why we have to specify the bit rate. aac
offers better quality thanmp3
at the same bitrate