Install Youtube on VPS

888u

Last update at :2024-05-05,Edit by888u

Youtube-dl is a very powerful online video download tool that can download videos and audio from major audio and video websites outside mainland China. It supports many websites, such as YouTube, Youku, Station A and Station B, iQiyi and many more Live streaming platform. FFmpeg is a very powerful audio and video processing tool, with functions including merging, splitting, and suppressing audio and video. This article mainly talks about how to install these two tools on our vps (not limited to virtual architecture) to download YouTube video files with resolutions of 1080P and above.


You may want to pay attention to the following three websites:

Youtube-dl Github project address: https://github.com/rg3/youtube-dl

List of video and audio websites supported by Youtube-dl: http://rg3.github.io/youtube-dl/supportedsites.html

FFmpeg official website: http://www.ffmpeg.org/


This article is mainly divided into four parts

1. Basic environment configuration

2. Install Youtube-dl

3. Install FFmpeg

4. Download youtube videos


1. Basic environment configuration

No matter what operating system it is, update is absolutely necessary before you install the software. At the same time, we need to use wget when installing Youtube-dl. If your operating system does not have wget installed, you need to install it first. gcc is also used, so it must be installed as well.

This article uses the Centos 7 operating system for experimental installation. Ubuntu was not tested due to various reasons.


Centos 7:

yum update

yum install wget

yum install gcc

yum install gcc-c++

yum install make


Ubuntu:

apt-get update

apt-get install wget

apt-get install build-essential

apt-get install make


2. Install Youtube-dl

There are many ways to install Youtube-dl. The one used here is a universal method.

wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl

chmod a+rx /usr/local/bin/youtube-dl


3. Install FFmpeg

If you don't plan to download 1080P and above resolutions, there is no need to install FFmpeg.

There are many ways to install FFmpeg, but the only way to install FFmpeg without distinguishing between operating systems is to compile and install it, so just use this method. However, in order to improve the compilation speed, FFmpeg uses assembly instructions. If there is no yasm instruction in the system, it must be installed first.

It should be noted that the compilation and installation time will be relatively long, ranging from ten minutes to several hours. It is recommended to use screen (http://www.138vps.com/vpsjc/933.html).

At the same time, compilation takes up a lot of CPU. It is recommended not to choose a merchant with large CPU restrictions.


1. Install yasm

wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz

tar -zxvf yasm-1.3.0.tar.gz

cd yasm-1.3.0

./configure

make

make install

If: [make: *** No targets specified and no makefile found. Stop.] Please see Note 1


2. Install FFmpeg

cd /root

wget http://www.ffmpeg.org/releases/ffmpeg-3.3.3.tar.gz

tar -zxvf ffmpeg-3.3.3.tar.gz

cd ffmpeg-3.3.3

./configure

make

make install


After a long level, the compilation is finally completed and we can check the installed ffmpeg version

ffmpeg-version


4. Download Youtube videos

Downloading YouTube videos is very simple. For example, the following command will automatically download the highest resolution video.

youtube-dl https://www.youtube.com/watch?v=SLaYPmhse30


However, for damn YouTube videos with 1080P resolution and above, their audio and video are separated, so if we want to download high resolution, we have to download the audio as well, so we have to look at all the videos first Optional resolutions and audio:

youtube-dl -F https://www.youtube.com/watch?v=SLaYPmhse30


The result is as shown in the figure, please pay attention to format-code:

audio only means only audio

video only is only video


If you just want to download 720P videos, then by looking at the picture above, just add format-code when downloading:

youtube-dl -f 22 https://www.youtube.com/watch?v=SLaYPmhse30



If you want to download 1080P, in addition to downloading the video, you must also download the audio, because youtube-dl will automatically call ffmpeg to merge the audio and video, so we only need to download it. After the download is completed, youtube-dl will Automatically call ffmpeg to merge audio and video.

youtube-dl -f 137+140 https://www.youtube.com/watch?v=SLaYPmhse30


In addition, youtube-dl can also download the entire video list and subtitles. It is quite powerful. Please learn more through Baidu or Google.

The function of ffmpeg is also very powerful. If you are interested, you can search it on Baidu yourself. If you have to write it down, it seems that this is not the knowledge point to be shared in this blog.



Remarks

1. Note 1 If there is a problem following the above operations, it may be that some dependencies are not installed. The solution is as follows:

centos:

yum install gcc gcc-c++ autoconf automake

yun -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel

ubuntu

apt-get install gcc build-essential

Then start over with the [ ./configure ] command.

Recommended site searches: German servers, best American servers, domain name expiration query, American European cloud servers, how to register company domain names, high-defense servers, Guangdong server rental, free foreign space, proxy server ipftp space,

Install Youtube on VPS

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码