Skip to main content
View all posts

How to Download YouTube Video and Audio from Mac Terminal

Step by step instructions on how to download any youtube video and audio from the Mac terminal using the yt-dlp package.

Marshall Hahn
Marshall HahnSoftware Engineer
How to Download YouTube Video and Audio from Mac Terminal

Install Homebrew

If you don’t already have it, install Homebrew – the missing package manager for macOS. Search for your “Terminal” app, which is pre-installed on your mac, and paste the following command (can also be found at https://brew.sh):

Install yt-dlp

Install the package yt-dlp, which is a feature-rich command-line audio/video downloader. The source code can be found on GitHub at https://github.com/yt-dlp/yt-dlp for the curious.

Download Video/Audio

Change directory to wherever you want to download the video/audio. The easiest way you can do this is by typing cd and then dragging and dropping a folder into the terminal. For this example, we’ll download the audio to the desktop:

Next, we need to get the available formats for the YouTube video. Replace the identifier of the youtube video after YOUTUBE_VIDEO_ID= at the beginning of the following command:

The uppercase -F flag at the end of the command instructs the API to list all available formats and quality you can download for the selected video. The output will look something like this:

In this example, we will use the id 140 to download the highest quality available audio only for the video. Use the lowercase -f flag and then specify the number afterwards:

Your download should begin and the file available in your desired destination shortly!