All posts

Video to WebM via CLI

Re-encode any video to VP9 + Opus with ffmpeg.

Open online converter

Packages to install

Install ffmpeg built with libvpx-vp9 and libopus — Ubuntu’s package includes both.

ffmpeg
apt install
sudo apt-get update
sudo apt-get install -y ffmpeg

How to run the command

ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 32 -b:v 0 -deadline good -cpu-used 4 -c:a libopus -b:a 96k output.webm. The same profile works for MOV, MKV, and AVI.

ffmpeg
ffmpeg -y -i input.mp4 -c:v libvpx-vp9 -crf 32 -b:v 0 -deadline good -cpu-used 4 -c:a libopus -b:a 96k output.webm

Dockerfile example

Build a minimal Ubuntu image with the required packages and run the conversion inside the container.

Dockerfile
FROM ubuntu:24.04

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        ffmpeg && \
    rm -rf /var/lib/apt/lists/*

WORKDIR /work
docker build && docker run
docker build -t video-to-webm .
docker run --rm -v "$PWD:/work" -w /work video-to-webm \
  ffmpeg -y -i input.mp4 -c:v libvpx-vp9 -crf 32 -b:v 0 -deadline good -cpu-used 4 -c:a libopus -b:a 96k output.webm

Example commands

Run these locally after installing the packages, or inside the container from the Dockerfile.

Example 1
ffmpeg -y -i input.mp4 -c:v libvpx-vp9 -crf 32 -b:v 0 -deadline good -cpu-used 4 -c:a libopus -b:a 96k output.webm
Example 2
ffmpeg -y -i input.mov -c:v libvpx-vp9 -crf 32 -b:v 0 -deadline good -cpu-used 4 -c:a libopus -b:a 96k output.webm