A container format (or muxer) is the "box" that holds your video, audio, and subtitle streams together. It does not determine quality — the codec does. Choosing the right container is about compatibility, features, and metadata.
Before we dive in, here's the most important command you'll use: remuxing. This changes the container without re‑encoding (instant, lossless).
ffmpeg -i input.mkv -c copy output.mp4
Key takeaways
- MP4 – universal standard. Use
-movflags +faststartfor web streaming. - MKV – open, flexible, supports any codec. Perfect for archiving.
- WebM – royalty‑free, web‑optimised. Use VP9/AV1 + Opus.
- MOV – Apple's QuickTime. Great for editing.
- MPEG‑TS (.ts) – built for broadcast and live streaming.
- Remux with
-c copyto change containers instantly, without quality loss.
List & probe available formats
FFmpeg supports dozens of containers. List them all with:
ffmpeg -formats– shows all supported formats (E=encoding, D=decoding).ffmpeg -muxers– only output formats.ffmpeg -demuxers– only input formats.
To inspect what's inside a file, use ffprobe:
ffprobe -hide_banner video.mp4
Video containers
MP4 (MPEG‑4 Part 14) – the universal standard
MP4 is the most compatible container in the world. It plays everywhere: browsers, phones, TVs, and video platforms. It works best with H.264/H.265 video and AAC audio. For web delivery, always enable faststart to move the metadata ('moov atom') to the front — this allows the video to start playing before it's fully downloaded.
# Standard MP4 ffmpeg -i input.mov -c:v libx264 -crf 23 -c:a aac -b:a 128k output.mp4 # Web‑optimised (faststart) ffmpeg -i input.mov -c:v libx264 -crf 23 -c:a aac -movflags +faststart output.mp4 # Fragmented MP4 for DASH / HLS ffmpeg -i input.mov -c copy -movflags +frag_keyframe+empty_moov output.mp4
MP4 variants
- .m4a – audio‑only MP4 (AAC/ALAC).
- .m4v – video MP4 (often used for Apple devices).
- .3gp – MP4 variant for mobile (older phones).
MOV – QuickTime (Apple ecosystem)
MOV is Apple's container. It's identical to MP4 under the hood, but it supports more codecs (like ProRes, DNxHD, uncompressed PCM) and is the standard for editing and post‑production. Use MOV when you're working in Final Cut, Premiere, or DaVinci Resolve.
# ProRes in MOV (editing master) ffmpeg -i input.mp4 -c:v prores -profile:v 3 -c:a pcm_s16le output.mov
Note: MOV files often have large file sizes. They're meant for editing, not distribution.
MKV (Matroska) – the open, flexible powerhouse
MKV is an open‑source container that supports virtually any codec. It handles unlimited video/audio/subtitle tracks, chapters, attachments (fonts), and complex metadata. It's the top choice for archiving, anime, and home media servers (Plex, Jellyfin).
# Create MKV with multiple audio tracks and subtitles ffmpeg -i video.mp4 -i audio_eng.flac -i audio_fre.flac -i subs.srt \ -map 0:v -map 1:a -map 2:a -map 3:s \ -c:v copy -c:a flac -c:s copy -metadata title="My Movie" output.mkv
MKV options
- Use
-mapto select which streams go into the MKV. -metadatalets you set title, language, etc.- For chapters, create a
chapters.txtfile and use-i chapters.txt -map_metadata 1.
WebM – royalty‑free web video
WebM is the open, royalty‑free container designed specifically for the web. It only supports VP8/VP9/AV1 video and Vorbis/Opus audio. It's the standard for YouTube, Wikipedia, and modern browsers. Use WebM when you want the best web performance without patent worries.
# VP9 + Opus WebM ffmpeg -i input.mov -c:v libvpx-vp9 -crf 30 -b:v 0 -c:a libopus -b:a 96k output.webm
AVI – the legacy veteran
AVI (Audio Video Interleave) was introduced by Microsoft in 1992. It's old, has a 2GB/4GB file size limit (unless using OpenDML), and doesn't support modern features well. That said, it's still used in some legacy systems and industrial equipment. Use it only when you have to.
# AVI with MJPEG video and PCM audio (widely compatible) ffmpeg -i input.mov -c:v mjpeg -q:v 5 -c:a pcm_s16le output.avi
MPEG‑TS (Transport Stream) – broadcast & streaming
MPEG‑TS (.ts) is the container used for broadcast television, Blu‑ray, and live streaming (RTP, HLS). It's designed to be resilient to packet loss — if a piece of data is corrupted, the stream can recover. Use it for live events, satellite/cable distribution, and when you need to stream to legacy set‑top boxes.
ffmpeg -i input.mov -c copy -f mpegts output.ts
FLV – Flash Video (legacy)
FLV was the backbone of web video in the Flash era. It's still used in some legacy streaming servers and devices. Unless you're maintaining a very old system, you can skip FLV in favour of MP4 or WebM.
ffmpeg -i input.mp4 -c copy -f flv output.flv
GIF – animated images
GIF is a palette‑based image format that supports animation. FFmpeg can create GIFs, but they are large and limited to 256 colours. For modern web animations, use WebP or MP4. If you must create a GIF, use a high‑quality palette.
# High‑quality GIF with custom palette ffmpeg -i input.mp4 -vf "fps=10,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" output.gif
Audio‑only containers
MP3
The most compatible audio format. Use it for podcasts, music distribution, and legacy devices.
ffmpeg -i input.mov -c:a libmp3lame -b:a 192k output.mp3
M4A (AAC / ALAC)
The audio‑only version of MP4. Use AAC for compressed, high‑quality audio, or ALAC for lossless.
# AAC in M4A ffmpeg -i input.mov -c:a aac -b:a 128k output.m4a # ALAC lossless in M4A ffmpeg -i input.mov -c:a alac output.m4a
OGG (Vorbis / Opus)
OGG is the open container for Vorbis and Opus audio. It's free, efficient, and widely used in open‑source projects and games.
ffmpeg -i input.mov -c:a libopus -b:a 96k output.ogg
FLAC
Free Lossless Audio Codec. Perfect for archiving music and high‑fidelity audio. File sizes are large but quality is perfect.
ffmpeg -i input.mov -c:a flac -compression_level 8 output.flac
Container comparison table
| Container | Extension | Best video codecs | Best audio codecs | Subtitle support | Best for |
|---|---|---|---|---|---|
| MP4 | .mp4, .m4v, .m4a | H.264, H.265 | AAC, MP3, ALAC | Limited (TTXT, VobSub) | Universal compatibility, web |
| MOV | .mov | ProRes, DNxHD, H.264 | PCM, AAC | Limited | Editing, post‑production |
| MKV | .mkv | Any (H.264, H.265, VP9, AV1) | Any (AAC, MP3, FLAC, Opus) | Excellent (ASS, SRT, PGS) | Archiving, media servers, fansubbing |
| WebM | .webm | VP8, VP9, AV1 | Vorbis, Opus | Native (WebVTT) | Royalty‑free web video |
| AVI | .avi | MJPEG, MPEG‑4 | PCM, MP3 | Poor | Legacy / industrial systems |
| MPEG‑TS | .ts | H.264, H.265 | AAC, MP2 | Limited | Broadcast, live streaming, HLS |
| FLV | .flv | H.264, VP6 | MP3, AAC | No | Legacy Flash applications |
Container‑specific quirks & best practices
1. The "moov atom" in MP4
The moov atom is the metadata index in an MP4 file. If it's at the end, the player must download the entire file before starting playback. Use -movflags +faststart to move it to the front.
2. Fragmented MP4 for adaptive streaming
For HLS and DASH, you need fragmented MP4 (-movflags +frag_keyframe+empty_moov). This allows the file to be split into small chunks.
3. MKV and audio gap handling
MKV is very tolerant of bad audio sync. Use -async 1 if you encounter sync issues when remuxing.
4. AVI file size limits
Standard AVI has a 2GB limit. Use -fs to set a file size limit, or use the OpenDML extension (-f avi -flags +bitexact).
5. WebM mandates VP9/AV1 and Opus/Vorbis
You cannot put H.264 or AAC into a WebM file. FFmpeg will error if you try. Use VP9/AV1 + Opus for WebM.
How to choose the right container
- Delivering to clients / universal playback → MP4 (H.264 + AAC, faststart).
- Archiving a complete movie → MKV (lossless video + multiple audio/subtitle tracks).
- Web streaming (modern browsers) → WebM (VP9/AV1 + Opus) or MP4 (H.265 + AAC).
- Editing in Premiere/Resolve → MOV (ProRes + PCM).
- Live broadcast / satellite → MPEG‑TS (.ts).
- Audio‑only podcast → MP3 (compatible) or M4A (better quality).
- Lossless audio archive → FLAC.
Want to see how formats interact with codec choices? Check out our Complete Codecs Guide. For practical compression, see the compression guide.
Ready to remux and convert on a visual timeline? FFmpegLab lets you switch containers, apply faststart, and generate the exact command — all offline in your browser.