FFmpeg Essentials: Containers vs Codecs (MP4, MKV, MOV)
Tue Jul 02 2024
Understand containers vs codecs, when to remux or transcode, and enable fast start for MP4.
Containers like MP4 and MKV store streams encoded by codecs like H.264 and AAC. Knowing the difference helps you choose the right workflow and avoid needless quality loss.
Containers vs Codecs
- Containers: MP4, MKV, MOV, WebM — wrap streams, subtitles, and metadata.
- Codecs: H.264/H.265/VP9/AV1 (video), AAC/Opus/FLAC/MP3 (audio).
Practical Tasks
# Remux to MKV (no quality loss) ffmpeg -i input.mp4 -c copy output.mkv # Move MP4 moov atom for fast start ffmpeg -i input.mp4 -c copy -movflags +faststart output_faststart.mp4 # WebM (VP9/Opus) encode ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 0 -crf 32 -c:a libopus -b:a 96k out.webm
Pitfalls
- MP4 text subs need
mov_text. - Some platforms have limited MKV support.
Start by remuxing when possible; transcode only when you must change codecs or apply filters.