Have you ever had issues trying to watch a YouTube video where you have spotty Wi-Fi coverage? Or worse, you've wanted to watch a 4k video but your download speeds are too slow? Perhaps you're the type of person who frets at watching the race between the YouTube buffer and the playback indicator. Whatever your reason, you can mitigate those issues by locally storing your favorite YouTube videos for personal use using the terminal on macOS. Here's how!
What is youtube-dl
You can archive YouTube videos by using youtube-dl. Youtube-dl (the dl stands for "download") is open source software that's freely available on a variety of platforms including macOS. It's a command line utility that runs in the macOS terminal application.
There are a number of ways to have youtube-dl installed on your Mac.
- You can download the source code and build it using a compiler.
- Or, you can install Homebrew as a package manager and then subsequently install the youtube-dl executable.
- Finally, you can install the pre-built application directly with the following commands in terminal.
- sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
- sudo chmod a+rx /usr/local/bin/youtube-dl
Using youtube-dl boils down to copying the URL of the video you want to archive and appending it to the youtube-dl command in the terminal. However, there are some nifty options that you can use to make certain you get the video quality level that you want.
For example, if you simply wanted to download and watch a video, do the following.
- Start terminal.
- Type in youtube-dl URL_OF_VIDEO.
- Hit return.
The application will download the default "best" version that contains both video and audio. You can then use your video player of choice to play the downloaded file.
However, if you wanted to download a specific resolution, just download the video portion, or if you simply wanted an audio-only portion to download, here's how you do it.
- Start terminal.
- Type in youtube-dl -F URL_OF_VIDEO.
- Hit return.
You'll now be presented with a list of formats you can choose from.
Some format codes include both audio and video — some just video and some just audio. Let's say for example I wanted to download the 4k version of my chosen video. In my list of formats, I can see the format code 313 is the 4k video file with no audio. In order to download that specific format, type the following in terminal.
- youtube-dl -f 313 URL_OF_VIDEO.
You'll now have downloaded the 4k video only portion. You'll have to then download the audio separately. In my example, the audio-only version I want is format code 251. So I'd type the following in terminal.
- youtube-dl -f 251 URL_OF_VIDEO -o AUDIO_ONLY.output.
This downloads the audio-only portion that I chose and renames the file to AUDIO_ONLY.output so to not overwrite my downloaded video file.
In order for me to play the two files simultaneously, I'd need a compatible media player that can mux the two files synchronously. You can use something like VLC. I stick to the command line and use mplayer instead. Continuing with my example, with mplayer installed, I'd type the following in terminal.
- mplayer -lavdopts threads=6 -audiofile AUDIO_ONLY.output DOWNLOADED_VIDEO_FILE_NAME.
Then I can enjoy my locally stored video and audio without the need for a good (or any) internet connection. if you need any more information on how to use youtube-dl you can read the youtube-dl manual in the terminal by typing in man youtube-dl.
Have you ever wished that you had a local copy of a YouTube video? Do you have other suggestions as to how to ameliorate your YouTube viewing experience? Let us know in the comments!
We may earn a commission for purchases using our links. Learn more.
Telegram now supports video calls on iOS
Secure messaging app Telegram now supports fast and secure video calls on iOS.
TikTok ban gets extended to 90 days with new executive order
Under the new executive order from President Trump, ByteDance has 90 days to divest itself from its business in the United States.
'Nineteen Eighty-Fortnite' has been streaming 17+ hours. With Apple ads.
Epic Games isn't letting up in its war with Apple over Fortnite.
Show off your pictures with a smart digital photo frame
A digital photo frame is a logical answer to thousands of pictures on multiple devices. We've rounded up the best right here.