23 Jul 2015

Download you tube video from command line ! Youtube downloading for geeks

There are pretty much too many ways to download a video from YouTube. But today i am going to show you how a geeky way to download YouTube videos without using all those stupid plugins or spammy  sites. but just using a command prompt Remember this is just an experimental stuff and you wont get things quickly as you would expect from a  GUI  tool.




Things that you would need
I told you its just an experimental thing, and its going to entertain only those people who are familiar with things like basic npm and basic command line tasks.

How its done
So if you haven't used npm yet do a google search for npm ,and install it. Npm is a package manager for web, it can be used to install and manage packages and dependencies if you are working on a web project especially one that is dealing with  node.js... ok lets get off from those tech stuff , cos it will be boring if i keep on bluffing all those stuff.

Anyways, once you have installed npm, open your favorite command line tool (powershell,terminal or whatever). Move to the directory where you want the files to be downloaded via the command line.
Now we need to install a package called ytdl . Ytdl is a command line YouTube downloader written in node.js. To install this package just type the following commands:

npm -g install ytdl

It will take a minute or two to install based on your internet speed,By the time you can go to YouTube and grab a link of your favorite video .Here is my link, which is music video of azazeel the band.
BTW, Azazeel is a great band based off from Kerala if you like some progressive  music please do support them .


https://www.youtube.com/watch?v=d-Ca72Hu2sU


Now lets move on to our task, just type in ytdl videourl>filename in the command prompt.In my case it will be :

ytdl  http://www.youtube.com/watch?v=d-Ca72Hu2sU>azazeelshivam.flv





It will start downloading the file,unfortunately it wont show you a progress bar rather it just keeps on rolling until the video is fully downloaded.There are some extra parameters we can give along with the command they are:
Parameters
we can chnage the quality of the video by adding an extra paramater called --q or --quality , followed by an itag, Itag something that google internally uses for separating video based on the quality.It allocates a specific number for each quality video based on its resolution and file format. Here is complete list of itag table which i grabbed from Wikipedia

DASH (audio only)
itag value[1]Default containerVideo resolutionVideo encodingVideo profileVideo bitrate (Mbit/s) [2]Audio encodingAudio bitrate (kbit/s) [2]
5FLV240pSorenson H.263N/A0.25MP364
6FLV270pSorenson H.263N/A0.8MP364
133GPN/AMPEG-4 VisualN/A0.5AACN/A
173GP144pMPEG-4 VisualSimple0.05AAC24
18MP4360pH.264Baseline0.5AAC96
22MP4720pH.264High2-3AAC192
34FLV360pH.264Main0.5AAC128
35FLV480pH.264Main0.8-1AAC128
363GP240pMPEG-4 VisualSimple0.175AAC32
37MP41080pH.264High3–5.9AAC192
38MP43072pH.264High3.5-5AAC192
43WebM360pVP8N/A0.5Vorbis128
44WebM480pVP8N/A1Vorbis128
45WebM720pVP8N/A2Vorbis192
46WebM1080pVP8N/AN/AVorbis192
82MP4360pH.2643D0.5AAC96
83MP4240pH.2643D0.5AAC96
84MP4720pH.2643D2-3AAC192
85MP41080pH.2643D3-4AAC192
100WebM360pVP83DN/AVorbis128
101WebM360pVP83DN/AVorbis192
102WebM720pVP83DN/AVorbis192
DASH (audio only)
itag value[1]Default containerAudio encodingAudio bitrate (kbit/s) [2]
139M4AAAC48
140M4AAAC128
141[6]M4AAAC256
171WebMVorbis128
172WebMVorbis192
249WebMOpus48
250WebMOpus64
251WebMOpus160
Live streaming
itag value[1]Default containerVideo resolutionVideo encodingVideo profileVideo bitrate (Mbit/s) [2]Audio encodingAudio bitrate (kbit/s) [2]
92TS240pH.264Main0.15–0.3AAC48
93TS360pH.264Main0.5–1AAC128
94TS480pH.264Main0.8–1.25AAC128
95TS720pH.264Main1.5–3AAC256
96TS1080pH.264High2.5–6AAC256
120[7]FLV720pH.264Main@L3.12AAC128
127[8]TSN/AN/AN/AN/AAAC96
128[8]TSN/AN/AN/AN/AAAC96
132TS240pH.264Baseline0.15–0.2AAC48
151TS72pH.264Baseline0.05AAC24


So basically it means that you need to pass along an itag value to download the video in your desired quality. For example if i want to download a video with 240p whose itag is 5 . i have to use :

ytdl videourl>filename.flv --quality 5

Moreover, instead of itag if you use pass --quality lowest or --quality highest. ytdl will automatically download the video on the highest or lowest resolution possible.It might be useful since all resolutions are not supported for all videos


That's  all,Happy hacking!

0 comments:

Post a Comment