All posts
MP4 to WebM via CLI
Re-encode to VP9 + Opus with ffmpeg.
Open online converterPackages to install
Install ffmpeg built with libvpx-vp9 and libopus — Ubuntu’s package includes both.
ffmpeg
sudo apt-get update
sudo apt-get install -y ffmpegHow 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. -b:v 0 enables constant-quality CRF mode.
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.webmDockerfile example
Build a minimal Ubuntu image with the required packages and run the conversion inside the container.
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 -t mp4-to-webm .
docker run --rm -v "$PWD:/work" -w /work mp4-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.webmExample commands
Run these locally after installing the packages, or inside the container from the Dockerfile.
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.webmffmpeg -y -i input.mp4 -c:v libvpx-vp9 -crf 36 -b:v 0 -c:a libopus -b:a 64k output.webm