How to Download MP4 from yt-dlp: A Complete Guide
yt-dlp is one of the most powerful command-line tools available for downloading video content from hundreds of websites. If you've landed here, you probably already know it works — but getting it to output a clean MP4 file specifically isn't always the default behavior. Here's exactly how that process works, and what factors shape your results.
What yt-dlp Actually Does by Default
When you run a basic yt-dlp command without any format flags, the tool selects what it considers the best available quality — which often means downloading video and audio as separate streams and merging them. The output container in that case is frequently MKV or WebM, not MP4.
This surprises a lot of users. The video looks fine, but the file extension isn't what they expected, and some media players or devices don't handle MKV as smoothly as MP4.
To get a proper MP4, you need to be explicit about both the format selection and the output container.
The Core Command for MP4 Output
The most reliable way to force MP4 output is:
yt-dlp -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" --merge-output-format mp4 URL Breaking this down:
-f "bestvideo[ext=mp4]+bestaudio[ext=m4a]"— requests the best video stream that's already in MP4/H.264 format, paired with M4A audio/best[ext=mp4]— fallback to a pre-merged MP4 if separate streams aren't available/best— final fallback if nothing else matches--merge-output-format mp4— instructs yt-dlp to mux the final output into an MP4 container
This combination handles the most common scenarios cleanly.
Why FFmpeg Is Essential Here 🔧
yt-dlp relies on FFmpeg to merge video and audio streams and to remux containers. If FFmpeg isn't installed or isn't in your system's PATH, yt-dlp will either skip the merge step entirely or throw an error.
FFmpeg is not bundled with yt-dlp — it's a separate installation. On Windows, you'll typically add it to PATH manually. On macOS, Homebrew (brew install ffmpeg) handles it cleanly. On Linux, your package manager (apt, dnf, pacman) will have it.
Once FFmpeg is in place, the merge command above works as expected.
Choosing a Specific Resolution
If you want a particular resolution rather than the absolute best available, you can refine the format string:
yt-dlp -f "bestvideo[height<=1080][ext=mp4]+bestaudio[ext=m4a]/best[height<=1080][ext=mp4]" --merge-output-format mp4 URL Common height values to filter by:
| Target Quality | Height Filter |
|---|---|
| 4K / 2160p | height<=2160 |
| 1080p Full HD | height<=1080 |
| 720p HD | height<=720 |
| 480p | height<=480 |
| 360p | height<=360 |
Using <= rather than = means yt-dlp will grab the best quality up to that ceiling — useful when a specific resolution isn't always available.
Listing Available Formats First
Before committing to a download, it's worth checking what's actually available for a given video:
yt-dlp -F URL This outputs a full format list with format codes, extensions, resolutions, codecs, and file sizes. You'll immediately see whether native MP4/H.264 streams exist, or whether the best quality is served in VP9/WebM — which yt-dlp can still merge into MP4 via FFmpeg, but it involves transcoding.
When Transcoding Comes Into Play
Some platforms serve their highest-quality streams exclusively in VP9 or AV1 codec inside a WebM container. In that case, your options are:
- Accept the quality trade-off — use a native MP4 stream at a lower resolution
- Allow transcoding — yt-dlp with FFmpeg can convert VP9/WebM to H.264/MP4, but this takes significantly more time and CPU power
Transcoding is lossless in terms of perceived quality at the right settings, but it's not fast. On lower-powered machines, transcoding a long 4K video can take many minutes.
Setting a Default Template for File Naming 🎬
yt-dlp won't overwrite files with clean names unless you tell it how to label them. A practical output template:
yt-dlp -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" --merge-output-format mp4 -o "%(title)s.%(ext)s" URL The -o flag controls the filename. %(title)s pulls the video's title, and %(ext)s appends the correct extension automatically. You can also use %(uploader)s, %(upload_date)s, or %(id)s to build structured naming conventions.
Variables That Affect Your Results
Getting a clean MP4 isn't one-size-fits-all. Several factors shape what actually happens on your system:
- yt-dlp version — the tool updates frequently; older versions have different default behaviors and format string syntax
- FFmpeg version — mismatches between yt-dlp and FFmpeg can cause merge failures
- Operating system — PATH configuration differs between Windows, macOS, and Linux, which affects whether FFmpeg is found automatically
- Source platform — not all sites serve MP4 natively; codec availability varies widely
- Available codecs on the source — some videos only have VP9 or AV1 at high quality, making native MP4 extraction impossible without transcoding
- Disk space and CPU headroom — transcoding and high-resolution merges are resource-intensive
Saving Your Settings with a Config File
If you always want MP4 output, you can store these preferences in a yt-dlp config file rather than retyping flags every time. The config file location varies by OS:
- Linux/macOS:
~/.config/yt-dlp/config - Windows:
%APPDATA%yt-dlpconfig.txt
Adding the format string and merge flag there means every download defaults to your preferred behavior without extra typing.
The gap between understanding this process and getting the exact output you want often comes down to your specific platform combination, your FFmpeg setup, and which codecs the source actually provides — details that only become clear once you run -F on your target URL and see what's actually on offer.