This tutorial shows how to download a YouTube video at the highest useful quality on Linux Mint 22 using yt-dlp, ffmpeg, and Deno. It also explains how to select specific video and audio streams when you want a standard MP4 file with H.264 video and AAC audio.
1. Install the latest yt-dlp
It is better to use the current official yt-dlp binary rather than an older package from the Linux distribution repositories:
sudo curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux -o /usr/local/bin/yt-dlp
sudo chmod a+rx /usr/local/bin/yt-dlp
hash -rCheck that the correct executable is being used:
which yt-dlp
yt-dlp --versionwhich yt-dlp should normally return:
/usr/local/bin/yt-dlp2. Install ffmpeg
ffmpeg is required to merge separate video and audio streams:
sudo apt update
sudo apt install ffmpeg3. Install Deno
Recent YouTube extraction support in yt-dlp may require an external JavaScript runtime. Deno is a good choice:
curl -fsSL https://deno.land/install.sh | shDeno will prompt you to add itself to the current shell's PATH. Accept the prompt, then close and reopen the terminal.
Then verify the installation:
deno --version4. List the formats available for the video
Before downloading, inspect the available video and audio streams:
yt-dlp -F "https://youtube.com/watch?v=VIDEO_ID"The output contains a format ID for every available stream, together with information such as resolution, frame rate, codec, bitrate, language, and container.
For example, you may see several 1080p streams using different codecs:
avc1= H.264/AVCvp9= VP9av01= AV1
If your goal is broad compatibility with televisions, media players, phones, and video editors, H.264 video plus AAC audio inside an MP4 container is usually the safest choice.
5. Select the best H.264 video and the original AAC audio
In my example, the format list contained:
270— 1920x1080, 25 fps, H.264/AVC video140-1— original Italian audio, AAC, about 129 kb/s
I therefore downloaded those two streams explicitly:
yt-dlp -f "270+140-1" \
--merge-output-format mp4 \
-o "Intervista Francesco Galgani 23 agosto 2026.%(ext)s" \
"https://youtube.com/watch?v=2kQZZ2thq3w"yt-dlp downloads the selected video and audio streams separately and then asks ffmpeg to merge them into a single MP4 file.
Why not simply use the generic best-quality selector?
A generic command such as:
yt-dlp -f "bv*+ba/b" --merge-output-format mp4 "VIDEO_URL"is convenient, but the highest-quality stream selected by YouTube may use VP9 or AV1 instead of H.264. The resulting file can still use an .mp4 container, but codec compatibility may be lower on older devices or software.
By checking the format list first and selecting the H.264 video stream and AAC audio stream explicitly, you can keep the original streams without re-encoding while producing a highly compatible MP4 file.
Important note
Format IDs are specific to each YouTube video and can change. Do not assume that 270 and 140-1 will be correct for another video. Always run yt-dlp -F first and choose the format IDs that match the resolution, codec, audio language, and bitrate you want.
(August 26, 2026)