Docs: https://trac.ffmpeg.org/wiki/Encode/VP9
INPUT="video.mov"
OUTPUT="converted-video.webm"
CPUS=4 # Adjust the number of cores your CPU have
FRAMERATE=15 # Adjust for your needs
VARIABLE_BITRATE=100K # Adjust for your needs, can be represented as 1M, 1000k, etc.
MAX_BITRATE=200k # adjust for your needs
WIDTH=800
HEIGHT=-1 # setting width or height as -1 means to keep aspect ratio
# We are going to use 2-pass as suggested by the docs
# First pass is super fast and will generate a *.log file to help the coded better convert the video
ffmpeg -i "$INPUT" \
-threads $CPUS -cpu-used $CPUS \
-c:v libvpx-vp9 \
-r $FRAMERATE \
-b:v $VARIABLE_BITRATE \
-maxrate $MAX_BITRATE \
-vf scale=${WIDTH}:${HEIGHT} \
-pass 1 -an -f null \
/dev/null
# Second pass will be slower, and will actually convert the video using the log from first step
ffmpeg -i "$INPUT" \
-threads $CPUS -cpu-used $CPUS -deadline realtime \
-c:v libvpx-vp9 \
-r $FRAMERATE \
-b:v $VARIABLE_BITRATE \
-maxrate $MAX_BITRATE \
-vf scale=${WIDTH}:${HEIGHT} \
-pass 2 -y \
"$OUTPUT"