How to compress mp4 in one command with ffmpeg

With ffmpeg, we can create a free video compresser on our local machine.

First, create a shell function on you .bashrc or .zshrc:

function mp4-compress() {
    filename=$(basename -- "$1")
    extension="${filename##*.}"
    name="${filename%.*}"
    ffmpeg -i "$1" -vcodec libx265 -crf 28 ${name%.*}-compress.${extension##*.}
}

Then, use it:

mp4-compress happy.mp4

Then the output file will be happy-compress.mp4

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *