VideoHelp Forum



Support our site by donate $5 directly to us Thanks!!!

Try StreamFab Downloader and download streaming video from Netflix, Amazon!



+ Reply to Thread
Results 1 to 8 of 8
  1. Member
    Join Date
    Mar 2011
    Location
    Paris, France
    Search PM
    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")
    Quote Quote  
  2. Kawaiiii
    Join Date
    May 2021
    Location
    Italy
    Search Comp PM
    Originally Posted by yetanotherlogin View Post
    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")
    Don't know about Python.. and I'm not sure if this is the YT_DLP you're talking : https://github.com/yt-dlp/yt-dlp

    To download a video in a specific format using the command-line in YT-DLP you need to use the --format parameter (also -f ).. in your case YT_DLP.exe --format mp4 <url of the video>
    Quote Quote  
  3. Member
    Join Date
    Mar 2011
    Location
    Paris, France
    Search PM
    Yes, it works with the CLI, but not in Python, hence my question here.
    Quote Quote  
  4. I also can not help with Python.
    I use command line.
    Here is what I use:
    I start with
    Code:
    yt-dlp --list-formats https://www.youtube.com/watch?v=fHT2CtiEAhM
    I tried the largest files first but some of those were "Forbidden".
    There are the largest size numbers that worked:
    Code:
    yt-dlp -f 140+137 https://www.youtube.com/watch?v=fHT2CtiEAhM
    This also worked but the file size was much smaller:
    Code:
    yt-dlp -f ba*+bv* yt-dlp1 https://www.youtube.com/watch?v=fHT2CtiEAhM
    I hope there is a way you can use these with Python.
    Quote Quote  
  5. Keep in mind that some codecs can't be put in MP4.
    Quote Quote  
  6. Kawaiiii
    Join Date
    May 2021
    Location
    Italy
    Search Comp PM
    Originally Posted by jagabo View Post
    Keep in mind that some codecs can't be put in MP4.
    that video the user posted has an mp4 source for video.. so I think the problem in in how he's implementing the call to the YT-DLP in python.. something wrong with how parameters/options are passed, probably.
    Quote Quote  
  7. Originally Posted by jagabo View Post
    Keep in mind that some codecs can't be put in MP4.
    The list formats only had .mp4 & webm video.
    .m4a audio & webm audio as opus.
    The opus codec can not be in an .mp4
    The webm opus were not the largest audio files available.
    While size is not an absolute indicator of quality. It is a fairly good one.
    Quote Quote  
  8. Originally Posted by cholla View Post
    This also worked but the file size was much smaller:
    Code:
    yt-dlp -f ba*+bv* yt-dlp1 https://www.youtube.com/watch?v=fHT2CtiEAhM
    Because you need to specify the extension. This should work:
    Code:
    yt-dlp -f bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4] https://www.youtube.com/watch?v=xxxxxxxxxxx
    You can also force the H.264/AVC codec:
    Code:
    yt-dlp -f bestvideo[ext=mp4][vcodec^=avc1]+bestaudio[ext=m4a]/best[ext=mp4] https://www.youtube.com/watch?v=xxxxxxxxxxx
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!