How to download an MP4 from YouTube, every time

I use yt-dlp to download videos off YouTube quite frequently. I'll use the videos as reference, and I often use it to grab the VOD for one of my livestreams, since there's no simpler way (I'm not going to dig through the bowel's of YouTube's UI to try to download one of my own videos...).

But I also can't handle the default .webm videos in all my video editing tools natively, and transcoding is annoying. So I've settled on the following yt-dlp command to first try to pull a native MP4 version off YouTube, and failing that, transcode to MP4 immediately after downloading:

yt-dlp -S res,ext:mp4:m4a --recode mp4 https://www.youtube.com/watch?v=dQw4w9WgXcQ

And if you weren't aware, yt-dlp does an excellent job pulling video files from other sites as well, should the need arise.

Comments

Interesting. Is this tool related to youtube-dl? that is the one I've been using. If so, are you aware of any of the pros-cons between the two?
PS. Love your videos. Keep up the great work. Hope your health is getting back under control.

Yes, basically yt-dlp is a more maintained version of youtube-dl (there have been a few times when the original project went unmaintained for a while).

thank you, was wondering what the best option was for this. transcoding was taking a long time per video..

Jeff since you have given back so much useful information to me over the years, here is yt-dlp tip I would suggest to everyone.

I would first run this command to check the different qualities of the video that are available on the YT servers:

yt-dlp --geo-bypass -F https://www.youtube.com/watch?v=dQw4w9WgXcQ

Considering you want to download the highest quality mp4 file from YT, here is the command to use:

yt-dlp -f 137+140 https://www.youtube.com/watch?v=dQw4w9WgXcQ -o %%(title)s.%%(ext)s

Here are the explanations of the variables I used in the yt-dlp commands:

--geo-bypass     Bypass geographic restriction via faking X-Forwarded-For HTTP header (default)
-F                       List available formats of each video. 
-f                        Video format code
-o                       Output filename template

In this case %%(title)s gets the title from YT video and %%(ext)s gets the extension from YT for this video would be mp4.

I hope you find this information useful.

Take care of yourself and your family!

I wonder what the difference is, between:

`-S res,ext:mp4:m4a`
and
`-f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best'`