Sunday 20 March 2016

youtube-dl - How to always download mp4 only

How often do you try to watch a video on YouTube and the playback is jerky and voice is out of sync, making the whole thing painful to watch.  There are video download 'helper' add ons available for most browsers, but they are also a pain most of the time.  The only time I ever had malware on my Linux machines was form one well known download helper

There is a solution.  Youtube-dl is a handy command line tool that and can be used to download video not only form YouTube, but from many more sites.  Because it works from the command line it can also be used in conjunction with other programs that stream video.

There are even a couple of GUI interfaces that make good use of its power.  But for now, we'll look at pure command line.

The basic method to download a video (we'll use YouTube for the example) is to open a youtube page and open a video, the copy the address of the video, either by copying from the address bar, or right clicking the viceo and copying the 'vidwo url'.
The open a terminal and type youtube-dl followed by the address of the link to the video (you can copy and paste it).

So if you had uploaded a video to your YouTube account and want to download it again to watch, you might end up with something like this in your terminal.

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

Press enter and youtube-dl will check for the highest quality video on the page and download it.
And here is where the problem occurs.

Many of my playback devices cannot play .webm files.  And often webm. happens to be the highest quality file on the page.

So I prefer to download any video as an mp4 for consistency.  To do that, I enter:

youtube-dl -f mp4   (followed by the url of the video)

Now youtube-dl will only download and save videos as mp4, and I don;t end up with files I cannot play back.

It is also possible to set the config file of youtube-dl to only download as mp4.  To override it you would then haver to put an ignore argument in the command line.  For now though, this is the easy way to make sure you get an mp4 rather than a webm file.

Also it is worth remembering that unless you modify the config file, youtube-dl will always download to the folder in which you opened the terminal.  So if you open a terminal from your /home/Download/Youtube/  folder, that's where the files will be saved.


No comments:

Post a Comment