youtube-dl is an opensource command line tool to download video or audio from online video streaming services.
Videos downloaded in mkv
or webm
extensions can be played by VLC Media player in all major devices and operating systems including iPhone, Android devices.
Tool website: https://youtube-dl.org/
This gist shows the example commands to use the tool and doesn't support or encourage piracy or violation of copyrights of the online streaming service or the author of the content
brew install youtube-dl
brew install ffmpeg
sudo apt-get install youtube-dl -y
sudo apt-get install ffmpeg -y
choco install youtube-dl
choco install ffmpeg
brew upgrade youtube-dl
brew upgrade ffmpeg
sudo apt-get install --only-upgrade youtube-dl -y
sudo apt-get install --only-upgrade ffmpeg -y
choco upgrade youtube-dl
choco upgrade ffmpeg
youtube-dl --version
ffmpeg
The following commands are tested with:
- youtube-dl version
2018.11.07
- ffmpeg version
4.1
youtube-dl --yes-playlist --ignore-errors --continue --no-overwrites --output "~/Downloads/%(title)s.%(ext)s" "{URL}"
Explanation of params:
--yes-playlist
-> Download multiple videos if the url is a playlist--ignore-errors
-> Ignore errors like geo resitriction of a video or deleted video in a playlist and continue with rest of the playlist--continue
-> Resume if any of the video is partially downloaded in the local file system--no-overwrites
-> If a file is already downloaded in local file system, then skip the download--output "~/Downloads/%(title)s.%(ext)s
-> Specify the download directory with filename and extension extracted from the video"{URL}"
-> URL of the video or playlist
Use --extract-audio --audio-format mp3 --format 'bestaudio'
to extract only the audio information and store as mp3
file
youtube-dl --yes-playlist --ignore-errors --continue --no-overwrites --extract-audio --audio-format mp3 --format 'bestaudio' --output "~/Downloads/%(title)s.%(ext)s" "{URL}"
youtube-dl --ignore-errors --continue --no-overwrites --output "~/Downloads/%(title)s.%(ext)s" "{URL}"
Use --format 'bestvideo+bestaudio'
to download the video with best quality of audio and video
youtube-dl --ignore-errors --continue --no-overwrites --format 'bestvideo+bestaudio' --output "~/Downloads/%(title)s.%(ext)s" "{URL}"
Use --recode-video mp4
option to convert the downloaded file as mp4
format
youtube-dl --ignore-errors --continue --no-overwrites --recode-video mp4 --output "~/Downloads/%(title)s.%(ext)s" "{URL}"
youtube-dl --ignore-errors --continue --no-overwrites --extract-audio --audio-format mp3 --format 'bestaudio' --output "~/Downloads/%(title)s.%(ext)s" "{URL}"
Use --batch-file batchlist.txt
to capture the list of URLs in a separate lines in a text file and download them in batch
youtube-dl --ignore-errors --continue --no-overwrites --format 'bestvideo+bestaudio' --batch-file batchlist.txt --output "~/Downloads/%(title)s.%(ext)s"
Use --write-sub
to download the subtitle information along with the video
youtube-dl --write-sub --ignore-errors --continue --no-overwrites --format 'bestvideo+bestaudio' --output "~/Downloads/%(title)s.%(ext)s" "{URL}"
Use --proxy "http[s]://[user:password@]proxyhost[:port]"
to download a geo restricted video
youtube-dl --proxy "http[s]://[user:password@]proxyhost[:port]" --ignore-errors --continue --no-overwrites --format 'bestvideo+bestaudio' --output "~/Downloads/%(title)s.%(ext)s" "{URL}"
ffmpeg -i input.mkv output.mp4 -hide_banner