youtube-dl, or how to download YouTube videos as 1080p and higher
YouTube video hosting is the second most visited website in the world. It is watched from smart TVs, gaming and set-top boxes, desktops and laptops, tablets and smartphones. Not all of these devices require the same picture. The network nature of the service and streaming video suggests that the site should have access to viewing options in different qualities.
The picture quality on YouTube varies from 144p (144 lines in a progressive scan) to 8K 4320p. The last video is four times larger than 4K 2160p, at sixteen - 1080p, at thirty-six - 720p, which is also called HD.
Few computers can play this video in its full resolution, and 8K monitors are not available in the world at affordable prices.
')
MPEG-DASH technology breaks content into chunks, and the browser requests these segments automatically. It is logical to store and give separate video and sound. DASH has a fat plus: playability adaptability.
A few years ago, YouTube users noticed the introduction of DASH by the fact that video buffering no longer went to the end of the video, but was limited to about a minute. Around the same time, another problem arose in downloading videos from YouTube. Suddenly, 1080p-quality videos were found available as silent files. Sites services that previously gave out links to download videos, gave only 720p, not higher. About 1080p stood “without sound” or “video only”.
A simple solution: download a video file, download a sound file and combine them with, for example, FFmpeg . Download sites did not dare to do this: traffic is needed for this, disk storage space, finally, you can get a ban on IP from YouTube itself. Such services live on the income from banners, and this money does not allow this.
The problem can be solved on the client side. The user also needs to figure out how to download raw data from YouTube, determine its quality and select the best options. The video is stored in VP9 and MP4, the sound is M4A, Vorbis or Opus in WebM. There are many options with different bit rates. After that, you need to sew everything into a .mp4 or .mkv container. Depending on the formats chosen, the command for FFmpeg might look like ffmpeg -i videoplayback.mp4 -i videoplayback.webm -c:v copy -c:a copy videoplayback.mkv , where videoplayback.mkv is our finished file.
The process is monotonous, why not automate it? There is a utility that performs all this on its own and supports several more video hosting sites.
youtube-dl
youtube-dl is a cross-platform free open source project in Python. Development began Ricardo Garcia , today the project are several contributors .
A download version is available for Windows and installation instructions for UNIX-like systems (Linux, OS X, FreeBSD, and others). For work in Windows, Microsoft Visual C ++ 2010 Redistributable Package x86 is required, for all others - Python version 2.6, 2.7, 3.2 or higher.
Youtube-dl is in the package directories of some Linux distributions: sudo apt-get install youtube-dl , sudo yum install youtube-dl , sudo pacman -S youtube-dl - all this should install the utility. Rather, one of its versions, which quickly become obsolete. It is more logical to install python-pip , and then install from there: sudo pip install youtube-dl . For comparison: at the time of writing the article in the Debian repositories is version 2014.08.05, while 2016.11.4 is relevant.
Some of the following instructions apply only to users on Windows 10, but the general principles work everywhere. Move the downloaded youtube-dl.exe to any folder, for example, create the Downloads folder in Videos . In the "Explorer" in the "File" menu, open "Command Prompt".
So, to deflate the video at maximum resolution and with the best sound, you need to enter a command like
That is, you need a link to a page with a roller. In Windows 10, the Ctrl + V insert works in the “Command Line”. In earlier versions, right-click to open the context menu and select the “Insert” menu item.
Downloading playlists is similar. The format of the link to the playlist is https://www.youtube.com/playlist?list=PL94A83DC128CC6B4B , that is, you need to go to the main page of the playlist. Caution: youtube-dl will download all videos in the playlist.
You can download all the user's videos: you just need to substitute a link to the channel in the form https://www.youtube.com/user/username .
The -F flag will display all available formats. If you enter the -f flag with a numeric format code, it will be downloaded. The combination -f bestaudio download audio in the best format.
The process of pumping out 981 clips in the form of audio from a Korean ASMR channel.
One thing is not limited to YouTube: the program can download from a large number of sites . If the download is interrupted by Ctrl + C, and then restarted, the utility will recognize the under-downloaded fragment and start downloading the remainder.
Video services regularly update their players, some struggling with “rockers”, youtube-dl adds new and new sites to the list of supported. Therefore, it is sometimes desirable to be updated. In self-downloaded versions, the update is performed on youtube-dl -U ( sudo as needed). In the case of pip, you need to run sudo pip install -U youtube-dl .
As an analogue of a small free utility without a graphical interface, you can bring Freemake Video Downloader. This software contains a reference set of disgusting practices of cheap software for Windows.
On the download page, the product is advertised as free. As it often happens, in addition to the program itself, the installer tries to install a third-party product. It is already so familiar that it has become the norm. Installation unnecessary can be avoided only if you choose a installation with options. It’s best not to run the installer at all: the program was accused of throwing Trojans, spyware and adware even when unchecking all the checkboxes.
The program can download videos with sound from YouTube at a resolution of 1080p and higher. There is only one problem: in the free version you can download only at a speed of 4 megabytes per second. To remove the restriction, you need to lay out 10 dollars. All this is a bit contrary to the claims for free. The program interface itself is tasteless and contains many advertisements for other products of the manufacturer.
Another similar software for pumping video performs a trivial task, but requires a fee for the removal of restrictions. Only Free Download Manager can be called fair, but its ability to download video is weaker: there is no support for playlists and channels, the list of supported sites is limited to YouTube and Google Videos.
In fact, this post is not about a specific program that can do something. And not about the fact that console applications are better.
A modern user has acquired a positive habit: when he needs to solve a certain problem, he types its description in a search engine and pokes results in the first page. For more than a decade and a half of the existence of search engines and thanks to the flourishing of artificial intelligence systems, the question “remove wrinkles” is guaranteed to give out five to ten articles that will almost always solve the problem.
At the other end, another good habit emerged: writing software for Windows that solves a problem that can be described using a search query. For example, “download youtube 1080p video”. There are many similar requests from users. You can make programs for each of them, provide a free version with the ability to upgrade to the full for 10-30 dollars. Or sell the installation: distribute with the program unwanted software or viruses in general.
There is a wonderful free open source software that solves these user-generated requests. But search engine optimization will never allow it to settle on the first lines of issue. There are a variety of programs of dubious origin. They do not inspire confidence in either the quality or the fact that the installer will slip. This is the tragedy of life useful software level youtube-dl.