ffmpeg compress video code example

Example 1: ffmpeg shrink video size

ffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4

Example 2: ffmpeg reduce video size

$ ffmpeg -i "[inputName.mp4]" -vcodec [libx265]  -crf [28] "[outputName.mp4]"
# vcodec: libx265 for HVEC or libx264 for H.264
# crf: ranges form 0-51, (Value > less quality & size), (Value < Higher quality & size, size can get higher than the original size)
# To ouput Matroska/Mkv ad: -f matroska

Example 3: ffmpeg compile video

ffmpeg -i a%d.jpg -r 10 -c:v libx264 -preset slow -crf 21 output.mp4

Example 4: ffmpeg compile video

ffmpeg -i 'img-%03d.jpeg' -r 10 out.mkv