How to highly-compress videos using FFmpeg

Today while exploring ways to reduce video file size, we at SpadeBee came across a stunning method. Using FFMPEG, we reduced the file size of a 720p video from 1.7 GB to 67 MB without changing resolution or any quality loss!

FFmpeg is a free and open-source project consisting of a vast software suite of libraries and programs for handling video, audio, and other multimedia files and streams. At its core is the FFmpeg program itself, designed for command-line-based processing of video and audio files, and widely used for format transcoding, basic editing (trimming and concatenation), video scaling, video post-production effects, and standards compliance (SMPTEITU). [source: FFMPEG Wikipedia]

If you don’t already have FFmpeg installed to your machine please refer to our guide on How to install FFmpeg.

How it is done?

The ultimate compression is done by changing the video codec of your video.
video codec is an electronic circuit or software that compresses or decompresses digital video. It converts uncompressed video to a compressed format or vice versa. In the context of video compression, “codec” is a concatenation of “encoder” and “decoder”—a device that only compresses is typically called an encoder, and one that only decompresses is a decoder.

We shall be changing your codec to HEVC/H.265. In comparison to AVC, HEVC offers from 25% to 50% better data compression at the same level of video quality, or substantially improved video quality at the same bit rate.

Let’s begin

So let’s get compressing your video by following steps:

  1. Open up your command prompt/terminal/termux depending upon your OS.
  2. Check if ffmpeg is installed by following command
    ffmpeg -version
    It should be something like:
    ffmpeg -version output
    If it’s not, your ffmpeg is not installed properly. Follow our guide to install FFmpeg properly.
  3. Next thing we need to do is to use the following command:
    ffmpeg -i <input file> -c:v libx265 -crf 28 <output file>
    where <input file> and <output file> are your paths to input and output files respectively.
    For example:
    ffmpeg -i spadebee.mp4 -c:v libx265 -crf 28 newspadebee.mp4
    The process may take time depending upon your video length and your computer specs.
    1. Checking results:
      Input file:
      Input file properties
      Output file:
      output file properties

So here we compressed the file significantly.
Drop down your queries and ideas in comment section about video compressions!

source: stackexchange

We know no one likes ads, but please consider allowing us as we also need to keep running!

Please disable your adblocker or whitelist this site 🙂