2025-08-12

Hello,

I'm trying to turn a Windows batch file using the youtube-dlp.exe binary to a Python script. They're such a pain over there in the issues section that I'd rather ask elsewhere.

Although I kept the "ext:mp4" bit, for some reason, the following script downloads the file as .webm instead of .mp4.

Any idea why?

Thank you.

Code:

import yt_dlp

yt_opts = { 'extractor-args': 'youtube:lang=fr', 'S':'width:640,ext:mp4,lang:fr-FR',

'trim-filenames':'128',

'compat':'filename-sanitization',

'console-title':'',

'progress':'',

'progress-template':'%(progress._percent_str)s',

}

with yt_dlp.YoutubeDL(yt_opts) as ydl:

ydl.download("https://www.youtube.com/watch?v=fHT2CtiEAhM")

Show more