Created
September 24, 2019 05:45
-
-
Save khalid32/129cdd43d7347601a6515eeb6e1bc2da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### extract videos as mp3 files | |
youtube-dl -x --audio-format mp3 <video link> | |
### get highest resolution audio & video | |
To download a video, you type the URL after the command like so: | |
youtube-dl <video link> | |
To select the video quality, first use the -F option to list the available formats, here’s an example, | |
youtube-dl -F <video link> | |
Here’s the output: | |
[youtube] Setting language | |
[youtube] P9pzm5b6FFY: Downloading webpage | |
[youtube] P9pzm5b6FFY: Downloading video info webpage | |
[youtube] P9pzm5b6FFY: Extracting video information | |
[info] Available formats for P9pzm5b6FFY: | |
format code extension resolution note | |
140 m4a audio only DASH audio , audio@128k (worst) | |
160 mp4 144p DASH video , video only | |
133 mp4 240p DASH video , video only | |
134 mp4 360p DASH video , video only | |
135 mp4 480p DASH video , video only | |
136 mp4 720p DASH video , video only | |
17 3gp 176x144 | |
36 3gp 320x240 | |
5 flv 400x240 | |
43 webm 640x360 | |
18 mp4 640x360 | |
22 mp4 1280x720 (best) | |
The best quality is 22 so use -f 22 instead of -F to download the MP4 video with 1280x720 resolution like this: | |
youtube-dl -f 22 <video link> | |
Or optionally use the following flags to automatically download the best audio and video tracks that are available as a single file: | |
youtube-dl -f best <video link> | |
If you encounter any error during the muxing process or an issue with the video quality selection, you can use one of the following commands: | |
youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio' --merge-output-format mp4 <video link> | |
or as Gabriel Staples pointed out here, the following command will typically select the actual best single file video quality resolution instead of video quality bit-rate: | |
### merge best audio & best video quality | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
YOU MUST FIRST INSTALL `ffmpeg` to merge audio & video | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
check the info | |
youtube-dl -F <video link> | |
Just use `-f bestvideoformatcode+bestaudioformatcode` or `-f bestvideoformatcode+bestaudioformatcode/best` for highest resulting quality available. For example, | |
youtube-dl -f 315+251 <video link> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment