Compression

Compressing video using ffmpeg

I use gpu-screen-recorder to create screencasts. The only problem is the resulting videos are huge, which is difficult to share online.

Fortunately, ffmpeg exists.

For decent quality, at a decent file size, quickly

ffmpeg -i input.mp4 -c:v libx264 -crf 25 -preset medium -c:a copy output.mp4

Tests on my machine produce a video file around 80% smaller than the original, at a speed of 1.7x.

For a smaller file, at the cost of speed

ffmpeg -i input.mp4 -c:v libx265 -crf 30 -preset slow -c:a copy output.mp4

Tests produce a file 90% smaller, at a significantly slower speed of 0.4x.

Part of the penalty is due to x265 encoding, and part will be of the "slow" preset.

A thing of note is that I found the CRF value1 of 25 for x264 was visually indistinct to 30 for x265.

Of course, the speed and perhaps compression rate will differ per machine.

Footnotes

  1. The Constant Rate Factor (CRF) is a value which determines the bitrate to use


built by panulat v1.4 - Thu, 19 Dec 2024 14:17:23 GMT