How to download youtube videos using open source software

Nikhil Vijayan
1 min readOct 5, 2022

UPDATE (April 7, 2024)

The method below stopped working for me sometime in 2023, here is a working solution I currently use:

You will need homebrew installed. See for instructions on installing Homebrew.

Install the yt-dlp homebrew package from

Example usage:

yt-dlp --extract-audio --audio-format mp3\?v\=<your-video-id>

See for additional options.


If you’ve tried to download youtube videos while trying not to download malware, this is for you.


You will need to have Docker installed, and know if your terminal uses bash or zsh.

All you have to do is use this incantation

alias yt-dl='docker run \
--rm -i \
-e PGID=$(id -g) \
-e PUID=$(id -u) \
-v "$(pwd)":/workdir:rw \

Add 👆this to your ~/.bash_aliases file or ~/.bashrc or ~/.zshrc file.

Once you’ve done that (and used source ~/.zshrc , or whatever the name of your rc file you updated) you can download videos by using yt-dl <youtube-url>

Further reading:

Disclaimer: this might work for apple and linux devices only. Post a comment if you need help.

Also, we’re using docker here so we don’t run into any problems in terms of yt-download not being compatible with your machine (this is what happened with me).

Example usage:

yt-dl --extract-audio --audio-format mp3