Downloading YouTube Videos on Linux

📢 This article was translated by gemini-3-flash-preview

Introduction

Since we’ve already covered the Windows command line, we can’t skip Linux.

Windows article: Downloading YouTube videos via Command Line

Download yt-dlp

I recommend setting up a Python environment first, then heading to Releases · yt-dlp/yt-dlp · GitHub to download yt-dlp. If you don’t want to deal with Python, just download the yt-dlp_linux binary.

After downloading, grant it execution permissions and move it to /usr/local/bin/.

Download ffmpeg

Refer to the official site: Download FFmpeg

On Fedora, use the following command:

1
sudo dnf install ffmpeg

Configuration File

Switch to the configuration directory:

1
cd ~/.config

Create the folder and enter it:

1
2
mkdir yt-dlp
cd yt-dlp

Create the configuration file:

1
vi config

Here is my configuration:

1
-f bv+ba/b -o ~/Videos/%(uploader)s/%(upload_date)s%(title)s%(id)s.%(ext)s --continue --merge-output-format mp4

Breakdown:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
-f bv+ba/b # Best video + best audio / best quality

-o # Output folder configuration
/%(uploader)s/ # Create folder based on channel name
%(upload_date)s # Upload date
%(title)s # Video title
%(id)s # Video ID
.%(ext)s # File extension

--continue # Resume partial downloads

--merge-output-format mp4 # Merge into mp4 format

References

Batch converting video formats with ffmpeg (Wait, do I really need to link my own article?)

This post is licensed under CC BY-NC-SA 4.0 by the author.