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'`

to make this even easier firstly copy yt-dlp to Windows folder OR add the folder where you keep yt-dlp in your environmentv path

then make a batch file, first adding the location you want the videos to be downloaded, then add the line jeffs mentions plus add *% at the end of the MP4 conversion line which will be used by the batchfile to take an argument:

cd c:\downloads
yt-dlp -S res,ext:mp4:m4a --recode mp4 %*

Then save the batchfile in the same folder with the yt-dlp executable, give it a useful name like yt2mp4.bat

then whenever you need to download a youtube video to mp4 just open a commandprompt, type the name of the batchfile you created then a space then add the direct youtube link.