How to download videos and Live using youtube-dl
What is youtube-dl
youtube-dl is a command line program to download videos and live from YouTube and other sites.
Official site: youtube-dl
Supported Sites
List of supported video sharing sites: Supported sites | yuboutine-dl.org
Right now, you can see that niconico, Instagram and Twitter are also supported.
You can also check the supported sites by running the following command
youtube-dl --extractor-descriptions
GitHub
GitHub Repository: youtube-dl | GitHub
A list and description of the command Option can also be found here.
Preparation
Install each tool in each environment, such as macOS and Windows.
- youtube-dl
http://ytdl-org.github.io/youtube-dl/download.html
For Mac, you can use Homebrew to install it.
brew install youtube-dl
. - FFmpeg
https://ffmpeg.org/
You may need it for video and audio conversion.
How to check youtube-dl version
youtube-dl --version
How to download YouTube videos
Example: Simple example
Enter the URL of the video or Live in the
youtube-dl <URL>
Issue
For example,
when you run youtube-dl on macOS with zsh, you get the following display:
zsh: no matches found:
Solution
Solution 1.
Execute the following command.
setopt +o nomatch
Solution 2.
Put the following commands in ~/.zshrc
.
setopt +o nomatch
Then restart the Terminal.
Or, run source ~/.zshrc
to reflect the configuration.
Example: Download the best available mp4 format or download the best other format
Here’s an example from GitHub’s README.md.
youtube-dl <URL> -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best'
Example: Converting downloaded video to mp4 format
youtube-dl <URL>
ffmpeg -i <youtube-dl download file name> <output file name>.mp4
How to download playlist videos in bulk
youtube-dl -i <URL of the playlist>
By using -i, --ignore-errors
, the
If some of the videos in the playlist fail to play and you get an error, continue downloading.
How to download multiple videos at once using file.
youtube-dl -a <FILE>
Description
First, save a plain text file with one URL per line.
Then, specify the path to the file (above, as shown in the above list) in the
Then you can download the file in batches.
How to download audio as mp3
youtube-dl -x --audio-format mp3 <URL>
Description
-x
part is an Option to convert a video file to an audio file. Abbreviated form of --extract-audio
.
You can download audio files with -x
alone.
--audio-format mp3
is an Option to specify the format of the audio file.
For the mp3
part, you can specify a different Format.
How to download videos from niconico.
Here’s an example to run in PowerShell
1..10 | % { youtube-dl <niconico URL> }
Description
When you try to download the video in niconico,
It is possible that the download will stop with an error in the middle.
So, as a workaround, I run youtube-dl 10 times.
To be specific, I get the following error.
ERROR: unable to download video data: HTTP Error 403: Forbidden
GitHub Issues
- https://github.com/ytdl-org/youtube-dl/issues/19261
- https://github.com/ytdl-org/youtube-dl/issues/14582
If you do it repeatedly, you can download 100% even if you do it manually.
Reference link
Please check the terms of use for each site.
YouTube: https://www.youtube.com/t/terms
niconico: https://account.nicovideo.jp/rules/account
Twitter: https://twitter.com/en/tos
Instagram: https://www.facebook.com/help/instagram/581066165581870
FFmpeg: http://www.ffmpeg.org/legal.html